Closed
Description
MRE
Using the following sketch
- Arduino IDE v1.8.19,
- mbed_portenta core v2.6.1
- Portenta_H7_M7 with Murata WiFi
#ifdef CORE_CM7 // Start M7 Core programming
#include <WiFi.h>
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = "YOUR_SSID"; // your network SSID (name)
char pass[] = "YOUR_PASSWORD"; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
void printWifiStatus()
{
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial);
delay(500);
// check for the WiFi module:
if (WiFi.status() == WL_NO_SHIELD)
{
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 3 seconds for connection:
delay(3000);
}
}
void loop()
{
if (WiFi.status() == WL_CONNECTED)
//if ( (WiFi.status() == WL_CONNECTED) && (WiFi.RSSI() != 0) ) // temporary workaround
{
Serial.println("Connected to wifi");
printWifiStatus();
}
else
{
Serial.println("Not connected to wifi");
}
delay(5000);
}
#endif
The Terminal output shows that even after WiFi was powered down ( RSSI = 0), WiFi.status()
still reports WL_CONNECTED
Attempting to connect to SSID: YOUR_SSID
Connected to wifi
SSID: YOUR_SSID
IP Address: 192.168.2.104
signal strength (RSSI):-26 dBm
Connected to wifi
SSID: YOUR_SSID
IP Address: 192.168.2.104
signal strength (RSSI):-38 dBm
Connected to wifi
SSID: YOUR_SSID
...
Connected to wifi
SSID: YOUR_SSID
IP Address: 192.168.2.104
signal strength (RSSI):0 dBm <======= WiFi Powered down, RSSI = 0, but still reporting WL_CONNECTED
Connected to wifi
SSID: YOUR_SSID
IP Address: 192.168.2.104
signal strength (RSSI):0 dBm
Connected to wifi
SSID: YOUR_SSID
IP Address: 192.168.2.104
signal strength (RSSI):0 dBm
Discussion
WiFi.status() returns _currentNetworkStatus
, which is updated only in begin() or beginAP(), but there is no function to update _currentNetworkStatus
if the connected WiFi is lost.
uint8_t arduino::WiFiClass::status() {
return _currentNetworkStatus;
}
Temporary Workaround (not 100% working now)
Using with WiFi.RSSI()
to detect if WiFi is powered down or signal lost
if ( (WiFi.status() == WL_CONNECTED) && (WiFi.RSSI() != 0) )
Metadata
Metadata
Assignees
Labels
No labels