Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Wifi connection problem

MM_MM_
edited February 21 in Mongoose OS

Hi,

I've got a problem with wifi disconnecting from time to time.
I've build a prototype with several esp8266 (NodeMCU) which are connected to local wifi network. These are mostly some kind of sensors - temperature, pressure, humidity, UV, Lux, etc.
They are working 24\7 but sometimes (I'd say once in 3/4 days) one (random) esp disconnected from the wifi and cannot reconnect. After several days another NodeMCU stops working. Router has around 10 active connected devices at most.

If I reset esp it simply reconnects and works as usual for another several days.
If I reset router (without resetting esp) esp still cannot connect.
I tried adding sta1 to my config (the same as sta) but that doesn't help - same log as without sta1.

I assume that this is a problem with esp not being able to reconnect. I found somewhere (forum or github) similar case (I think it was in 2017) but this was the problem within esp sdk and was corrected by a new mongoose os release with new sdk.

Did anyone have the same problem? Any ideas where to search for a solution?
I thought about monitoring the connection status and software resetting the device after some time without a proper connection however that's a workaround - not a solution for a long run.

Thanks in advance.

Logs:

mos --port COM9 call Sys.GetInfo
{
  "app": "sensor",
  "fw_version": "1.0",
  "fw_id": "20190117-212354",
  "mac": "CE50E3C734EA",
  "arch": "esp8266",
  "uptime": 60826,
  "ram_size": 52056,
  "ram_free": 38688,
  "ram_min_free": 31512,
  "fs_size": 233681,
  "fs_free": 226904,
  "wifi": {
    "sta_ip": "",
    "ap_ip": "",
    "status": "disconnected",
    "ssid": ""
  }
}
"wifi": {
    "ap": {
      "enable": false,
      "ssid": "Mongoose_??????",
      "pass": "Mongoose",
      "hidden": false,
      "channel": 6,
      "max_connections": 10,
      "ip": "192.168.4.1",
      "netmask": "255.255.255.0",
      "gw": "192.168.4.1",
      "dhcp_start": "192.168.4.2",
      "dhcp_end": "192.168.4.100",
      "trigger_on_gpio": -1,
      "disable_after": 0,
      "hostname": "",
      "keep_enabled": true
    },
    "sta": {
      "enable": true,
      "ssid": "paker",
      "pass": "???",
      "user": "",
      "anon_identity": "",
      "cert": "",
      "key": "",
      "ca_cert": "",
      "ip": "",
      "netmask": "",
      "gw": "",
      "nameserver": "",
      "dhcp_hostname": ""
    },
    "sta1": {
      "enable": true,
      "ssid": "paker",
      "pass": "???",
      "user": "",
      "anon_identity": "",
      "cert": "",
      "key": "",
      "ca_cert": "",
      "ip": "",
      "netmask": "",
      "gw": "",
      "nameserver": "",
      "dhcp_hostname": ""
    },
    "sta2": {
      "enable": false,
      "ssid": "",
      "pass": "",
      "user": "",
      "anon_identity": "",
      "cert": "",
      "key": "",
      "ca_cert": "",
      "ip": "",
      "netmask": "",
      "gw": "",
      "nameserver": "",
      "dhcp_hostname": ""
    },
    "sta_cfg_idx": 1,
    "sta_connect_timeout": 30
  },
mos console --port COM9
[Feb 21 09:28:23.757] timer_cb             Temperature 25.490000, Humidity 42.996094%, Pressure 1024.029163hPa
[Feb 21 09:28:23.772]
[Feb 21 09:28:24.371] mgos_wifi_sta_connec WiFi STA: Connect timeout
[Feb 21 09:28:24.377] mgos_wifi_get_next_s WiFi STA: Using config 0 (paker)
[Feb 21 09:28:24.383] state: 2 -> 0 (0)
[Feb 21 09:28:24.383] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Feb 21 09:28:24.388] mgos_wifi_setup_sta  WiFi STA: Connecting to paker
[Feb 21 09:28:24.402] mgos_net_on_change_c WiFi STA: connecting
[Feb 21 09:28:24.405] mgos_net_on_change_c WiFi STA: disconnected
[Feb 21 09:28:27.304] scandone
[Feb 21 09:28:27.305] state: 0 -> 2 (b0)
[Feb 21 09:28:27.305] state: 2 -> 3 (0)
[Feb 21 09:28:27.306] state: 3 -> 5 (10)
[Feb 21 09:28:27.306] add 0
[Feb 21 09:28:27.306] aid 5
[Feb 21 09:28:27.307] cnt
[Feb 21 09:28:28.771] timer_cb             Temperature 25.470000, Humidity 42.851562%, Pressure 1024.025663hPa
[Feb 21 09:28:28.798]
[Feb 21 09:28:30.276] state: 5 -> 2 (2c0)
[Feb 21 09:28:30.278] rm 0
[Feb 21 09:28:30.291] mgos_net_on_change_c WiFi STA: disconnected
[Feb 21 09:28:33.756] timer_cb             Temperature 25.450000, Humidity 42.736328%, Pressure 1023.998363hPa
[Feb 21 09:28:33.771]
[Feb 21 09:28:38.756] timer_cb             Temperature 25.440000, Humidity 42.836914%, Pressure 1024.003863hPa
[Feb 21 09:28:38.767]
[Feb 21 09:28:43.760] timer_cb             Temperature 25.430000, Humidity 42.712891%, Pressure 1024.017263hPa
[Feb 21 09:28:43.767]
[Feb 21 09:28:53.783] timer_cb             Temperature 25.410000, Humidity 43.089844%, Pressure 1024.020463hPa
[Feb 21 09:28:53.795]
[Feb 21 09:28:54.395] mgos_wifi_sta_connec WiFi STA: Connect timeout
[Feb 21 09:28:54.405] mgos_wifi_get_next_s WiFi STA: Using config 1 (paker)
[Feb 21 09:28:54.410] state: 2 -> 0 (0)
[Feb 21 09:28:54.411] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Feb 21 09:28:54.412] mgos_wifi_setup_sta  WiFi STA: Connecting to paker
[Feb 21 09:28:54.424] mgos_net_on_change_c WiFi STA: connecting
[Feb 21 09:28:54.426] mgos_net_on_change_c WiFi STA: disconnected
[Feb 21 09:28:57.346] scandone
[Feb 21 09:28:57.347] state: 0 -> 2 (b0)
[Feb 21 09:28:57.352] state: 2 -> 3 (0)
[Feb 21 09:28:57.354] state: 3 -> 5 (10)
[Feb 21 09:28:57.365] add 0
[Feb 21 09:28:57.424] aid 5
[Feb 21 09:28:57.426] cnt
[Feb 21 09:28:58.763] timer_cb             Temperature 25.390000, Humidity 43.128906%, Pressure 1024.027763hPa
[Feb 21 09:28:58.777]
[Feb 21 09:28:58.876] mgos_mqtt_global_con MQTT connecting to 192.168.0.21:1883
[Feb 21 09:28:58.885] mgos_mqtt_ev         MQTT TCP connect error (-4)
[Feb 21 09:28:58.890] mgos_mqtt_ev         MQTT Disconnect
[Feb 21 09:28:58.891] mqtt_global_reconnec MQTT connecting after 60807 ms
[Feb 21 09:29:00.314] state: 5 -> 2 (2c0)
[Feb 21 09:29:00.317] rm 0
[Feb 21 09:29:00.318] mgos_net_on_change_c WiFi STA: disconnected
[Feb 21 09:29:03.760] timer_cb             Temperature 25.390000, Humidity 43.057617%, Pressure 1024.030963hPa
[Feb 21 09:29:03.773]
[Feb 21 09:29:03.810] mgos_mdns_init       Listening on udp://:5353
[Feb 21 09:29:03.814] mgos_mdns_hal_join_g Joining multicast group 224.0.0.251
[Feb 21 09:29:08.760] timer_cb             Temperature 25.370000, Humidity 43.188477%, Pressure 1024.030963hPa
[Feb 21 09:29:08.772]
[Feb 21 09:29:13.762] timer_cb             Temperature 25.360000, Humidity 42.952148%, Pressure 1024.027463hPa
[Feb 21 09:29:13.769]
[Feb 21 09:29:18.760] timer_cb             Temperature 25.340000, Humidity 43.412109%, Pressure 1024.029963hPa
[Feb 21 09:29:18.771]
[Feb 21 09:29:23.763] timer_cb             Temperature 25.340000, Humidity 43.114258%, Pressure 1024.029163hPa
[Feb 21 09:29:23.774]
[Feb 21 09:29:24.421] mgos_wifi_sta_connec WiFi STA: Connect timeout
[Feb 21 09:29:24.423] mgos_wifi_get_next_s WiFi STA: Using config 0 (paker)
[Feb 21 09:29:24.430] state: 2 -> 0 (0)
[Feb 21 09:29:24.446] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Feb 21 09:29:24.449] mgos_wifi_setup_sta  WiFi STA: Connecting to paker
[Feb 21 09:29:24.488] mgos_net_on_change_c WiFi STA: connecting
[Feb 21 09:29:24.512] mgos_net_on_change_c WiFi STA: disconnected
[Feb 21 09:29:27.369] scandone
[Feb 21 09:29:27.369] state: 0 -> 2 (b0)
[Feb 21 09:29:27.380] state: 2 -> 3 (0)
[Feb 21 09:29:27.398] state: 3 -> 5 (10)
[Feb 21 09:29:27.399] add 0
[Feb 21 09:29:27.442] aid 5
[Feb 21 09:29:27.445] cnt
[Feb 21 09:29:28.762] timer_cb             Temperature 25.320000, Humidity 43.450195%, Pressure 1024.020163hPa
[Feb 21 09:29:28.777]
[Feb 21 09:29:30.327] state: 5 -> 2 (2c0)
[Feb 21 09:29:30.337] rm 0
[Feb 21 09:29:30.338] mgos_net_on_change_c WiFi STA: disconnected

Comments

  • tripflextripflex Orlando, FL

    What kind of signal are you getting for your device's wifi connection? Is it a poor quality signal? I've actually done the same thing myself with a "fallback" so-to-speak, to reboot the device if wifi network is down for more than 4 hours, but in my situation is seems to be only when my device has a really poor quality signal from the router

  • Thanks for the info.
    Unfortunately, some of the devices are really close (same room - 2-3m) to the router and have good signal, however I double check it next time.

    It seems as if the chip permanently drops connection and cannot reconnect to wifi after some time - only reset helps.
    For some applications the workaround with a reboot is fine, but for others it isn't.

  • I powered one of the device from power bank. After it hanged I moved it close to the access point (1 meter).
    However without device reset (router reset didn't help) it couldn't connect to the wifi - still I could connect the device itself with serial\bt connection and see that it's working.

    In other location the device (completely different firmware, based on Mongoose OS) was very stable - working fine for 5 weeks. After it being moved outside of the house it drops connection from time to time and cannot reconect like the situation I described earlier.

    It seems as if there's a problem with the connection\reconnection functionality.
    Can it be caused by a bug in ESP8266 SDK?

    Can it be caused by unsuitable power supply? However I reproduced the problem using my good powerful branded power bank.
    Maybe some more decoupling capacitors near the NodeMCU would help - should try this.

  • This one seems be the same case: https://github.com/espressif/ESP8266_NONOS_SDK/issues/119

    It was already done, however as noted in the comments - the problem still shows up sometimes in other unknown circumstances.
    https://github.com/mongoose-os-libs/wifi/commit/752dac619cb318394a28ff518d3e67900445d34f

    Does anybody know any other workaround about this problem apart from resetting the device?

    Thanks in advance.

Sign In or Register to comment.