Deep Sleep/Function questions


I have a few questions which I can’t seem to figure out from reading the document. Firstly I have 3 variables which I am reading and I would like to return them in one API call. However I can’t seem to figure out how. The variable list function only returns their type and functions can only return ints.

Secondly I would like to put my core into a deep sleep for 29 mins after it has received a ping, is this possible? My web app only requests data every 30 mins.

Any help would be great.

Hi dtsn,
My approach to returning multiple variables is to have a STRING variable, in which I pack everything I want to return.
I have a function in my loop which updates this STRING variable with some frequency so that it is always up-to-date.
I also pack everything into my string in JSON format so it is easy to parse, but this is certainly not required. will show you about the deep sleep mode.

// EXAMPLE USAGE: Put the Core into deep sleep for 60 seconds
// The Core LED will shut off during deep sleep

Happy Hacking!

Thanks for the string idea.

However regarding the sleep. If i put it directly into my loop function, the core will read then immediately go to sleep.

I would like it to go to sleep only after i’ve made an API request to it, so that the timing for the sleeps works with my server side code (otherwise they are out of sync).

So instead of putting it in your loop, put it at the end of your function.

So you have

String myStatusString;

setup() {
loop() {

readNotifyFunction() {

Then, on your client program (or web app, whatever it is) you first call the variable read
then after that is complete, make a call to the readNotify function
which will put it to sleep for 29 minutes after which it will loop, keeping the string variable up to date and waiting for you to call it and put it back to sleep.