Last June, I wrote about a sensor board from element14 that is Freedom-compatible with Freedom development boards (See the new board from element14 that features Xtrinsic sensors). That board was compatible with Arduino R3-compatible boards, including the Freedom hardware. element14 has since updated their MEMS sensor evaluation board design such that the new version is compatible with both Freedom AND Raspberry Pi model B boards and platforms. I was unfamiliar with Raspberry Pi, so element14 sent me a couple so I could try out their new board. They also sent 8GB SD cards pre-installed with New Out of Box Software (NOOBS), which gives you a choice of several popular operating systems for the Pi. I set aside a morning earlier this week to take the two boards for a test drive.
Figure 1: Revision B of the Raspberry Pi (photo courtesy of Wikipedia)
The Raspberry Pi is a self contained computer designed for educational use. Starting at the upper right corner in the figure above, we have:
An SD card slot is on the opposite side of the board.
The sensor board itself is shown below. Key components (circled) are MAG3110 magnetometer, MPL3115 pressure sensor/altimeter and MMA8491 accelerometer. The board plugs into the expansion header on the Pi.
Figure 2: element14 MEMS Sensors Evaluation Board (photo courtesy of element14)
The user guide refers to a custom Pi image for use with the sensor board. Since my boards came supplied with 8GB NOOBS SD cards, I went ahead and folliowed the standard startup sequence as shown in the 1st video.
Plug your sensor board into the Raspberry Pi expansion port. Connect peripherals and then power via micro-USB. Make sure you connect peripherals before power. The Pi has no on-off switch. You are going to need USB mouse and keyboard, micro-USB power adapter, HDMI monitor (there’s also a standard video output), and (if you want to try the web server demos) ethernet cable.
Figure 3: Board Stackup (photo courtesy of element14)
When you apply power the first time, you will be offered a selection of operating systems. I chose the Raspbian OS, an embedded Linux, and “boot to desktop”. That initial startup takes about ten minutes, and when you are done, you should see a standard desktop with a colorful raspberry in the center. I should note that I had to “sudo raspi_config” a number of times from a command window until I found a keyboard configuration that worked correctly with my hardware.
At this point, you have a live Raspberry Pi, but still no access to the sensors. Consult Anthony H.’s second blog to enable the I2C expansion port and download example scripts for accessing sensors. Anthony uses a text editor called “nano” to update configuration files. I used the “vi” editor, which is also available.
If you follow instructions, scripts will be located in ~/rpi_sensor_board. There’s one each to pull streaming data from the MMA8491, MAG3110 and MPL3115. These can be run at this point in the process. The sensor_website.py script will NOT run yet. For this, you need to install PHP and nginx web server first. Details are in the sensor board user manual, but curiously they occur after the web server demo is first presented. Make sure you read ahead before trying sensor_website.py. Run the “ifconfig” command from a command window to determine the IP address of your Pi (it shows up in the 2nd line of the command result as “inet addr:”.
When you finally do run sensor_website.py, you will be given a choice of 1 of 3 different web pages to be continuously updated (one for each fo the sensors). You can then access that page from a web browser on any other device on your network. A screen dump of the compass display is shown in Figure 4.