Newby question

Posted on
  • I have Espurino running on a Wemos D1 mini (finally)
    I have a question about the IDE
    After installing and configuring OTA connection the wifi setup seems to
    stay there even after I upload a new simple test program without any wifi
    connection commands

    So does this mean the OTA wifi connection is stored in a secret place
    that I cant see and I just add my extra bit ?
    What if I wanted to change the wifi configuration that is stored in the secret place?

  • Moving this to the ESP8266 forum

  • Yes, it auto connects once you've configured the wifi and saved it (see http://www.espruino.com/ESP8266_Flashing­ where they describe configuring the wifi, you save with wifi.save() ). Which is good, since you want it to come up in wifi mode so you can connect via telnet console

    It is stored in different place on the flash.

  • Thanks for the reply!
    My next question is when I put in a simple hello world http if I unplug the device then plug it in it doesn't seem to start the http and I have resend the code to make it work again I tried setting the communication setup to keep the code but then it shows an error when I try to load the code

  • @ghedo, pls take a look at this conversation, especially posts #8 and #18. They shed some light on what is going on when you upload code, save(), and re-power/power cycle your device.

  • hmm things get very complicated very quickly

    I tried

    var http = require("http");

    function onInit(){
    http.createServer(function (req, res) {
    res.writeHead(200);
    res.end("Hello World");
    }).listen(8080);

    }

    but didnt work :(

  • sorry just to be clear in the right hand side of IDE I put
    var http = require("http");

    function onInit(){
    http.createServer(function (req, res) {
    res.writeHead(200);
    res.end("Hello World");
    }).listen(8080);}
    onInit();

    then in left hand side I type
    save()
    then I repower the device and find doesnt work

  • To change the saved wifi settings you set the config up and the run wifi.save().
    Did you take a look at http://www.espruino.com/ESP8266_WifiUsag­e ?

  • Thats ok
    At the moment I feel the onInit() function is just not running on power up
    no matter what I do. if I power up then dump() the code is there but it just doesnt run on power up/reset.

  • Mhh, I haven't used onInit... looking...

  • I'm not sure what exactly is happening, but it may be that onInit() gets called before the networking code is fully initialized. The following will do what you're looking for:

    var http = require("http");
    
    function server() {
      http.createServer(function (req, res) {
        res.writeHead(200);
        res.end("Hello World");
      }).listen(8080);
    }
    
    function onInit() {
      Serial2.write("onInit\n");
      setTimeout(server, 1000);
    }
    

    The Serial2.write appears on uart1 (as opposed to the normal uart0) where the log messages are. You can remove that, I used it to see when onInit runs.

  • oh god it worked!
    So, need to wait a bit before starting it up.
    Thanks so much

  • You're welcome. It's not ideal and I should look into it, but at least it works...

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

Newby question

Posted by Avatar for ghendo @ghendo

Actions