BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

WEMOS Mega +WiFi R3 ATmega2560 + ESP8266

Hi guys,
i already accomplished to connect my mega+esp8266 with blynk.
i’m using the BlynkSimpleShieldEsp8266.h library for send from MEGA to ESP all the AT commands for wifi and blynk connection, and everything works fine for me.

i would to add to my blynk project a level widget with the wifi strength, but i cannot find any suggestion how to retrieve the value to send to the virtual pin.

i searched a lot on the net but i find a lot of example using wifi.h or esp8266.h and others library, but it seams that libriaries don’t work with my board, like wifi.RSSI() or others functions.

i searched also inside the BlynkSimpleShieldEsp8266.h and the BlynkESP8266_Lib libraries looking for some function that can send me the value of the wifi strength but i did not find anything about.

can someone help me how to retrieve that value?
or, can someone help me using another library with my board and my configuration (sketch on the mega, nothing on the esp, connected via serial3) that can send me that value?

i don’t wanto to transform all my sketch (like 600 lines) on two different sketches (one for the mega and one for the esp) cause in that case i have to send everything throw the serial3, data by data, and it’s not an option for me.

i hope exists another library that will work for me, also trying to connect with WPS.
maybe is the BlynkSimpleShieldEsp8266.h a little too SIMPLE?

thanks a lot

long rssi = WiFi.RSSI();
Blynk.virtualWrite(V1, rssi);

Works for me.
I haven’t dug into which library it is. I have also included ESP8266WiFi.h.

I believe this has been debated before… but I don’t think you can get direct access with WiFi.--- commands when using the ESP as a shield, as opposed to running Blynk (and the appropriate Blynk Library) on the actual ESP itself.

1 Like

That is what I was beginning to wonder. I guess there is a reason I gave up on Shields after 1 try.

There is a way to do this, but it requires you to add an additional method into the BlynkSimpleShieldEsp8266.h library file.

Please note that I don’t condone or encourage editing the Blynk library files, these changes are made at your own risk, and may need to be replicated each time Blynk is updated

Search the BlynkSimpleShieldEsp8266.h library file for these lines:

BLYNK_LOG1(BLYNK_F("Connected to WiFi"));
return true;

immediately after return true;, but before the closing curly bracket that follows it, add these lines:

// added by PeteKnight....
        String my_ap_ststs = wifi->getNowConecAp();
        BLYNK_LOG1(my_ap_ststs);
// end of added by PeteKnight

so that it looks like this:

        BLYNK_LOG1(BLYNK_F("Connected to WiFi"));
        return true;
    
// added by PK....
        String my_ap_ststs = wifi->getNowConecAp();
        BLYNK_LOG1(my_ap_ststs);
// end of added by PK
	   }

    void config(ESP8266&    esp8266,
                const char* auth,
                const char* domain = BLYNK_DEFAULT_DOMAIN,

This has the effect of allowing you to access the getNowConecAp() command in the ESP8266.Lib file which issues the AT+CWJAP_CUR? command that returns information about your Access Point in the following response format:

+CWJAP_CUR:<ssid>,<bssid>,<channel>,<rssi>

OK

ssid is the SSID of the WiFi network that you are connected to
bssid is the MAC address of your ESP-01
channel is the WiFi channel in use
rssi is what you’re looking for, the RSSI value

You can use this new method by adding the following lines to your sketch:

  String ap_stats = wifi.getNowConecAp();
  Serial.println(ap_stats);

This prints the following to my serial monitor:

+CWJAP:"MySSID","xx:c6:8e:11:af:xx",1,-56

OK

You’ll obviously need to parse the ap_stats string to extract the RSSI field. When you do this, be aware that the “OK” preceded by a new line are part of the ap_stats string, so it’s not simply a case of taking the last few characters of the string.

Pete.

1 Like

thank you so much, Pete.
i will try this solution and i’ll let you know if it’s working for me.

thanks a lot again. very helpfull!

ps. why don’t you put those lines in the next update so everyone can retrieve this AP info without ‘hand changing’ the library? can be usefull to many of us.

I have no connections to Blynk, so it’s not my decision to make.

I guess that the more functionality like this that is incorporated into the Blynk libraries, the more likely you are to get disconnection issues.

I see the ESP as Wi-Fi adaptor for an Arduino as being a simple way of getting people stated with Blynk, but I think it’s assumed that people will quickly progress to proper IoT enabled hardware such as the NodeMCU or ESP32.

Pete.

1 Like

this is my function to retrieve the int value of wifi strength
if someone else need it

thanks again to Pete for his help with the library hack suggestion

//get wifi strength
  int wifi_signal() {
    String ap_string=wifi.getNowConecAp();
    char* ap_char=ap_string.c_str();
    ap_char=strtok(ap_char,",");
    ap_char=strtok(NULL,","); 
    ap_char=strtok(NULL,",");
    ap_char=strtok(NULL,"\n");
    return atoi(ap_char);
  }
1 Like

Done!

1 Like

A post was split to a new topic: How to connect Uno and ESP-01 to Blynk

@Elfo_Del_Monte Thnx for your code to retrieve RSSI . . . I used it in my project, very muc apprecited!

billd