It’s not really a thread to discuss coding styles like the positioning of curly brackets and they can be discussed elsewhere on this site.
To keep the thread to a reasonable size I believe the expectation is that it will not be a thread for any discussion, simply a schedule of very useful sketches.
So if you have any questions about any of the sketches create a new thread in this category and provide a clear link to the actual sketch you wish to discuss.
I will kick it off with:
@Gunner in C++ Blynk - Code Examples for Basic Tasks (Work in Progress) you state the WeMos will not restart without a hard reset when it crashes with a WDT failure. Are you sure you are resetting the ESP after every local flash as this is required for ESP’s to be able to restart after a crash?
I have sketches that connect to 2 different routers that are tied to 2 different WISP’s. If one WISP goes down it will initially cause a WDT crash but it will automatically reboot and connect to the second WISP.
Thanks!! I don’t mind doing a little housekeeping here and there, but better to not have the guests trample around in the first place
I don’t think I did a reset at any time I know about the OTA issue, but wasn’t actually using that for flashing anyhow… but now I will have to retry with resets…
However, even without resetting after flash, I can repeatedly cause the crash by reflashing with the default v2 Prebuilt… but ONLY if there is NO WiFi signal available… if the WiFi is up, but the server is down, then no crash and it keeps running the sketch.
However with the v1.4 Prebuilt… everything keeps working regardless if loss of WiFi or just loss of the Server.
Oh? I use that in all my running projects… what issues need I look out for? And are they documented on the espressif site somewhere?
EDIT - OK, I found reference where some device’s local IP shows 0.0.0.0. I have seen that, but only on the one same device after a few hours/days or so… it hasn’t been critical as I don’t need to update it often… and can always just manually reset it, then do the OTA update. But interesting anyhow.
Some of them are described on the ESP8266 GitHub site.
There are discussions regarding what constitutes a valid hostname i.e. underscores are not officially supported by standard XXX but Espressif were using them without any problems until recently. It might depend which standard a specific router is using to validate hostnames.
void UpTime() {
Blynk.virtualWrite(V0, millis() / 1000); // Send UpTime seconds to App
Serial.print("UpTime: ");
Serial.println(millis() / 1000); // Send UpTime seconds to Serial
digitalWrite(DeviceLED, !digitalRead(DeviceLED)); // Blink onboard LED
}
Apart from the curly brackets , there’s a minor issue that after about 50 days this up-time counter will reset to zero because millis() is and unsigned long and will eventually overflow. It’s not a big deal, but it might be worth putting a note to this effect in the code to prevent the “Why is my device resetting every 50 days, this is a bug! I’m going to sue you all” type of comment.
For those with an obsession on timing accuracy you will glad to know that the millis() drift for ESP8266, that was reported in March 2017, should be fixed when ESP8266 Core 2.5.0 is released.
ESP8266 based clocks will then be approximately 2.2 s more accurate per annum.
No problem from me… as stated, I just clean up my topic when needed. Here however your comments against my massive cooding prowess will self destruct in about 50 days JK
I am just using the UpTime example from Blynk’s own examples… I don’t think I can possibly leave any device alone for that long to test without tinkering with some code But since millis() is being referenced directly and not assigned to anything, perhaps it simply loops to 0 and everything carries on?
That’s my understanding, it’s just that from a user perspective it will look like the device has reset because the up-time will be back to zero again. Hence the suggestion to add a comment about that in the code.
You’re certainly a better coder than me.
I think one of my problems is that I taught myself to program in BASIC then VB and the syntax doesn’t translate into C/C++ very well. All these curly bracelets and semi colons used to drive me mad, but I think they’re finally becoming second nature. I still struggle with == instead of = and ! Instead of <>, but fortunately I’ve got plenty of time on my hands to debug my mistakes
I think your code examples thread is a great idea and we’ll implemented. The Sketch Builder is great feature, but it it lacks a bit of appeal for some people, whereas the screenshots and videos help to bring the projects to life. Even if they’re not exactly what a user is looking for, they’re a great starting point and a learning tool for people who want to learn without begging for code.