For this tutorial, we will be using the Freescale Xtrinsic sense board. This small chip is connected via GPIO to your Raspberry Pi and has several sensors:
- MPL3115: air pressure, height and temperature
- MAG3110: magnetic fields
- MMA8491Q: velocity (position or speed)
For now, we will just try the temperature sensor. Using the other sensors is easy as well!
You will need a Raspberry Pi installed with an OS (Raspbian preferred).
First, we need the OS to support the sensor board. For that, you will need to enable I2C drivers. We can do this by modifying the blacklist modprobe file.
Open up a terminal and type:
sudo nano /etc/modprobe.d/raspi-blacklist.conf
Put a "hashtag" (#) in front of “blacklist i2c-bcm2708”. This tells the OS to ignore that and will not block the loading the driver. Press Ctrl+O to save and then Ctrl+X to exit.
Then we need to download the sample code. So type in terminal:
This git project has the sample code for reading the sensors and also simple web server output.
Let's reboot to enable the drivers.
So after the reboot, we should be all set. "cd" to the git project and type
sudo python mpl3115a2.py
You should now see temperature & altitude information come up to your terminal.
Running the web server stuff is bit trickier. You need to have Apache + PHP working on your server before using this.
sudo python sensor_website.py
This starts the sensor daemon for the website. Choose which sensor you want to read (for this tutorial, mpl3115).
Now, copy rpi_sensors_web folder to your web server root.
After that, you should be able to check the website with:
If you want to make your custom temperature monitor software, you can open the file mpl3115a2.py with your favorite text editor and see how it works. The code is rather simple to read.