Wi-Fi strength and reconnect details


#1

Hi,
I’m having a problem with an ESP32 that whenever I put it into it’s final location (temperature monitor of a greenhouse) it works for a variable number of hours and then stops reporting.
My current theory that it is losing it’s Wi-Fi connection and is unable to reconnect.

Is there any way to get the strength of the Wi-Fi signal using ulisp?

Also, I know wifi-connect says it will reconnect if the signal is lost. How does this work? ie. how often does it try to reconnect, will it try reconnecting indefinitely or is there an eventual timeout etc?

I’m thinking of lighting up the onboard LED to show whether the Wi-Fi is connected or not. Can I get this state using ulisp?

Sorry for a bunch of questions, but I’ve currently only found the wifi-connect function and I will need some other functions too.

Thank you!


#2

You didn’t say what board you are using. I’ve just tried the following test on my Adafruit ESP32 Feather board:

Load the following program:

(defvar *wifi* "MyWiFi")
(defvar *pass* "Mypassword")

(defun test ()
  (pinMode :led-builtin t)
  (wifi-connect *wifi* *pass*)
  (loop
   (let ((ip (wifi-localip)))
     (digitalwrite :led-builtin (not (string= ip "0.0.0.0")))
     (delay 1000))))

Run:

(test)

The built-in LED lights up. Then turning off my home Wi-Fi made the light go out. Turning it back on again, and the ESP32 automatically reconnected to the network and the LED went on again.

My assumption is that it will try reconnecting indefinitely, but you could use this test program to explore that.

It could be that there’s something else in your program that’s causing it to fail eventually. Is it all written in uLisp? Does it only fail after several hours when running in the greenhouse? Could it be a power supply problem; eg glitches resetting the board?


#3

Thanks, for the program, that’s great. I’ll try something like that to debug and explore if it reconnects indefinitely.


#4

If I wanted to get a number representing the signal strength, would that be possible?


#5

The ESP32 provides a call WiFi.RSSI() that gives the signal strength, but I haven’t implemented it in uLisp. I could add it in a future version. In the meantime you could program it as an extension; see:

Adding your own functions