Last month we looked at using Arduinos to monitor bathroom usage at thoughtbot so employees could check bathroom availability at their desks. After we had a working prototype, power consumption was too high resulting in only a day of usage. It was also very expensive to reproduce if we wanted to expand our sensor network.
Lower Power, Higher Savings
The biggest power sucker was the XBee radio. It was always on and drawing about 50mA of current. The XBee Series 2 offers a bit more power savings when on and also has a more robust interface that allows us to put it in sleep mode. However, it still has a steep price. The better option is the nRF24l01+ series from Nortic. They are very inexpensive on Amazon.com, have an SDK for the Arduino, sleep mode capability, and gives us automatic transmission packet assemble, detection, validation, retransmission, and acknowledgement.
When using the nRF24l01+ board in conjunction with the Arduino Fio, there was large jump in power savings. Current consumption for the entire sensor board was down to around 5mA. This would yield about 80 hours of use on a 400mAh battery. That’s only about 3 days until it would need to be recharged again. Still not so great. The final chunk of power sucking was being caused by the LED that comes on every Arduino to indicate power-on. Removing the LEDs and potentially destroying an expensive board didn’t sound appealing. The best option was to design a custom Arduino board that would fit our use case instead of trying to mash together pre-made general purpose boards.
Introducing the thoughtbot Arduino Sensor Board
The custom Arduino board will have no LEDs for power savings. To keep it similar to other Arduino boards, it will use the ATMega328P 8-bit microcontroller and have the same pinouts on the connectors. It will have a connector for the nRF24 board for easily making it wireless. Finally, it will support LiPo rechargeable batteries and coin cell batteries.
Designing the Board
We used the free version of Eagle for the schematic capture and PCB layout. You can access the eagle files, Gerber files, and bill of materials in the repository.
Here is the schematic:
Here is the PCB layout:
Assemble Your Own
We used OSHPark to fabricate the boards. They are inexpensive and relatively quick. We had our boards in less than 2 weeks. To make your own, upload the Gerber files to OSHPark. While you’re waiting for the boards to arrive, place an order with DigiKey for the components. The list of components is also on the repository: BOM. You will also need a few other things to program the Arduino that you could order while you waiting. Read the Programming section for specifics.
Soldering it Together
To solder together the board, you’ll need a few tools:
- A decent soldering iron with a fine point tip and a variable temperature control. We used this one from the local Radio Shack.
- A slightly damp sponge or tip cleaner to wipe the hot iron on.
- Thin solder, we used .022" diameter solder, but the non lead-free version.
- Thin tweezers for placing small components.
- A Flux pen makes soldering easier.
- Copper braid for fixing mistakes.
Start with U1, the microcontroller. It will be the hardest to solder so make it easy on yourself and do it before there are other parts in the way. Align the chip so pin 1 is in the correct spot and that all the pins are centered on their pads. Use some tape to hold it in place. Next, apply flux to one side of pins. Then, touch the solder to the hot iron just to get a little bit on the tip of the iron. Then, place the tip of the iron on each pad and you will see the flux-soaked metal pull the solder over it. Move down the pins, touching each one until you see the solder flow over it. Touch the solder to the iron again if more is needed. Once you have one side of the microcontroller done, remove the tape and finish the other sides.
We used a volt meter to test the pins and make sure they were connected to the pads by testing that the resistance between the pin on the chip and a pad it connects to somewhere else on the board was 0. If you don’t have a volt meter a visual inspection will be sufficient. If 2 pins were accidentally connected by too much solder, try to add flux again and re-apply the iron. If that doesn’t work, soak up some of the solder using the copper braid. Apply flux, then put the copper braid on top of the solder and push down on the braid with the soldering iron. Make sure to hold the plastic case of the braid and that there is enough braid between the case and the soldering iron or you could melt the case. You should see the copper braid absorb the solder and turn tin colored. Remove the braid when you’ve soaked up enough and re-touch the pins with solder as needed.
Next, solder the other tough components, U2 and JP9 (the USB connector). Move onto the small components, capacitors and resistors, and take on the biggest stuff last, the connectors. When soldering the other small components, tape can be impractical, so try putting solder on one pad first then, using the tweezers, slide the component in while heating the pad with the soldering iron. Then solder the other side.
Take care when soldering the LED and the capacitor C1. Both of these components have to be soldered in a certain orientation. C1 pad should have a white line closer to one pad and there should be a white line on one end of the part. Make sure these lines are aligned. The LED should have a line and a dot on the bottom of the part. The line should face toward power. The green line is somewhat visible in this image:
Once you’re all done it should look similar to this:
To use the board as an Arduino, you’ll have to upload the Arduino bootloader onto the chip. You can do this with this programmer from Sparkfun. Plug it into J1 so that the cable goes over the chip. If you’re not sure, check the pin mappings. It should look similar to this image:
Plug the USB cable from the programmer
into your computer and burn the bootloader to the chip from the Arduino
software. If you’re having trouble making your computer recognize the
programmer, look around the internet as there is a lot of support out there.
Open the Arduino software, at this time the latest version is 1.0.5. In the
Arduino Uno. Then,
Burn Bootloader. After a bit of time the
board should be programmed with the Arduino bootloader.
Now you have a fully functional Arduino board. To save space and cost on the board, we left out the FTDI USB to Serial chip. The Arduino software uses USB to Serial to program the devices. You can purchase one from Sparkfun or Amazon.com. The way the board was designed, you need to plug the FTDI board in upside down. If the board is not plugged in correctly the power pins will be misaligned and you’ll risk damaging the processor.
To make sure everything works, plug in the FTDI board to you computer and open
Blink example from the Arduino software. Make sure the Arduino Uno is
selected as your board and the correct serial port is selected in the
menu. Upload the program. Connect and LED in series with a resistor (330 ohms to
1K) between ground (GND pin) and pin D13. Make sure the cathode of the LED is
facing toward ground. The LED should blink in 1 second intervals.
Your Arduino is ready to go! Have fun creating anything your mind can imagine! Next time we’ll look at rewriting the software for the bathroom occupancy detector and creating a sensor network using this custom Arduino board and the nRF24 transceiver.