I'm trying to do a reading of a small PHP I did with the temperature of my house, with an Arduino and ESP8266 Wifi).
The php is the http://ricardogomes.eu/jp/temps.php.
I wanted to take the 3 lines and print on a 20x4 LCD.
I already have some code and I think I'm already able to connect to the site and get something.
But just got the response of bytes received and what I think is the top of page.
Someone can give a look in my code?
thank you
#include <stdlib.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define SSID "*******"
#define PASS "********"
#define IP "ricardogomes.eu"
int a=0;
void setup()
{
lcd.begin(20, 4);
Serial.begin(115200);
sendDebug("AT");
delay(5000);
if(Serial.find("OK")){
connectWiFi();
}
}
void loop(){
updateTemp();
delay(5000);
a=a+1;
if (a>120) {
String cmd = "AT+RST";
sendDebug(cmd);
delay(60000);
sendDebug("AT");
delay(5000);
if(Serial.find("OK")){
connectWiFi();
a=0;
}
}
}
void updateTemp(){
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
Serial.println(cmd);
delay(2000);
cmd = "GET /jp/temps.php \r\n\r\nHost: ricardogomes.eu:80\r\n\r\n\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
if(Serial.find(">")){
Serial.print(cmd);
delay(10000);
lcd.clear();
while (Serial.available())
{
char c = Serial.read();
lcd.print(c);
}
}
else{
lcd.print("*****NOK*****");
sendDebug("AT+CIPCLOSE");
}
}
void sendDebug(String cmd){
Serial.println(cmd);
}
boolean connectWiFi(){
// Serial.println("AT+CWMODE=3");
// Serial.println("AT+RST");
// Serial.println("AT+CIPMUX=1");
Serial.println("AT+CWMODE=1");
delay(2000);
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";
sendDebug(cmd);
delay(5000);
}