Arduino Wireless Accelerometer Shield Tutorial

The finished article

The finished article

I think perhaps the word “tutorial” is a rather grand title for what follows, but it’s my first attempt, either at making something like this, or at sharing my exploits.

So I bought a couple of 3-axis accelerometers for cheap cheap and had them wired up to the Arduino, trying to get them working, when it occurred: wouldn’t it be nice if there weren’t a pile of wires trailing everywhere, if it was easy to plug and unplug, and if it could even communicate wirelessly with a PC? Luckily I’m not the first person to think this, and someone cleverly invented the concept of a shield. As far as I can gather no-one sells an accelerometer shield, and anyway, where’s the fun in buying one?

The parts I used consisting of: blank Arduino protoshield, stackable headers, MMA7361 accelerometer on breakout board, a cheap Bluetooth module, an LED, a couple of resitors and a couple of push switches.

The parts I used consisting of: blank Arduino protoshield, stackable headers, a right-angled female header,MMA7361 accelerometer on breakout board, a cheap Bluetooth module, an LED, a couple of resitors and a couple of push switches.

I was happy for the accelerometer to be soldered to the board, having it sit in a female header would have made the board too high to stack. I did want the BT module to be removable though so that’s where the right-angled header would come in. The first step was to have a think about where best to put everything, including having the various pins in convenient places to wire to each other without it turning into a dog’s breakfast (well at least not too much of one). This done I plugged the MMA7361 into the board and heated up the iron.

My chosen location and orientation for the MMA7361

My chosen location and orientation for the MMA7361

MMA7631 PinsArduino Pins
X (X-axis output)A0 (analog input)
Y (Y-axis output)A1 (analog input)
Z (Z-axis output)A2 (analog input)
SL (sleep select)Pin 2 (digital output, keep this HIGH to keep it awake)
0G (zero-gravity detect)Not connected (used to test if e.g. a HDD has been dropped)
5V (power)5V (chip is 3.3V but the breakout board has a regulator and is happy with 5V)
3.3VAREF (used as a reference to make analog reads more accurate, can be left disconnected) NB: if using thus you must declare analogReference(EXTERNAL); before doing a digitalRead() or the Arduino can be damaged
GND (ground)GND (ground)
GS (g-select)Pin 3 (digital output, set LOW for 1.5g scale or HIGH for 6g. Defaults to 1.5 g)
ST (self test)Not connected
Time to start soldering those fiddly little wires on

Time to start soldering those fiddly little wires on

At this stage I soldered on the right-angled header for the Bluetooth module as I wanted to get a clear idea where the wires would end up.

Chosen position for Bluetooth socket

Chosen position for Bluetooth socket

Bluetooth Module PinsArduino Pins
KEYNot connected
VCC (power)5V (or 3.3V, power)
GND (ground)GND (ground)
TXD (transmit)Pin 0 (Rx, receive)
RXD (receive)Pin 1 (Tx, transmit)
STATENot connected
Next the switches and LED, the bottom one is a reset switch and plugs straight into the appropriate place on the protoshield. The other I want to use as a button to enter calibration mode. It’ll be attached to one of the Arduino inputs which I’ll pull high using its internal resistor. The switch is wired to ground so (hopefully)when the button is pressed the input will go low and the sketch will enter calibration mode until its pressed again. The LED will stay on to show this is happening.

The switches and LED in position

The switches and LED in position

Now just a case of wiring it all up. Easy on the poor soldering harassment please, I’m kind of new to this stuff. I’m sure there must have been a cleverer way to route all the wires but TBH I didn’t want to spend all afternoon thinking about it.

The finished wiring on the underside of the shield

The finished wiring on the underside of the shield

I chose to put the stackable headers in last and this was a good move, made it much easier to work on the wiring. The easiest way to make sure everything lines up when soldering stuff like this is to stick the pins in some holes, or vice versa, so I plugged another shield into the top of the headers whilst I did so. The Panavise makes it very easy to do this sort of thing and I’ll post a very brief review shortly.

Soldering the stackable headers with another shield plugged in to them to keep everything lined up

Soldering the stackable headers with another shield plugged in to them to keep everything lined up

And that was pretty much it. Plugged it in and amazingly it worked. I’ve managed to get a reading of g out of it and I want to write the calibration routine, I’ll post the code when its done.

All finished, I wonder if it works?

All finished, I wonder if it works?

What do you think? Any questions or suggestions, leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>