Until this week.
After jumping several hurdles, I now have a portable temperature-texter, which has been sensing and texting to Twitter for two days now.
Once I got the sensor and the cellular board to play nicely together, I set them to sense and text every 10 minutes. It worked, but the lithium-ion battery would die overnight. Sadness.
The trick, I knew, was getting the Fona and the Arduino to sleep between texts, saving the battery.
By crazy coincidence, Don Blair had been playing with essentially the same parts when I visited him at MIT recently. He found code that manages the sleep-cycles nicely, written by Jean-Claude Wippler, aka JeeLabs. The sources to check out are here:
- Great blog post explaining the low-power trick
- The wiki and install instructions
- The actual sleep functions
Then I found some nice code to power down (and up) the Fona by Kina Smith.
So the programming plan went like this:
- Take a temperature reading
- Use the data to compose a text message
- Turn the Fona board on
- Send the text
- Turn the Fona board off
- Sleep the Arduino for 20 minutes
- Wake up the Arduino
Two days later, the battery reading from the Fona (if it is to be believed) is one percentage point lower than it was 48 hours ago. And it’s still texting.
Here’s how I wired it up:
The Fritzing diagram is a little unclear on the pins for the two boards, so here’s what’s connected, in English:
- Arduino pin 2 to Fona RX
- Arduino pin 3 to Fona TX
- Arduino pin 4 to Fona Rst
- Arduino pin 5 to the data pin of the temperature sensor
- Arduino pin 6 to Fona Key
- Arduino pin 7 to Fona PS
- Arduino VCC to the red rail on the Fona breadboard (this is “clean” power, at 3.3 volts)
- Fona Vio also to the red rail on the Fona breadboard
- Arduino Gnd to the black rail on the Fona breadboard
- Fona Gnd to the black rail on the Fona breadboard
- Temp sensor ground to the black rail on the Fona breadboard
- Temp sensor power to the red rail on the Fona breadboard
- 10K-ohm resistor from temp sensor data pin to VCC / red rail on Fona breadboard
- Lithium-ion 3.7-volt battery connected to the red and black rails on the Arduino breadboard (this is the “raw” power)
- Fona JST power and ground connected to the red (power) and black (ground) rails on the Arduino breadboard
- Arduino ground connected to the black rail of the Arudino breadboard
In my wiring, the red rail on the Arduino’s breadboard carries the “raw” 3.7-volt power from the battery, while the red rail on the Fona’s breadboard carries “clean” 3.3-volt power from the Arduino, which has passed through the Arduino’s voltage regulator.
Also, for those paying attention to such details, the temperature sensor in the photo is reversed from one in the drawing.
I’d like to:
- Make it smaller
- Fit it into an Altoids box
- Text data to a spreadsheet via a node server
- Make it look less like a … er, less dangerous to passers-by