I have a problem with the following code. (Only the important code is shown)
The code works when I’m on localhost (using the IP address) but when going to an external web page I get the text “No answer”
I do not have a fixed IP only the URL of the webpage and my web supplier cannot give me a fixed IP on the homepage.
Any good advice would be appreciated, as I’m stuck with 20 rev 2 Cactus micros if there is no solution!
The code is build on your example.
.
.
void wificonnect(MyObject customVar) {
esp.enable();
delay(500);
esp.reset();
delay(500);
debugTekst("ARDUINO: setup rest client");
while (!esp.ready());
Serial.println("ARDUINO: setup rest client");
//if (!rest.begin("yourapihere-com-r2pgihowjx7x.runscope.net")) {
if (!rest.begin("http://www.klokken10.com")) {
debugTekst("ARDUINO: failed to setup rest client");
while (1);
}
/*setup wifi*/
debugTekst("ARDUINO: setup wifi");
esp.wifiCb.attach(&wifiCb);
esp.wifiConnect(customVar.ssid, customVar.pass);
debugTekst(customVar.ssid);
debugTekst(customVar.pass);
debugTekst("ARDUINO: system started");
}
.
.
.
void wifi() {
char response[266];
esp.process();
if (digitalRead(pirPort)) {
debugTekst("PIR alarm wifi?");
if (wifiConnected) {
debugTekst("PIR alarm");
rest.get("/test.php");
if (rest.getResponse(response, 266) == HTTP_STATUS_OK) {
debugTekst("ARDUINO: GET successful");
debugTekst(response);
blink(4);
} else {
debugTekst("No answer");
}
delay(12000);
}
}
}
.
.
The output looks like this
.
.
add 0
aid 2
pm open phy2,type:2 0 0
cnt
connected with jip:192.168.0.19,mask:255.255.255.0,gw:192.168.0.1
WIFI CONNECTED
PIR alarm wifi?
PIR alarm
No answer