Enregistrer des objets dans des fichiers - Python Dans beaucoup de langages de haut niveau, on peut enregistrer ses objets dans un fichier. Python ne fait pas exception. Grâce au module pickle que nous allons découvrir, on peut enregistrer n'importe quel objet et le récupérer par la suite, au prochain lancement du programme, par exemple. En outre, le fichier résultant pourra être lu depuis n'importe quel système d'exploitation (à condition, naturellement, que celui-ci prenne en charge Python). Enregistrer un objet dans un fichier Il nous faut naturellement d'abord importer le module pickle. On va ensuite utiliser deux classes incluses dans ce module : la classe Pickler et la classe Unpickler. C'est la première qui nous intéresse dans cette section. Pour créer notre objet Pickler, nous allons l'appeler en passant en paramètre le fichier dans lequel nous allons enregistrer notre objet. 1>>> with open('donnees', 'wb') as fichier: 2... mon_pickler = pickle.Pickler(fichier) 3... # enregistrement ... Bon. 1>>> score = { 2... 3... 4... 5... En résumé
Raspberry pi loves Sensors and LEDs make sure the tools are installed... to test if the tool are installed run the following command..sudo i2cdetect -y 0 this will scan all devices connected to the I2C bus. it should look like the pic below. if you see that i2ctools are not installed run the following comand sudo apt-get install i2c-tools also install sudo apt-get install python-smbus sudo apt-get install python-pip sudo pip install rpi.gpio sudo /home/pi/Desktop wget -O geekman-python-eeml.tar.gz tar zxvf geekman-python-eeml.tar.gz cd geekman-python-eeml* sudo python setup.py install note down the address of the I2C device that you have connected. in this case i have connected a temp. sensor PMODTEMP2 from digilent.we use the sumbus function for I2C communcation. COSM Account and Feed | Send Raspberry Pi Data to COSM COSM (used to be Pachube) helps connect little devices like the raspberry pi to the internet. You will need to do the following to use COSM.Setup a AccountCreate a FeedSave the API_KEYSave the FEED ID You will need to create a COSM account. Click the blue plus to add a feed. Select Arduino Give your new feed a title and tags. Title: "Raspberry Pi Temperature" (or whatever you like)Tags: raspberry pi, temperature, adc (or make up your own) Select the "Create" button. You need to extract the API_KEY and FEEDID from the code sample that COSM provides. In this example the API_KEY is: 5RNOO3ShYJxYiq2V2sgSRtz3112SAKxFQjNDQmNXc0RScz0gThe FEEDID is: 68872 Do not use those numbers, use your own!
I2C Installation for Raspberry Pi – Step by Step Guide | SK Pang Electronics Ltd This is a step by step guide on installation I2C driver for the Raspberry Pi. It is for the Raspbian image. Raspberry Pi Starter Kits Make sure your Raspberry Pi is connected to the internet when installing the drivers. The new Raspbian distro already have the I2C driver installed but they are disabled by default. To enable it all you need to do is comment out a line by putting # in front. sudo nano /etc/modprobe.d/raspi-blacklist.conf then add a # on the 3rd line. Press CTRL X then y to save and exit. Next edit the modules file by: sudo nano /etc/modules Add i2c-dev to a new line. Now install the i2c-tools package by: sudo apt-get install i2c-tools If you get a 404 error do an update first: sudo apt-get update then run the install the i2c-tools again. Note : The installation could take a few minutes to do, depend on how busy the server is. Now add a new user to the i2c group: sudo adduser pi i2c Reboot the machine by: sudo shutdown -r now After the reboot test to see any device connected by: .
Casting Python integers into signed 32-bit equivalent When implementing bit-twiddling routines in C/C++, one frequently takes for granted the implicit convertibility between signed and unsigned values of the same bit pattern and bitwidth. For example, 0xFFFFFFFF, when cast to a signed 32-bit integer will return -1. In Python however, all integers are signed and when a positive integer exceeds the maximum possible 32-bit signed value, 2147483647, it is automatically promoted to a long, e.g. 2147483648L. The following routine will take any integer value up to 0xFFFFFFFF, treat it like it had the unsigned 32-bit integer bit pattern and return the equivalent signed twos-complement integer value much like the corresponding cast in C would. The return value is guaranteed to be <type 'int'> and not <type 'long'>. def int32(x): if x>0xFFFFFFFF: raise OverflowError if x>0x7FFFFFFF: x=int(0x100000000-x) if x<2147483648: return -x else: return -2147483648 return x
Protocole I.P. ; calculs de sous-réseaux Repérage Une machine est repérée sur le réseau par une adresse IP (IPx) associée à un masque (Mx) qui sont chacun un nombre binaire de 3 bits organisé en 4 octets. Le masque sert à repérer le réseau ou le sous-réseau auquel la machine appartient. Identification du réseau Diffusion et nombre d'hôtes L'adresse de diffusion (Bx) d'un réseau ou d'un sous-réseau est une adresse réservée ( la dernière des adresses possibles du dit réseau). La capacité maximale du réseau ou du sous-réseau, appelée le nombre d'hôtes (Hx), s'obtient aisément par le nombre n de bits à 1 du masque Mx : Hx = ; 2 adresses en moins car une est réservée pour l'adresse du sous-réseau lui-même et l'autre pour la diffusion du sous-réseau ("broadcast").Dans l'exemple 1, H1 = 254 ; dans l'exemple 2, H2 = 65 534 et dans l'exemple 3, H3 = 62 . Plus Hx est grand et plus la bande passante du réseau s'amenuise et le traffic de diffusion augmente. Visibilité des machines entre elles
R-Pi Hub Notice: The Raspberry Pi Wiki pages on this site is collaborative work - the Raspberry Pi Foundation is not responsible for content on these pages. Now shipping to customers See the Buying Guide on how to order one, or visit the Raspberry Pi Foundation Home Page About The Raspberry Pi production board (model B Rev 2.0) 3D CAD Model of the Raspberry Pi 3 Model B (Download) The Raspberry Pi (short: RPi or RasPi) is an ultra-low-cost ($20-$35) credit-card sized Linux computer which was conceived with the primary goal of teaching computer programming to children. Raspberry Pi is manufactured and sold in partnership with the worldwide industrial distributors Premier Farnell/Element 14 and RS Components, and the Chinese distributor Egoman Technology Corp[1]. Products are RoHS, CE, FCC, CTick, CSA and WEEE compliant[2]. History If you are interested in why the Raspberry Pi was created, and why it is what it is, check the General History page, which highlights relevant events in its history. Resources
Self-oscillating circuit for 5V power supply - UK Vintage Radio Repair and Restoration Discussion Forum I'm trying to make a circuit using the components of a CFL (HV transistors, ferrite core, HV diodes, HV capacitors, etc) in order to obtain a 5V source to supply a TTL-made timer for a microwave oven. All circuit I have checked use two ferrite cores. I think it is posible to do it using just one core. I need some help with the cicuit configuration (for the self oscilating circuit) and how many turns (approx.) should I coil in the ferrite core. I want to rectify the 110 V AC line supply and using one of the capacitor of the CFL, obtain 150 V CD (non-regulated), and then the self-oscilating circuit with one independent secondary to obtain 5V using a single diode and a small capacitor. It is now working with an iron core transformer and a 7805 (TO-3), but I want to change to ferrite core because the iron transformer and the 7805 get hot when they work for some time. Thanks in advance. Miguel PS: If there is a thread about this I apologise.
Write plugins for XBMC XBMC includes support for writing Add-Ons written in Python. Plugins, unlike scripts, do not generally provide new functionality to XBMC, instead they provide an easy way to present content listings in XBMC through the native GUI interface. Content is usually online audio and video streams like YouTube, Vimeo or podcasts, or pictures from websites such as Flickr or Picasa. Please feel free to add samples of simple plugin functions. Add anything at all no matter how basic, if it is not already here add it! Someone will more than likely benefit from it. For end-user instruction on how to install XBMC plugins please see HOW-TO install and use plugins in XBMC. Note! Helpful tools: There's also lots of streaming sources available for building plugins: Before you begin, search the XBMC forum for the name of the plugin you are planning on creating. Right click on the file 'Default.py' and select 'Edit with IDLE'. This is just to familiarise yourself with the layout of the plugin template. for ?
R-Pi Troubleshooting Back to the Hub. This page lists the most common problems and suggests some solutions. See RPi_Bugs for problems that are bugs. Power / Start-up Note: if you have any kind of booting problems, start off by reading the "Is your Pi not booting? A good power supply that will supply 5 volts and at least 1 amp (5V 1A) is vital. Note that the Pi has no BIOS, so nothing will be displayed on screen unless the Pi successfully boots! Normal LED status There are five LEDS near the USB connector. See the next sections for how to interpret other statuses. Red power LED does not light, nothing on display The power is not properly connected. Red power LED is blinking A blinking red power LED indicates problems with the power supply. On model B+ (and presumably also the A+), the circuit has been improved to give a much more reliable warning of poor power quality. Red power LED is on, green LED does not flash, nothing on display Start off by reading the "Is your Pi not booting? Coloured splash screen xset -r Webcam .
Raspberry Pi DC Motor Driver | File Exchange Pick of the Week May 3rd, 2013 Raspberry Pi DC Motor Driver Doug 's pick this week is Raspberry Pi DC Motor H-Bridge Driver Block by Joshua Hurst . As my previous posts may suggest, I've been a long-time fan of the Arduino platform. Enter R2013a which introduced support for a number of new target platforms which Jiro pointed out earlier this year. Looking at the blocks that are included with the target, however, you'll notice that there is nothing included for sending voltages to a DC Motor like you can do with the Arduino PWM Output blocks. After some breadboard work, I built and downloaded the model and I was controlling my motor in minutes by simply changing the Input Volts value in External Mode. I was happy to see that Joshua was inspired by Giampiero's Device Driver guide that explains how to create custom drivers for the hardware support packages. One minor suggestion I would have for Joshua is to include the pin numbers that correspond to the PWM outputs for this model. By Guest Picker