Monday, March 05, 2012

Sunshine On My Arduino Makes Me Happy

Denizens of the Great State of Colorado like to boast that we have 300 days of sunshine per year. That's a little misleading: the Colorado Climate Center says that although the sun does indeed come out for at least an hour 300 days of the year in Colorado, only 115 days can really be said to be those classic clear sunny days.

But do we get enough sunshine to run an Arduino Uno board with an Xbee radio? There was only one way to find out.

I connected two six-volt solar panels (Radio Shack P/N 2770052) in series to get a voltage somewhere in the range of what the Arduino Uno would find acceptable, and connected the combination to an M-type coaxial DC power plug. I wrote a little Arduino code to just print a time stamp, loaded it into an Uno powered by its USB cable, and tested it. I asked one of the cats where the sunniest spot was right then; Petronius assured me that in the breakfast area near a flower pot was the place to be.

In the photograph below you can see the solar cells in series, the Arduino Uno, and a SparkFun XBee shield with an XBee Series 1 radio on top of it.

Solar Powered Andruino and XBee Radio

I had to position the solar panels just right to get enough juice to power both the Uno and the XBee radio. But with a little fiddling, all the right LEDs came on and started blinking. I went back to my office a floor above and pointed the Arduino IDE Serial Monitor tool at the XBee that was USB-attached to my Mac Mini. I was rewarded with this output from my Arduino program.

Screen Shot: Elapsed Time

Here's the simple little program that generates and prints a time stamp with approximately millisecond resolution. The Xbee shield is setup to route the serial output of the ATmega328P microcontroller over the wireless serial link between the two radios.

void setup() {
 Serial.begin(9600);
}

void loop() {
 unsigned long milliseconds = millis();
 unsigned int hours = milliseconds / 3600000UL;
 milliseconds %= 3600000UL;
 unsigned int minutes = milliseconds / 60000UL;
 milliseconds %= 60000UL;
 unsigned int seconds = milliseconds / 1000UL;
 milliseconds %= 1000UL;
 Serial.print(hours);
 Serial.print(':');
 if (minutes < 10) { Serial.print('0'); }
 Serial.print(minutes);
 Serial.print(':');
 if (seconds < 10) { Serial.print('0'); }
 Serial.print(seconds);
 Serial.print('.');
 if (milliseconds < 100) { Serial.print('0'); if (milliseconds < 10) { Serial.print('0'); } }
 Serial.println(milliseconds);
 delay(1000);
}

I continue to look at low-power automation and wireless networking and alternate power sources for my Amigo project. In the long run what I would really like is a combination solar/LiPo battery combination. But this was a useful first step.

Update (2012-03-12)

The one pair of six-volt panels in series proved a little weak for reliable operation. So I built a second identical fixture and connected the two fixtures in parallel to get more power. Here's what it looks like now.

Four Panel Solar Array

Update (2012-05-30)

Here's the next iteration of this project. Clockwise from top left: a 7A solar charge regulator, an Arduino Uno with an XBee shield, a 12V sealed lead-acid rechargeable "gel cell" battery, and a 12V 1.5W solar battery charger.

IMG_1506

I definitely went the cheap route on this new setup, the battery being the most expensive component. The idea is that the Arduino runs off the battery, which is charged by the solar panel. I'm experimenting now with seeing how long this can keep running, starting with a fully charged battery. The software on the Arduino wirelessly sends a heartbeat to my desktop, which logs it with a timestamp. The heartbeat message indicates how long the Arduino has been running since its last reset (which would happen if the power fails and later returns). The output is logged to a file so I can see what happens overnight. My guess is a (much) larger solar panel and maybe a better solar power controller would be necessary if this evolved beyond the experimental stage.

Update (2012-07-19)

I went to a larger 5W solar panel, then to much larger 15W solar panel. We'll see if that's enough to charge the 12V battery during the day and let the system run all night. I also had to go to Xbee Series 2 radios with external antennas on both the Arduino Uno with the Xbee shield, and on the Xbee Explorer that is USB connected to my desktop, in order to get the range I needed, which was just a few tens of yards from the south-western edge of my back yard to my home office on the south side of my house.

Here's the "instrument pod" with its external antenna visible at the lower left.

Instrument Pod: Cover Off

Here is the instrument pod in my back yard connected to the largish 15W solar panel.

Instrument Pod and 15W Solar Panel

Here is the tiny Xbee Explorer, with its own external antenna, USB attached to my desktop Mac.

Xbee Coordinator on Xbee Explorer

I'll monitor this for the next few days and see what happens.

No comments: