By: Rohan Daruwala (rdaruwala@wisc.edu)
A tutorial to introduce people to BadgerLoop embedded software development by creating a BeagleBone Black driver for the BMP180 pressure sensor.
At the minimum, you should be familiar with programming fundamentals (CS 300-ish), connecting to a linux computer via SSH, building basic circuits, and understanding binary & how data registers work (CS/ECE 252). Experience with basic C programming (CS/ECE 354) is recommended.
This tutorial uses the following devices:
- BeagleBone Black
- BMP180 Pressure Sensor (Your sensor may not look like this)
- Male/Male Jumper Wires
- Breadboard
- 2x 4.7 kOhm Resistor
First, plug the BMP180 sensor into the breakout. Using the jumper wires and resistors, wire it up to the BeagleBone according to the following schematic:
Note that your sensor breakout may not look like the one in the picture. That's perfectly fine, just make sure that you're plugging the right wires into the right ports (VIN, GND, SCA, and SCL). If you know that your BMP180 breakout includes pull-up resistors, you can opt to remove them from your breadboard. If you don't know what a pull-up resistor is, don't worry. We'll explain it later.
Once you've connected everything, turn on the BeagleBone and connect to it via SSH. To verify that you've installed the sensor correctly, run the following command:
i2cdetect -r 2
You should see a screen similiar to the following:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77
If you see 0x77
, this means that the BMP180 is correctly installed!
Next, clone this repository:
sudo apt-get install git
git clone https://github.com/rdaruwala/embedded-tutorial
Compile the program with the following commands:
cd embedded-tutorial
make
Finally, run it:
./bmp180
And you'll see an output looking like:
Altitude : 442.29 m
Pressure : 961.24 hPa
Temperature in Celsius : 20.75 C
Temperature in Fahrenheit : 69.36 F
This means it's working! Good job!
Next, let's take a dive into the code and see how and why it works.