Load program after reset or power-on ESP-8266 12f

Posted on
  • Hi,

    please help me with loading espruino code from flash after reset() or power-on device esp8266 12f.

    My device has espruino ver. 1.89 and I need start http server after reset() or power-on.

    I try onInit() func, E.on('init', ... and E.setBootCode function, but without success.

    I know that esp8266 not full supported board for espruino, but is chance load code ?

    Lot of thanks for answears.

    Jakub

  • Are you trying something like this ?

    I don't know how onInit() works.

  • Hi @jakub.frydrych

    o setup wifi as station connected your access point (only once)

    var Wifi = require("Wifi");
    Wifi.connect( "your SSSID",{password:"your password"}, function(err) {
        if (err) {
            console.log("error connecting to your SSID:",err);
        }
        else {
            Wifi.stopAP();
            Wifi.setConfig({powersave : "none"});  // optional    
            Wifi.save();  // this saves all your Wifi settings
            console.log("Wifi.getIP:", Wifi.getIP());
         }
    }
    
    

    o write code you want to be started on boot='init' and upload

    E.on('init', function() {
    	  // add your code here
    	  ......
    });
    
    

    o after your code is completely uploaded run save, this will save, restart and run your code

    
    save();
    
    
  • Hi, thaks for answear.

    I test this tip and after restart device ( use func reset() ), device not loaded code from init function. What I do wrong ?

    Testing code for init func :

    E.on('init', function() {
          console.log("Device started");
    });
    

    And console output, after save(); code correctly loaded, but after reset() not load code from init function. If I call load() func after reset, code correctly run.

    Connected
    >
    >
    =undefined
    Wifi.getIP: {
      "ip": "10.0.0.42",
      "netmask": "255.255.255.0",
      "gw": "10.0.0.138",
      "mac": "5c:cf:7f:24:77:e4"
     }
    >
    =undefined
    >
    =undefined
    Erasing Flash.....
    Writing....
    Compressed 27200 bytes to 2026
    Checking...
    DDevice started
    >reset();
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v89 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
    > 
    
  • So it works as designed.

    A reset() is not a boot, it is a soft reset that clears code.

    A boot is when pressing reset button or call require("ESP8266").reboot

  • Many thanks,

    I did not understand reset() func and take this func as restart device with boot.

    Now is after reboot or power-on code loaded from memory.

    Thanks for explanation and your time.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Load program after reset or power-on ESP-8266 12f

Posted by Avatar for jakub.frydrych @jakub.frydrych

Actions