Alternative to DDNS, get public IP from Ipify with ESP8266

247 views
Skip to first unread message

Di Maio, Dario

unread,
Nov 26, 2017, 6:16:35 AM11/26/17
to sou...@googlegroups.com
Hi,

just got some code over the internet and re arranged to echo back my IP address every 30 min if has changed, via Telegram in my case, but could be any other messagging solution.

This is an alternative to no-ip and other DDNS that request 30-day confirmation for free accounts.

My ip address doesn't change until I reboot my router, so this works for me as generally it never change. But if it will, I will get a notification via Telegram to change my SoulissApp settings.

Here a piece of code,

        SLOW_30m() {  // Process the timer twice per hour  

// Open a connection to Ipify to get the public IP address
WiFiClient client;
if (client.connect("api.ipify.org", 80)) 
{
client.println("GET / HTTP/1.0\r\nHost: api.ipify.org\r\n\r\n");
}
 
// Retrieve the response string
String new_ip;
while(client.available()) new_ip = client.readStringUntil('\n');

// If the IP address has changed, notify via Telegram
if (new_ip!=ip) {
ip=new_ip;
String ipmessage="Indirizzo IP cambiato: "+ip;
bot.sendMessage(group_id, ipmessage, "");
}
}
}

Dario.
Reply all
Reply to author
Forward
0 new messages