ESP-01 simple WiFi Client problem
Posted: Fri Dec 04, 2015 11:09 am
Hi,
I'm trying to read some data from simple web page (https://pure-caverns-1350.herokuapp.com/stan)
It should respond with "0" or "1" (later I would like to turn output high or low regarding to this, but later...)
I have a problem with this code:
In serial monitor I have only:
But what is weird I don't see anything in heroku's log...
I tested it with postman and get request works fine when I'm not using ESP-01
Where should I look for problem?
Thank you in advance for any kind of help!
I'm trying to read some data from simple web page (https://pure-caverns-1350.herokuapp.com/stan)
It should respond with "0" or "1" (later I would like to turn output high or low regarding to this, but later...)
I have a problem with this code:
Code: Select all
/*
#include <ESP8266WiFi.h>
const char* ssid = "WiwoNET";
const char* password = "123456";
const char* host = "pure-caverns-1350.herokuapp.com";
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
delay(5000);
++value;
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (client.connect(host, httpPort)) {
Serial.println("connection success");
}
else {
Serial.println("connection failed");
}
// We now create a URI for the request
String url = "/stan";
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print("GET " + url + " HTTP/1.1\r\n" +
"Host: " + host +"\r\n");
delay(10);
// Read all the lines of the reply from server and print them to Serial
Serial.println("Informacja zwrotna:");
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}
In serial monitor I have only:
Code: Select all
Connecting to WiwoNET
...........
WiFi connected
IP address:
192.168.0.111
connecting to pure-caverns-1350.herokuapp.com
connection success
Requesting URL: /stan
Informacja zwrotna:
closing connection
But what is weird I don't see anything in heroku's log...
I tested it with postman and get request works fine when I'm not using ESP-01
Where should I look for problem?
Thank you in advance for any kind of help!