Using feed save() and deepsleep problem

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
tubos
 
Posts: 14
Joined: Sun Feb 02, 2020 5:05 am

Using feed save() and deepsleep problem

Post by tubos »

1) In the code when going to sleep after the Temp-save() no data is received at my feed in adafruitIO
When i add a delay (see **1) before i go to deepsleep the values are received.
Is this normal? or is there a better alternative?
See code below
2) is io.run() required if i just send data to adafruit.IO ?

Code: Select all

void loop() {

  io.run(); // Required at top of the loop to process incoming data

  Serial.print("sending -> ");
  int rndtemp = random(255);
  Serial.println(rndtemp);
  if(!Temp->save(rndtemp)) { // Send value to feed
    Serial.println("failed to send value");  
  }
  delay(500); // **1 
  Serial.println("Going to deepsleep");
  ESP.deepSleep(15e6);

}

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Using feed save() and deepsleep problem

Post by brubell »

You'll want to place io.run() at the bottom of the loop, after the device sends data to adafruit io. Take a look at our deep sleep example - https://github.com/adafruit/Adafruit_IO ... psleep.ino

User avatar
tubos
 
Posts: 14
Joined: Sun Feb 02, 2020 5:05 am

Re: Using feed save() and deepsleep problem

Post by tubos »

Thank you good tip , it works great now.

I was confused by the comment in the publish example :
// io.run(); is required for all sketches.
// it should always be present at the top of your loop

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Using feed save() and deepsleep problem

Post by brubell »

fantastic!

User avatar
alexbrugh
 
Posts: 1
Joined: Sat Apr 03, 2021 4:54 pm

Re: Using feed save() and deepsleep problem

Post by alexbrugh »

Thank you for the delay 500 suggestion. fixed my post-ssl-removal issue as well.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”