You are reading a single comment by @Robin 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?

  • Yes my version is 2.04. Would trying an older vesion help? Not sure what you want me to console.log(), if I just put that I get "=undefined". When I do >E.getSizeOf(global, 2), I get the following:

    >E.getSizeOf(global, 2)
    =[
      {
        name: "\xFF",
        size: 63,
        more: [
          {
            name: "timers",
            size: 12 },
          {
            name: "watches",
            size: 3 },
          {
            name: "net",
            size: 3 },
          {
            name: "modules",
            size: 15 },
          {
            name: "BLE_DEV_N",
            size: 4 },
          {
            name: "history",
            size: 24 }
         ]
       },
      {
        name: "wico",
        size: 4,
        more: [
          {
            name: "\xFFcod",
            size: 2 }
         ]
       },
      {
        name: "fmem",
        size: 4,
        more: [
          {
            name: "\xFFcod",
            size: 2 }
         ]
       },
      {
        name: "ssid",
        size: 2 },
      {
        name: "pswd",
        size: 3 },
      {
        name: "wifi",
        size: 12,
        more: [
          {
            name: "#ondisconnected",
            size: 5 },
          {
            name: "#onconnected",
            size: 5 }
         ]
       },
      {
        name: "iwico",
        size: 2 },
      {
        name: "process",
        size: 3,
        more: [  ]
       },
      {
        name: "free_mem",
        size: 2 },
      {
        name: "console",
        size: 3,
        more: [  ]
       },
      {
        name: "ReferenceError",
        size: 8,
        more: [
          {
            name: "prototype",
            size: 6 }
         ]
       },
      {
        name: "E",
        size: 2,
        more: [  ]
       }
     ]
    

    There were not any memory loss during the night (WIFI probably didn't loose connection). Resetting it this morning dropped it from 3696 (what it dropped to after running a few commands such as the E.getSizeOf(global, 2)) to 3605 by the time it reconnected.

About

Avatar for Robin @Robin started