Making, testing and debugging (pt. 1)
Let’s check the device first. I had to wire the accelerometer, the Zigbee Module and the battery to the Arduino Fio. Let’s look at some schematics made using the nice open-source tool named Fritzing.
How to program the Arduino Fio?
At first, you have to know the Arduino Fio has (also) been designed to be programmed wirelessly via the XBee module. It is really interesting but we also have to understand how we can program it wired to our computer, which is the most usual case. Arduino Fio USB connector cannot be used to program it. I guess you are now totally frightened by this, but of course, we have another way of programming it: our precious FTDI break out adapter.
Let’s see how the connection goes.
Arduino Fio’s back shows 6 pins grouped under the name FTDI. Basically, our small FTDI breakout is a USB to RS232 serial interface. It means we have to connect the FTDI board to the Arduino Fio and then connect th FTDI board to our computer with an USB cable in order to be able to program the Arduino Fio via the Arduino IDE.
I used to make this without soldering the header pins on the Fio side in order to save place if I have to put in small boxes. Check the FTDI board orientation: Gnd is the first connector at the top on the Fio side: don’t make a mistake here.
Choose the Arduino Fio in your board list in the IDE, then choose the FTDI board listed under the name /dev/tty.usbserial-A601EPM3 on OSX
Now, the basic workflow is still the same as in the first article of this series. You can code, and upload your code into Arduino Fio. Let’s next check the Accelerometer part.
Wiring and handling the accelerometer
ADXL345 accelerometer supports 2 differents serial communication protocol:
I used I2C and ADXL345 nice library: https://code.google.com/p/adxl345driver/. You can find a lot of explanation about serial communications in my book.
The accelerometer in this project is used for two purposes:
- detect a big movement (not a precise gesture) and trigger a message to the computer via Xbee modules
- detect activity and inactivity state in order to make the Arduino Fio sleeping a bit when no one holds the device
I inspired myself from the project of bildr.org here: http://bildr.org/2011/03/adxl345-arduino/
I modified some parts as you’ll see later in this article.
Let’s see the wiring of the accelerometer using I2C 2-wires circuit.
ADXL345 accelerometer wired to the Arduino Fio
I decided to solder my accelerometer to a small board in order to be able to wire it to the Arduino more freely.
Here are some pictures about that:
small soldering setup compared to protodeck project ;)
Useful small boards with connector connected 3 by 3 on rows
ADXL345 Accelerometer on which I soldered a small header
The ADXL345 soldered on the small board
Prepared 5 wires for ADXL345 soldering to Arduino Fio
ADXL345 wired to the Arduino Fio
The use of flexible a bit too long wires is adviced here. Indeed, I didn’t know precisely at this moment how I could wire the whole stuff in the box.. so having some length spare could help. This is a little tip: I knew I needed only 4 wires, the CS pin of the accelerometer being wired to the VCC one, but I prepared 5. Indeed, while wiring/soldering, if something goes wrong on a wire, you can use a spare one.