Case for deep sleep mode, sample code

Everything about programming the platform and using the Waspmote API
Post Reply
JessieP
Posts: 90
Joined: Fri May 27, 2016 2:39 pm

Case for deep sleep mode, sample code

Post by JessieP » Tue Nov 07, 2017 10:59 pm

We have a smart water mote with DO, TEMP, Conductivity, ORP and pH. It needs to send readings every 15 minutes. As coded it is consuming more battery power than can be recharged so I need to understand how to consume less battery. I have three questions

1. I see there is Sleep Mode and Deep Sleep Mode. It seems for Sleep mode the longest duration is 8 seconds, is that correct?

From Sample Code
USB.println(F("enter sleep"));

// Go to sleep disconnecting all the switches and modules
// After 8 seconds, Waspmote wakes up thanks to internal watchdog
/* Other possible values are:
* WTD_16MS: 16ms
* WTD_32MS: 32ms
* WTD_64MS: 64ms
* WTD_128MS: 128ms
* WTD_250MS: 250ms
* WTD_500MS: 500ms
* WTD_1S: 1s
* WTD_2S: 2s
* WTD_4S: 4s
* WTD_8S: 8s
*/
PWR.sleep(WTD_8S, ALL_OFF);

2. For Deep Sleep mode, in the example code - why are you manually setting the time? Is this just to seed some counter. Is this necessary
from sample code

void setup()
{
USB.ON();
USB.println(F("PWR_2 example"));

// Init RTC
RTC.ON();

// Setting time [yy:mm:dd:dow:hh:mm:ss]
RTC.setTime("12:07:17:02:17:25:00");

}

3. I have moved the sample code into our main application code, and the mote does go to sleep and awaken. But subsequent calls to read values from the sensors fail. Do I need to reset the calibration points? It would be really helpful to have sample code that shows what needs to be done to the sensor's in the code before and after Deep Sleep mode.

void loop()
{
USB.println(F("enter deep sleep"));

// Go to sleep disconnecting all the switches and modules
// After 10 seconds, Waspmote wakes up thanks to the RTC Alarm
PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);

USB.ON();
USB.println(F("\nwake up"));

// After wake up I check intFlag and blink LEDs
if( intFlag & RTC_INT )
{
USB.println(F("---------------------"));
USB.println(F("RTC INT captured"));
USB.println(F("---------------------"));
Utils.blinkLEDs(300);
Utils.blinkLEDs(300);
Utils.blinkLEDs(300);
intFlag &= ~(RTC_INT);
}

}

Thanks
Jess

JessieP
Posts: 90
Joined: Fri May 27, 2016 2:39 pm

Re: Case for deep sleep mode, sample code

Post by JessieP » Wed Nov 08, 2017 1:54 am

looks like I was missing this after the wakeup

SensorSW.ON();

Do I also need to call

USB.ON();
xbee900.ON();

thanks
Jess

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Case for deep sleep mode, sample code

Post by libelium-dev » Wed Nov 08, 2017 1:04 pm

Hi Jess,

Yes, for sleep() function the longest duration is 8 seconds, although you could program a loop with this function inside in order to wait more time. Anyway we think deepSleep() is a better option.

It isn't necessary to set the time before deepSleep() function but if you program deepSleep() with RTC_ABSOLUTE mode, the node waits up to the time you set.

deepSleep() function with ALL_OFF option turns the sensor board and communication modules OFF, so you should turn the modules and sensor board ON again.

You can find more information in the following guides
http://www.libelium.com/downloads/docum ... _guide.pdf
http://www.libelium.com/downloads/docum ... _guide.pdf

Regards

JessieP
Posts: 90
Joined: Fri May 27, 2016 2:39 pm

Re: Case for deep sleep mode, sample code

Post by JessieP » Wed Nov 08, 2017 9:55 pm

This seems to be working, it's taking a while for the battery to charge up but at least we are going in the right direction now.
Thanks
Jess

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Case for deep sleep mode, sample code

Post by libelium-dev » Thu Nov 09, 2017 11:27 am

Don't hesitate to ask if you have any doubt! :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest