Errors once code has been saved onto ESP8266 #6043
Replies: 1 comment
-
Posted at 2018-07-30 by @allObjects While you upload the code, some initializations happen which do not when you run the saved state after those. Try to put the 'connects` into an
If you now 'just' upload, nothing happens... To get it running, enter When the code works as you expect, upload again, and then enter Posted at 2018-07-30 by Hapseleg Ah I see, everything works now as it should. Thank you very much! Do you recommend I always use onInit when I want to save code? Posted at 2018-07-30 by @allObjects Yes, my personal recommendation. The @gfwilliams made lots of strides to make things easy and worry free, but some is outside of control of Espruino system, because a module can do what it wants when connecting. Some modules get some states/values initialized which save on When designing the structure of my code, I separate the runtime/variable dependent things from the static/fixed things... and always run the runtime dependent things in the Also - to simplify development (not to have to enter after every upload
(@gfwilliams, I'm sure this line could be made conditional on some Espruino system info which indicates 'load an start of code' by a plain power up vs an upload on a connected and running Espruino. Which such distinction, the line would not have to be removed before final upload for save().) @Hapseleg, structuring code in your particular case would extract the (nested) anonymous functions into named functions (or methods of an object). This results in a flatter hierarchy - less levels - and allows to give names to 'things' and foster reuse. You already do it for storing 'configuration things', such as WIFI NAME and OPTIONS, as 'variabe' values. Same you can to for functions, such as for the function in Posted at 2018-07-30 by Hapseleg Thank you so much for the very thorough explanation and the great tips. People such as you are those who make communities great :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-07-29 by Hapseleg
Hi there, I am playing around with my DHT11 temperature sensor and my websocket server, I am using the Wemos d1 mini.
Here is my code:
Note: I have obviously hidden my wifi ssid, password and my IP in the code, just in case :)
If I upload this to the Wemos it will work as it should, my websocket server is receiving the messages and will display the temperature and the humidity every 10 second the message is sent.
But then once i save() this code onto the Wemos and reboot it, it starts showing this message every 10 second:
What causes this problem? Seems like it has to do with the wifi module?
I have tried restarting the server and also the Wemos but the problem persists.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions