Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By zecanilis
#40060 ello

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

Code: Select all#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);
}

You do not have the required permissions to view the files attached to this post.
User avatar
By eduperez
#40103 Your PHP script produces an HTML page, and that contains much more text than what your browser is showing you. Using your browser of choice, look for an option to "view page source"; that is what your ESP receives, and that is what it is sending to the LCD.

So, you have two options here: either you modify your PHP script so it just output the text that you want to display on the LCD, or your modify your sketch on the ESP to parse the HTML and extract the info you need.
User avatar
By eduperez
#40117 Well, you sketch is programmed to stop on the first ">" character it encounters; have a look at the source code for the web page that your PHP script produces, and see the ">" at the end of the DOCTYPE tag.