I was able to get a hold of a sample of the new sensor board for the Raspberry Pi and play around with it a bit. It’s a small board that plugs into the IO expansion header on the Raspberry Pi. It has three different sensor chips on it which are connected to the Pi via I2C:
- Accelerometer (MMA8491)
- Magnetometer (MAG3110)
- Altimeter/Temperature (MPL3115)
It’s essentially the same board that can be found on the MEMS Sensors Board Evaluation Kit that came paired with a FRDM-KL25Z (a Cortex M0+ device). The difference is that now the board is now being sold stand-alone and has a new connector for the Raspberry Pi.
This means that the board can not only be used by the Raspberry Pi and FRDM-KL25Z, but also the Arduino Due. And because all the Freedom boards have an Arduino compatible footprint, it will also work with any of the Freedom boards with just a few software tweaks which I’ll attempt later.
Setup:
I have a slightly embarrassing confession to make: Even though I consider myself a huge nerd (I’d been running Linux on my home computer since high school in the late 90’s), I hadn’t actually played with a Raspberry Pi yet. Sure I’d read all about the board on Slashdot and the like, but it was just one of those things I never quite got around to using. So I was starting out as a newbie with a new Raspberry Pi 2.0 board and this sensors board, but it was actually really straight forward to use.
Following the user guide, I popped in a 4GB SD card into my laptop, and used ‘dd’ in Linux to copy the out-of-the-box image file (.img) to it.
sudo dd bs=4M if=sensor_board_1128.img of=/dev/sdd
Make sure the device (/dev/sdd) is correct for your SD card, and you run this command in the same directory as the .img file is located. It takes a while to do the copy, just be patient. Once it's done, plug the SD card into the Raspberry Pi.
You could also use Windows to do the copy if you don't have access to a Linux computer.
It’s at this point I realized my monitor doesn’t have an HDMI input, so I needed to find a DVI->HDMI cable. Luckily I already had one laying around, but just keep that requirement in mind. Otherwise I could have used my TV which uses HDMI. Then I plugged in a keyboard into the USB port, and connected the RPi to power via dual-headed USB, and suddenly there were colors and Linux bootup text scrolling by on the monitor. Success! At the prompt the username is “pi” and the password is “raspberry”
Trying it out:
Then came trying out the demo programs. There are three available to test out each of the three sensors. After changing to the sensor demo directory ("cd ~/rpi_sensor_board”), there's several Python scripts to run.
(Tip: you can hit the Tab key to complete a file name, so for instance you just have to type “sudo python mag” and then hit Tab, and Linux will fill in the rest for mag3110.py)
First up, the magnetometer:
“sudo python mag3110.py”
You can see the magnetic values change as you rotate the board. I will say it’s a bit difficult to spin it around the whole 360 degrees due to all the cables attached, but it conveys the idea even if only twisting it slightly.
Ctrl+C gets you back to the prompt
Then the altimeter and temperature sensor:
“sudo python mpl3115a2.py”
Try touching the sensor to see the temperature rise
And finally the accelerometer:
"sudo python mma8491q.py"
Tilt and shake the board around
All straight forward. In the much longer and more detailed user manual there’s some steps to run a web server and instructions on how to add support for the board in the default Raspbian OS, so I’ll explore those later. I also want to try getting it to work with my FRDM-KL26Z board.
All in all it’s a fun little board with a lot of possibilities, particularly since it's hardware compatible with a lot of different boards, and opens up a lot of possibilities for the Pi.
Top Comments