Picture of Raspberry pi loves Sensors and LEDs
This tutorial teaches you how to talk to I2C devices on a raspberry pi, this is based on the ADAfruit tutorials but i have made the code more generic and you can easily modify them to work with any sensors.

This tutorial uses the distro provided by adafruit, if you dont have the distro up an running re-visit one of my old tutorial on raspberry pi.

Remove these adsRemove these ads by Signing Up

Step 1: Parts

Picture of Parts
i am using a Mblink and PMODtemp (from digilent) for this tutorial, this approach would work for most I2C devices. connect the I2C sensor to the I2C pins refer the connection diagram from here, make sure you connect the a 3.3v I2C sensor.


the diagram below is from http://elinux.org/RPi_Low-level_peripherals

Step 2: Tools

Picture of Tools
photo 2.JPG
photo 3.JPG
photo 4.JPG
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 https://github.com/geekman/python-eeml/tarball/master

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.

Pigumon1 year ago
Sadly I still know very little about sensors and electronics. But it seems like this would be a great way to make a Star Trek / Ultraman / '60s blinking panel that actually means something.

Any thoughts on WHAT all the various lights could be used for? Home temperature, security, motion sensors...
do you have rPi some sensor projects you're thinking of trying?
sajingeo (author)  amandaghassaei2 years ago
Yes i do have a couple of I2C EEPROMs and Color Sensors that i would like to try very soon(just cant find the time).