#include //Local DNS Server used for redirecting all requests to the configuration portal #include //ESP8266 Core WiFi Library (you most likely already have this in your sketch) Also, since no safe mode, a manual delay has been added. It could probably be shorter, or instead count from when the delay stage first triggers, but it hasn’t been an issue so far, and just gave me enough time to hit the compile button, and power up the ESP8266 and gurantee it would ‘just work’ĮSP8266 Code // OneWire DS18S20, DS18B20, DS1822 Temperature ExampleĠ.70 - switch to ESP8266 core, WifiManager, ArduinoOTA.Ġ.60 - use DNS lookup then fall back to IP, plus extra parameter for updateThingspeak allowing field to be parameterisedĠ.50 - particle variable is now pushed (hence SYSTEM_MODE(SEMI_AUTOMATIC) mode)Ġ.40 - changed to DallasTemperature library, some code optimisations. And I tell a lie… it does use the loop, and instead uses a state machine to determine whether to get the sensor reading, idle until a total of 20 seconds uptime has elapsed to allow OTA to happen, or go into deepsleep. You just want it to be hanging around for long enough to hear espota sending it the message to start processing OTA…īelow is the code I currently have on a pair of ESP8266s (DigiStump Oak) that have been running well for the last several months… (and is overdue some tweaking as it’s a mismash of example code). As long as there is a delay of some description (even a delay(1)) the ESP will get the yield() call it needs to ensure it doesn’t lock up, as well as encouraging it to idle while not doing anything. # - Send command to controller to differ between flashing and transmitting SPIFFS image. # use it like: python3 espota.py -i -I -p -P -f # This script will push an OTA update to the ESP # Modified since from Matthew O'Gorman () I’m not sure why the timeout would configurable… as going by the espota.py script, it is hard coded for 10 seconds, and doesn’t have a ‘timeout’ option… quite strange! Maybe platformio is running it multiple times? esp8266/Arduino/blob/master/tools/espota.py?utm_source=platformio&utm_medium=docs #!/usr/bin/env python3 I’d probably be tempted to increase the lookup to at least 5 seconds, so 50… I’ll have a look at the code I did to do something similar… basically all in setup instead of loop. Is my look of 30x 100ms enough to catch the OTA (the while loop with ota handle() ). In platformio.ini " upload_flags = -timeout=20" it looks like the unit for this flag is 10sec ? curious, no? It does not always works and I wonder the following: So I launch an upload from atom and just wait… I do not have any “loop()” fonction, like most code with deepsleep, so I set a short loop at the end of my code, this way: mqtt.disconnect() ĪrduinoOTA.begin() // initialisation de l'OTA I added some OTA handling at the end of my code, before going back to sleep. I currently work on a weather sensor that spend most of its time in deepsleep, shortly wake up, measure and send data and goes back to deepsleep. I use atom+platformio to develop some software on ESP8266.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |