Sensors And LED’s Loved By Raspberry Pi


Sensors And LED’s Loved By Raspberry Pi:

Sensors And LED’s


The below lesson will help the user to interact with I2C devices on Raspberry pi, with help of ADAfruit lesson, however, the code has been made general so that any user can change it with ease while working with any sensor.

The below lesson is based on distro which is offered by ADAfruit, however, in case you do not have a proper functioning distro, kindly go through my old lessons on raspberry pi.

Step 1:

Raspberry Pi : Things required

Things required

For this lesson I will be making use of Mblink and Digilent’s PMODtemp. For most of the I2C devices, the below mentioned steps will work fine. I2C sensor is first connected with I2C pins’; keeping in mind that 3.3v I2C sensor is used for connection.






Step 2:

Raspberry Pi : I2 C Tools

Raspberry Pi I2 C Tools Coding

I2 C Tools Connecting

I2 C Tools wires Connecting
I2 C Tools All Set up With Raspberry Pi

Please check if the tools are installed correctly. In order to check if the tools are installed correctly, please run the following line of code.

sudo i2cdetect -y 0

The above line of code will test all the devices and make sure that they are connected to I2C bus. The below screenshot shows that the devices are connected properly. In order to install the I2C tools, run the following line of code.

sudo apt-get install i2c-tools

Run the below lines of code to install the rest of the tools:

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 install

Connected I2C device’s address is noted down. PMODTEMP2, which a Temp. Sensor from digilent is connected. For communication with I2C we will be using sumbus function.

Step 3:

Raspberry pi : Temperature Graph on website with help of sensor

Temperature Graph

The user can setup his or her own COSM account in order to get the sensor data. The user should track the feed ID and key.

In order to download git code to the folder named Home, run the following line of code which can ease up things for you.

cd /home/pi/Desktop

The below line of code is run in order to get a separate copy of my repository on your local machine.

git clone

on your desktop, to get a copy of my repository.

cd raspberry-pi-saj

cd cosm-temp-loger

There will be two files available. Open using nano command as below:


ADAfruit library which is present in the files are a great in carrying out I2C related operations and common mistakes can be avoided using it.


The temperature graph can now be implanted on the website and hosted on raspberry pi.

Step 4:

Raspberry pi : How to check emails using Raspberry pi

MBlink check emails

This step helps in checking and getting notification in case a new email arrives. Raspberry pi helps in checking email and controls Mblink to get a new notification.

Please use the first two steps in order to connect MBlink.

In order to configure the email go to /mail-checker folder in the git repository and open the file. Provide your credentials like username and password for your account and set the MAILSNOW to unread emails number in your inbox and set MAILCHECK with time duration after which emails are checked, while being connected on internet.

The LED will become RED when a new email arrives while it remains green when there is no new email, once the code is run.

 Step 5:

Raspberry Pi

Raspberry Pi Hosting

You can make an MP3 player or a CPU usage logger. The GIT repository has a README file which provide details on how to get this done. Please check other projects present in the repository.


About Author

Leave A Reply