Hi,
i just want to send a Jeenode to deep sleep and when ever and Interupt on Pin 3 comes in I want the Jeenode to send a Message.
I just wrote this sketch but the Jeenode doesnt comes up from sleep. So how can i get the Jeenode back from sleep when an Interrupt comes??
Thanks a lot.
Cu kami
typedef struct {
#include
static byte radioIsOn,testval = 1;
static void wakeupToSend (const void ptr, byte len) {
char sending = rf12easySend(ptr, len);
unsigned int device;
unsigned int error;
unsigned int lobat;
unsigned int status1;
} lowbatterystruct; if (sending) {
// make sure the radio is on again
if (!radioIsOn)
rf12sleep(-1); // turn the radio back on
radioIsOn = 1;
}
}
void setup()
{
Serial.begin(57600);
Serial.print("Logger;
attachInterrupt(1, domessage,FALLING);
rf12initialize(8, RF12868MHZ, 5);
rf12easyInit(0);
}
void loop()
{
if (radioIsOn && rf12easyPoll() == 0 ) {
Serial.println("SEND"); Serial.print("Getdown");
rf12sleep(0); // turn the radio off
radioIsOn = 0;
Sleepy::powerDown();
}
}
void domessage()
{
static unsigned long lastinterrupttime = 0;
unsigned long interrupttime = millis();
Serial.print("On:");
if (interrupttime - lastinterrupttime > 200)
{
if (testval==1) testval=0; else testval=1;
lowbatterystruct msgfile;
msgfile.device = LOGGERNUM;
msgfile.error = 344;
msgfile.lobat = rf12lowbat();
msgfile.status1 = testval;
}
lastinterrupttime = interrupttime;
}
wakeupToSend(&msgfile, sizeof msgfile);
