you can try this pice of code which is working for me:
.
.
#include <WiFi.h>
#include "Free_Fonts.h"
#include <M5Stack.h>
const char* ssid = "your_host";
const char* password = "your_password";
WiFiClient client;
void setup() {
M5.begin();
// Connecting to WiFi:
M5.Lcd.setFreeFont(FM9); M5.Lcd.setTextSize(1); M5.Lcd.setTextColor(TFT_WHITE);
M5.Lcd.print("\n\nConnecting to ");
M5.Lcd.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
M5.Lcd.setTextWrap(true);
M5.Lcd.print(".");
delay(500);
}
M5.Lcd.println("\nWiFi connected");
delay(1000);
M5.Lcd.fillScreen(TFT_BLACK);
}
void loop() {
showWifiStrength();
delay(2000);
}
// show Wifi-RSSI level (signal strength in 4 bars + dBm )
void showWifiStrength() {
int WifiRSSI = WiFi.RSSI();
M5.Lcd.fillRect(40, 0, 68, 15, TFT_BLACK);
M5.Lcd.setCursor(40, 14);
M5.Lcd.print(String(WifiRSSI) + "dBm");
if (WifiRSSI > -50 & ! WifiRSSI == 0 ) M5.Lcd.fillRoundRect(26, 1, 5, 12, 1, TFT_WHITE);
else M5.Lcd.fillRoundRect(26, 1, 5, 12, 1, TFT_DARKGREY);
if (WifiRSSI > -70 & ! WifiRSSI == 0) M5.Lcd.fillRoundRect(18, 3, 5, 10, 1, TFT_WHITE);
else M5.Lcd.fillRoundRect(18, 3, 5, 10, 1, TFT_DARKGREY);
if (WifiRSSI > -80 & ! WifiRSSI == 0) M5.Lcd.fillRoundRect(10, 5, 5, 8, 1, TFT_WHITE);
else M5.Lcd.fillRoundRect(10, 5, 5, 8, 1, TFT_DARKGREY);
if (WifiRSSI > -90 & ! WifiRSSI == 0)
M5.Lcd.fillRoundRect(2, 7, 5, 6, 1, TFT_WHITE);
else M5.Lcd.fillRoundRect(2, 7, 5, 6, 1, TFT_RED);
}