-->
Page 1 of 3

Creating a multi info display

PostPosted: Sun Jan 31, 2016 6:58 am
by zecanilis
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);
}


Re: Creating a multi info display

PostPosted: Sun Jan 31, 2016 3:41 pm
by eduperez
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.

Re: Creating a multi info display

PostPosted: Sun Jan 31, 2016 5:02 pm
by zecanilis
I'm made a soft serial and sent all the income of the ESP to it and i only get the same amount of characters.

Recv 56 bytes



SEND OK


+IPD,601:HTTP/1.1 200 OK

Date: CLOSED

Re: Creating a multi info display

PostPosted: Sun Jan 31, 2016 5:11 pm
by eduperez
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.