Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Torah
#27522 Hallo!

I think my question may be not relay with the time delay. Because I tried the local server and delay(50000). Always the response by using web browser is very quick. Well, please let me make it more clear. I have two questions turn to you for help.
1. I cannot find the esptool in tool->programmer, although the USBtinyISP and etc. are all well. BTW, I tried in both Win 10 64bit and Win XP 32bit. And I can't see nothing reply on serial monitor. I tried both Arduino as ISP or with FTDI (esp12 standalone).
2. I tried to make esp8266 to send GET request to local server. But failed many times. The code typically likes the following. I can see that my esp12 connected wifi. I think it's not a module or home network issue. I've ran some piece of code doing the same stuff but using httpd. So from your experience, can you help out of this strange problem?

Thank you in advance. Merci beaucoup.

// Import required libraries
#include <ESP8266WiFi.h>

// WiFi parameters
const char* ssid = "TorahYongquan";
const char* password = "PlantoWang";

// Host
const char* host = "planto.oicp.net";// the local dns server is ok, and I tried 192.168.x.x, the result is same

void setup() {
// Start Serial
Serial.begin(115200);
delay(50000);

// 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(50000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

int value = 0;

void loop() {

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 failed");
return;
}

// This will send the request to the server
client.print(String("GET /add.php?temper=22") + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(50000);

Serial.print("client.status(): ");
Serial.println(client.status());
Serial.print("client.available(): ");
Serial.println(client.available());
Serial.print("client.connected(): ");
Serial.println(client.connected());

// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r\n');
Serial.print(line);
}

Serial.println();
Serial.println("closing connection");
delay(50000);

}
User avatar
By martinayotte
#27553
Torah wrote:1. I cannot find the esptool in tool->programmer, although the USBtinyISP and etc. are all well. BTW, I tried in both Win 10 64bit and Win XP 32bit. And I can't see nothing reply on serial monitor. I tried both Arduino as ISP or with FTDI (esp12 standalone).

For ESP, The Tool/Programmer menu is not used at all, so it doesn't matter here. For the Serial monitor, make sure that you use the right port in Tool/Port menu.
Torah wrote:2. I tried to make esp8266 to send GET request to local server. But failed many times. The code typically likes the following. I can see that my esp12 connected wifi. I think it's not a module or home network issue.

Are you sure that the module is really connected to your WiFi ? maybe you can print its IP with WiFi.localIP() to make sure. What kind of Web server are you running, is it Apache ? is the URL you provide also working inside a simple browser ?
Torah wrote:I've ran some piece of code doing the same stuff but using httpd. So from your experience, can you help out of this strange problem?

What do you mean by "doing the same stuff but using httpd" ?
User avatar
By Torah
#27584 Hi, thank you for your reply.

1. It's very stranger that I can use Serial monitor when using Arduino board, but I can't see anything in Serial monitor when using arduino IDE 1.6.4 for esp8266 standalone programming with FTDI (usb->ttl, not arduino board).

2. I am sure about the module connected to the WIFI because I used superviser software on WiFi in Windows and it discovered the connected devices when the esp12 entered in. And because the first problem, I can see nothing in the Serial monitor when serial.println() executed when using esp8266 with FTDI. So your advice on print its IP is not suitable for this condition. For the local web server, it is Apache. And the URL works very well, you can trust me on that. And I attached it on dns server on my computer. So when I started this dns server, foreigners can also visit it.
User avatar
By martinayotte
#27587 Well, the FTDI issue is a new problem that you didn't mentioned before. It doesn't help to try to narrow the issue.
Do you mean that you are using the Arduino to upload to Flash or you are using the FTDI ?
Do you have a common ground on all the setup ?