ESP32 doesn't stay online

Coming from here:

As the title says my ESP32 running the newest dev version doesn’t stay online.

This is the LWT sensor data

10

Could you indicate the board you are using and your platformio.ini file.

This is the board I’m using:

And this is the content of the platforim.ini file:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
src_dir = main
default_envs = esp32dev
;, uno, atmega, esp32dev, nodemcuv2

[common]
framework = arduino
lib_deps = 
  Adafruit Unified Sensor
  1technophile/PubSubClient
  SparkFun BME280
  BMP180
  RFM69
  ArduinoJson@5.13.4
  DHT sensor library
  Adafruit TSL2561
  1technophile/rc-switch
  Wire
  jarzebski/Arduino-INA226
  1technophile/NewRemoteSwitch
build_flags =
  -w ; supress all warnings

[env:nodemcuv2]
framework = ${common.framework}
platform = espressif8266
board = nodemcuv2
lib_deps =
  ${common.lib_deps}
  1technophile/A6lib
  ESPiLight
  IRremoteESP8266
  https://github.com/tzapu/WiFiManager.git#c3ff582374e677f76d14de013966df0888b5b38e
  esp8266_mdns
lib_ignore = 
  Ethernet
build_flags = 
  ${common.build_flags}
monitor_speed = 115200
board_build.flash_mode = dout
upload_speed = 115200
upload_resetmethod = nodemcu

[env:esp32dev]
framework = ${common.framework}
platform = espressif32
board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
  ${common.lib_deps}
  IRremoteESP8266
  https://github.com/tzapu/WiFiManager.git#c3ff582374e677f76d14de013966df0888b5b38e
  https://github.com/eos1d3/ESP32_BLE.git
  https://github.com/sandeepmistry/arduino-LoRa.git
lib_ignore = 
  esp8266_mdns
  Ethernet
build_flags = 
  ${common.build_flags}

[env:atmega]
framework = ${common.framework}
platform = atmelavr
board = megaatmega2560
lib_deps =
  ${common.lib_deps}
  IRremote
  Ethernet
build_flags = 
  ${common.build_flags}

[env:uno]
framework = ${common.framework}
platform = atmelavr
board = uno
lib_deps =
  ${common.lib_deps}
  IRremote
  Ethernet
build_flags = 
  ${common.build_flags}

Thanks, could you give also your user_config.h without your password.

I didn’t change anything in the user_config will but “activating” RF, ONOFF and BLE.

I’d like to be able to use the wifimanger to configure it.

Could you try to deactivate ble and on off and see if you get a better stability ?

1 Like

It was online for a whole day (only RF activated).

I had to restart my WiFi router today and after that it went offline and did not go online again.

When you say after that, you mean as a consequency of the broker restart of some times after the restart ?

To check that I manually restartet my mqtt broker.
This isn’t the issue here, because the omg goes back/stays online after the restart.

It looks like if it loses the wifi connection somehow (eg router restart) it isn’t able to connect to wifi again.
This is repeatable, restarting my router means that the omg goes offline and stays offline.

I have just retested v0.9.2 on an esp32 with the following env:

[env:esp32dev-ble]
platform = ${com.esp32_platform}
board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
  ${com-esp.lib_deps}
  ${libraries.ble}
build_flags = 
  ${com-esp.build_flags}
  '-DZgatewayBT="BT"'
  '-DGateway_Name="OpenMQTTGateway_ESP32_BLE"'

With the following steps:

  • deactivate wifi
  • reactivate after 5s

OMG reconnects automaticaly

  • deactivate wifi
  • reactivate after 1min

OMG reconnects automaticaly

I pulled the latest dev version and was able to flash directly in vsc over the usb port (did it with FTDI before).

Unfortunately I still have the same issue. If the wifi routers restarts or fails the ESP32 OMG isn’t able to reconnect (again no problem with the ESP8266 running current master). I flashed:

default_envs = esp32dev-rf

And with the same env than me do you get the same behaviour ?

Flashed the same env as you and also removed my attached modules (RF and a LED).
Erased the flash before, just to make sure it’s a clean flash.

So now it’s a “naked” ESP32 with

default_envs = esp32dev-ble

and still after a reboot of my router the ESP32 goes and stays offline.

EDIT: it went online again after a minute.
EDIT2: unfortunately only for a few seconds and than went offline again.
EDIT3: I testet fresh ESP32 board, with the same result. So the first one isn’t defective.

Looks like I’m not the only one with this problem (ESP32):

Yep, I saw that. I will try a router restart instead of a wifi restart, if I don’t reproduce the difference could be due to the board or the router network. But as @PetricaM gets also bad result I’m excluding for the moment the network.

@PetricaM could you try to restart your router to see if your esp32 does the same like mine (staying offline).

Yeap, I already tried it but the behavior is too erratic.

Sometimes ESP32 reconnects, sometimes it doesn’t.

When it doesn’t reconnect I can see (in some of the cases) that the router has fast (2-3 per second) associate and disassociate events in the log. Some other times there’s dead radio silence from the board.

And when the ESP32 is not connected anymore does it popups the web portal for wifi configuration?

Nope (actually, I haven’t used wifi manager :slight_smile: )

Are you using wifi manager or the manual method?