For future reference, it is possible to resolve the hostname blynk-cloud.com to an IP address using this code:
IPAddress Blynk_Server_IP;
WiFi.hostByName("blynk-cloud.com", Blynk_Server_IP);
Serial.print("blynk.cloud.com IP address is ");
Serial.println(Blynk_Server_IP);
You can use this at any point once you have a Wi-Fi connection and you can use it when you done a normal Blynk.begin(), so it could be called using a button widget and the result pushed to a display widget if needed. As has been pointed out before, this isn’t necessarily the same IP address that has been used to establish the connection from the device to the Blynk cloud server. Having said that, it seems highly likely that it will be the same server.
I did briefly play around @Gunner’s suggestion by with using
WiFi.begin(ssid,pass);
to set-up the Wi-Fi connection then calling the code above and using:
Blynk.config(auth, Blynk_Server_IP, 8442);
This does work, but I ran into a couple of snags:
a) Sometimes this bit of code returns an IP of “0.0.0.0” as the Blynk_Server_IP and when this happens you obviously don’t get a Blynk connection when you use this as a parameter in the Blynk.config() call. There’s probably a way around this using a while loop to keep calling
WiFi.hostByName("blynk-cloud.com", Blynk_Server_IP);
until you get a valid IP, but I couldn’t be bothered to explore that option.
b) When you do get a Blynk connection you don’t get the normal Blynk logo on the serial monitor. You can tell that there is a valid connection because the device is shown as being online in the app, so it’s not really a big deal, especially if you’re not monitoring the serial output or redirecting it to a terminal widget.
It doesn’t seem that this will help @mohan_sundaram, but somebody might find it useful at some point in future.
Pete.