You are reading a single comment by @dwinfiel and its replies. Click here to read the full conversation.
  • @Robin,

    After flashing new firmware to the ESP32, disabling Bluetooth, saving my wifi settings using the following:

    var ssid = 'xxxx'; 
    var pswd = 'xxxx'; 
    var wifi = require('Wifi');
    wifi.stopAP();
    
    wifi.connect(ssid, {password: pswd},function(){
    //    console.log('Connected to Wifi.  IP address is:', wifi.getIP().ip);
        wifi.save(); // Next reboot will auto-connect
    });
    

    I get the following memory (after sending a ESP32.reboot):

    >process.memory();
    ={ free: 4021, usage: 79, total: 4100, history: 0,
      gc: 0, gctime: 3.2 }
    

    I found that my board does run the event wifi.on('disconnected',function()), at least sometimes. So I am trying the following code:

    var wifi = require('Wifi');
    var iwico = setInterval(wico,999999999);
    wifi.stopAP();
    
    wifi.on('disconnected',function(){
      //print("wifi disconnected");
      console.log('Wifi disconnected');
      clearInterval(iwico);
      iwico = setInterval(wico,1000*30);
      
    });
    
    wifi.on('connected',function(){
      //print("wifi connected");
      console.log('Connected to Wifi.  IP address is:', wifi.getIP().ip);
      clearInterval(iwico);
    });
    
    
    function wico() {
      console.log('trying to reconnect');
      wifi.restore();
    }
    
    function fmem() {
      free_mem = process.memory().free;
      print('free mem: ' + free_mem);
      setTimeout(fmem,1000);
    }
    fmem();
    

    After performing a ESP32.reboot, I get the following:

    >process.memory();
    ={ free: 3985, usage: 115, total: 4100, history: 0,
      gc: 0, gctime: 3.382 }
    free mem: 3981
    

    And as long as my Wifi doesn't disconnect it seems to stay steady at 3981. Shortly after I shut off my WIFI, I get a few error messages and then my memory drops to 3963. It continues to drop each time it tries to reconnect. After a couple of minutes, I turned my WIFI back on. Just before I turned it on the free memory was down to 3895. After it finished reconnecting it dropped more, down to:
    3859.

    Then it stays steady ad 3859. If I wait a few more minutes and turn off my WIFI again it doesn't seem to catch the change in WIFI status. If I manually type in wifi.getStatus(), I get the following

    ={
      station: "connected",
      ssid: "",
      bssid: "00:00:00:00:00:00",
      channel: 0, rssi: 0,
      htMode: "HT20",
      authMode: "wpa2",
      mode: "STA",
      powersave: "modem"
     }
    

    For some reason my ssid is now deleted. Any idea why it does that? Maybe I'm shutting my WIFI off too quickly. If I turn my WIFI back on, it doesn't re-connect a second time. I'll set it to run overnight and see how much, if any memory loss I get if I don't manually shut off the WIFI.

  • 'After flashing new firmware to the ESP32'

    Are we still at ver 2.04 ?

    On a S.W.AG. hunch, try console.log() the value of 'iwico' to see if the handle is changing. Wondering if the call to setInterval() is gobbling up those bytes?

About

Avatar for dwinfiel @dwinfiel started