arduino to ESP8266 get httpclient problem

400 Views Asked by At

i use httpclient lib in Arduino IDE, but there is no valid respond in monitor and it doesn't work well! it's very simple code:

#include <SoftwareSerial.h>
#include <Bridge.h>
#include <HttpClient.h>

#define RX 10
#define TX 11

String AP = "SSID";
String PASS = "password";

SoftwareSerial esp8266(RX,TX);

void setup() {
  Serial.begin(9600);
//  Serial.println("Serial init");
  esp8266.begin(115200);

  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}

void loop() {
  HttpClient client;
  client.get("http://server-address/led.txt"); // just 1 or 0

  while (client.available()) {
    char led = client.read();
//    Serial.println("=> "+led);

    if(led == '1') {
      digitalWrite(13, LOW);
    } else {
      digitalWrite(13, HIGH);
    }

    delay(1500);

  }

  Serial.flush();
  delay(1500);
}

sample example i use link

image link

tools: arduino uno, esp8266, breadboard, one led

1

There are 1 best solutions below

0
Nate Pulkar On

try your code using the ESP8266Webserver.h library you can also check the code sample from here