I’ve got my first Jeenode up and running (after a rather disastrous soldering mistake which may have left the radio module toast) – and I am having a strange problem with some of the code.
This code is rather different from some of the Arduino code I have written and used so far, as one of the main aims is to use as little power as possible, to enable the Jeenode to run on a set of batteries.
And here is the problematic code :
static byte periodicSleep (word msecs) {
// switch to idle mode while waiting for the next event
lowPower(SLEEP_MODE_IDLE);
// keep the easy tranmission mechanism going
if (radioIsOn && rf12_easyPoll() == 0) {
rf12_sleep(0); // turn the radio off
radioIsOn = 0;
}
// if we will wait for quite some time, go into total power down mode
// Serial.println(“ready for if radioison”);
if (!radioIsOn) {
// Serial.println(“Radio is not on”);
// see http://news.jeelabs.org/2009/12/18/battery-life-estimation/
if (loseSomeTime(sleepTimer.remaining()))
Serial.println(“ready for sleeptimer.set”);
sleepTimer.set(1); // really did a power down, trigger right now
}
// return true if the time has come to do something meaningful
Serial.println(“ready for sleeptimer.poll”);
return sleepTimer.poll(msecs);
}
where you can see the debug code I inserted to try to find the problem where the code never returned from the call to “periodicSleep”. Strangely enough the code suddenly starts to work when I enable the last debug line (return sleepTimer.poll(msecs);) – so more investigations to come.