Get external IP from Ipify
Posted: Wed Aug 12, 2015 3:19 pm
Hi i'm newbie on ESP8266. I have a project that have to acquire a external IP.
I found this website https://www.ipify.org/ that has an API that return the external IP.
When i try to use AT+CIPSEND to get the response the ESP returns wrong syntax.
Code:
Link: http://allaboutee.com/2014/12/27/esp826 ... d-circuit/
The Steps followed are:
- AT+RST (restart the module)
-AT+CWMODE=3 (change the working mode to 3, AP+STA)
-AT+CWJAP=“you ssid”, “password” (join router)
-AT+CIPMUX=0 (Single connection)
-AT+CIPSTART="TCP","api.ipify.org",80 (connect to remote TCP server)
-AT+CIPSEND=45 (quantity of characters)
(Wait for ">")
GET / HTTP/1.0\r\nHost: api.ipify.org\r\n\r\n
Thank you all for your help
I found this website https://www.ipify.org/ that has an API that return the external IP.
When i try to use AT+CIPSEND to get the response the ESP returns wrong syntax.
Code:
Code: Select all
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
}
void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}
if(Serial.available())
{
// the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
// In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
// but we want to send everything at the same time.
delay(1000);
String command="";
while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command); // send the read character to the esp8266
}
}
Link: http://allaboutee.com/2014/12/27/esp826 ... d-circuit/
The Steps followed are:
- AT+RST (restart the module)
-AT+CWMODE=3 (change the working mode to 3, AP+STA)
-AT+CWJAP=“you ssid”, “password” (join router)
-AT+CIPMUX=0 (Single connection)
-AT+CIPSTART="TCP","api.ipify.org",80 (connect to remote TCP server)
-AT+CIPSEND=45 (quantity of characters)
(Wait for ">")
GET / HTTP/1.0\r\nHost: api.ipify.org\r\n\r\n
Thank you all for your help