-
• #2
Upload the code in the ide.
Then on the left hand side:save();
You want want to read up on the
E.onInit( function() {});
If there is code you want to do on start up.
-
• #3
Regarding starting of your code on power-up, add to you code (in the IDE editor / right page) either
function onInit() { ... }
or
E.on("init", function(){ ... });
and then upload the code and finally issue a
save();
command in the console (left pane in IDE). For more details, see reference E on event and onInit().Personally, I prefer the single
function onInti(){ ... }
, because at development time, I just can either add as very last line in the code for invocationonInit();
which invokes it automatically on (after) every upload, or invoke it manually by enteringonInit();
in the console.Furthermore,
E.on("init", function(){ ... });
has major restriction, because sequence is not fully controllable nor the timing:- If initialization code has to run in a certain sequence - different from loading or appearance sequence of a module (which would contain
E.on("init",...);
to init itself but with dependencies on other modules), initialization may happen with wrong settings. - If initialization is asynchronous / callback oriented (next initialization is required to wait until callback is issued), initialization may happen too early.
To handle configuration, initialization (w/ sequencing/callbacks), and later sequencing / callbacks, I created a gCtl (globalController), with more about the global controller vs. E.on("init",...) and a [Tasker (kind of a Promise] with built-in retry options)[http://forum.espruino.com/conversations/261352/].
- If initialization code has to run in a certain sequence - different from loading or appearance sequence of a module (which would contain
-
• #4
As the others have said,
save()
is the key here.Best to read through the steps on the Quick Start - I know they don't all apply to ESP8266 (there's no 'LED' constant built in) but it doesn't take long and would answer a lot of questions you might have.
-
• #5
Thank you, everyone!
-
• #6
BTW, I have since learned, that wifi also has a save, which is smartly independent of the generic save. I recommend to readers to know uses of both:
wifi.save()
wifi.restore()reset()
save()
Sorry if I missed instruction/step, but it seems that I have to re-upload my code everytime the ESP8266 is rebooted. Am I missing a step to "flash" the code on top of the firmware?