Introduction: Intel Edison IoT - Reading Freescale MPL3115A2 Pressure Sensor
Hello everyone, last instructable I had show you how to read accelerometer and control servo. If you haven't read it yet, I suggest you should take a look because it's quite fun!
Now, in this project, we will know how to read Freescale Pressure Sensor, view it on Grove RGB LCD and put the data to serial in real-time. Let's get started!
Step 1: Collecting the Parts
There are a few stuff you will need in this project:
- Intel Edison
- Edison Arduino Expansion Board
- Grove Base Shield
- Grove RGB Backlight LCD
- Freescale MPL3115A2: 50 to 110kPa, Absolute Digital Pressure Sensor, you can find a breakout board in Sparkfun or Adafruit. I also remake my own breakout board version for prototype purpose, and it works great.
- 2 * 330R or 1k resistors to support I2C connection
- A BreadBoard, some bus wire and header for wiring stuff
Step 2: Build the Circuit
There are some notes you should know before starting:
- The Grove LCD and the pressure sensor are both use the I2C interface, so in this project, you will experience how can they work together simultaneously.
- The pressure sensor works with 3V3, NOT 5V in Arduino Expansion Board.
- You have two options: Adjust the Expansion Board to 3v3 logic level or Insert the resistors between I2C connection like below:
MPL3115A2 <--------> Edison (5V logic level)
VCC ------------------- 3V3 Power Supply
GND ------------------- GND
SCL ------330R------- SCL
SDA ------330R------- SDA
The LCD should be plug in the I2C port of Grove Base Shield as usual.
That's all! Let's dig inside the code and working principle!
Step 3: Let's Make It Run!
First, make sure that you are already installed all drivers and software, flash the newest Yocto Linus image to Edison, and do a blink example with Arduino Edison Compiler. If not, you must check out the specific getting started guide on intel maker site or the Intel IoT in Instructable, they are very useful for you to get familiar with Edison and Arduino.
Second, go to Sparkfun site and download MPL3115A2 driver library and example. Sparkfun has already built a specific library and good example code, so we don't need to build it again.
Here is where you can find the driver and useful info about the sensor:
MPL3115A2 overview: https://www.sparkfun.com/products/11084
Driver library: https://github.com/sparkfun/MPL3115A2_Breakout/tre...
Hookup Guide: https://learn.sparkfun.com/tutorials/mpl3115a2-pre...
Next, open the Arduino Edison Compiler and import the library. Go to Sketch/Import Library/Add Library...
Choose the downloaded firmware folder of driver library, and everything is imported. Now go to File/Example/MPL3115A2_Pressure and pick an example you like.
Now, try to verify it use a tick symbol on the upper left of the compiler. If nothing go wrong, then we are almost finished. Next, open the ino file attached, copy the code and paste to the basic example windows.
For more real-time data viewing, open the arduino Serial Monitor, it's located on the upper right of the compiler. Seem like it's smart enough that you don't have to adjust the baud rate, all you need to open and watch the output data. Besides, I have managed to put the data through LCD, so it's more convenient!
Finally, everything is really, now you can compile the code and enjoy the result. So now you can build your own weather station! Good luck, see you next time, enjoy!
We have a be nice policy.
Please be positive and constructive.