🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Simple Wi-Fi signal strength

    PROJECTS
    2
    2
    5.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      peter153
      last edited by peter153

      It's like an icon of LTE signal strength, but...
      Of course, I wanted to do it in a way that everyone knows, but...It's too complicated. Does anyone have a simple implementation experience?

      void showWifiSignal()
      {

      int nWifi = getWifidBm();
      M5.Lcd.setCursor(2, 30);
      M5.Lcd.setTextSize(1);
      M5.Lcd.print(String(nWifi)+"dBm");

      if(nWifi < -50 && nWifi == 0 )
      {
      M5.Lcd.drawRoundRect(30, 12, 5, 16, 1, LIGHTGREY);

      }
      else
      {
      M5.Lcd.fillRoundRect(30, 12, 5, 16, 1, BLACK);
      }

      if(nWifi < -70 && nWifi == 0)
      {
      M5.Lcd.drawRoundRect(22, 16, 5, 12, 1, LIGHTGREY);

      }
      else
      {
      M5.Lcd.fillRoundRect(22, 16, 5, 12, 1, BLACK);
      }

      if(nWifi < -80 && nWifi == 0)
      {
      M5.Lcd.drawRoundRect(14, 20, 5, 8, 1, LIGHTGREY);

      }
      else
      {
      M5.Lcd.fillRoundRect(14, 20, 5, 8, 1, BLACK);
      }

      if(nWifi < -90 && nWifi == 0)
      {
      M5.Lcd.drawRoundRect(6, 23, 5, 5, 1, LIGHTGREY);
      }
      else
      {
      M5.Lcd.fillRoundRect(6, 23, 5, 5, 1, BLACK);
      }
      }

      1 Reply Last reply Reply Quote 0
      • frittnaF
        frittna
        last edited by frittna

        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);
        }

        1 Reply Last reply Reply Quote 0
        • First post
          Last post