Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use loop() to receive MQTT callback reliably #7

Open
fakenius opened this issue Nov 11, 2020 · 0 comments
Open

Use loop() to receive MQTT callback reliably #7

fakenius opened this issue Nov 11, 2020 · 0 comments

Comments

@fakenius
Copy link

Super Projekt. Lief bei mir dank toller Anleitung auf Anhieb. Vielen Dank.

Lediglich der MQTT callback kam so gut wie nie an. Mein Broker ist wohl zu langsam. Ich habe daher die Abfrage in die loop() verfrachtet. Die boolesche Variable callback_done wird entsprechend in callback() gesetzt. Die Integer-Variable max_runtime enthält die Millisekunden bis zum Timeout.
Jetzt geht's problemlos.

void loop()
{
  mqttClient.loop();

  // looping until MQTT callback has been received or timeout is reached
  if ( callback_done || millis() > max_runtime ) {

    // deep sleep now
    WiFi.disconnect( true );
    delay( 100 );
    ESP.deepSleep(Minuten * DS_Intervall, WAKE_RF_DISABLED);  
    delay( 100 );
    
  }
}
@fakenius fakenius changed the title Use loop() to receive MQTT callback reliable Use loop() to receive MQTT callback reliably Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant