Sensors And LED’s Loved By Raspberry Pi:
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.
Raspberry Pi : 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.
SDA >>> SDA
Raspberry Pi : I2 C Tools
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
wget -O geekman-python-eeml.tar.gz https://github.com/geekman/python-eeml/tarball/master
tar zxvf geekman-python-eeml.tar.gz
sudo python setup.py 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.
Raspberry pi : Temperature Graph on website with help of sensor
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.
The below line of code is run in order to get a separate copy of my repository on your local machine.
on your desktop, to get a copy of my repository.
There will be two files available. Open i2cpy.py 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.
Raspberry pi : How to check emails using Raspberry pi
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 i2cLED.py 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.
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.