I'm trying to get the ESP8266-01 to work with my DHT11 sensor and post data to Thingspeak.
To upload my code to the ESP8266 I'm using a TTL to USB with the model FTDI232, and have selected the 3.3v output.
I was able to upload the "blink" example from the esp examples in the first try, then try to upload my code with the sensor and was not successful, getting the and error when uploading the sketch.
The code I'm trying to upload is the following:
// www.arduinesp.com
//
// Plot DTH11 data on thingspeak.com using an ESP8266
// April 11 2015
// Author: Jeroen Beemster
// Website: www.arduinesp.com
#include <DHT.h>
#include <ESP8266WiFi.h>
// replace with your channel’s thingspeak API key,
String apiKey = "EQE7GT28UMUW17CH";
const char* ssid = "GC-Office-WLAN1";
const char* password = "bsontkgcmxitwn30of01101911";
const char* server = "api.thingspeak.com";
#define DHTPIN 2 // what pin we’re connected to
DHT dht(DHTPIN, DHT11,15);
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);
dht.begin();
WiFi.begin(ssid, password);
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");
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
if (client.connect(server,80)) { // "184.106.153.149" or api.thingspeak.com
String postStr = apiKey;
postStr +="&field1=";
postStr += String(t);
postStr +="&field2=";
postStr += String(h);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius Humidity: ");
Serial.print(h);
Serial.println("% send to Thingspeak");
}
client.stop();
Serial.println("Waiting…");
// thingspeak needs minimum 15 sec delay between updates
delay(60000);
}
And the error message I get is the following:
Arduino:1.6.12 (Windows 7), Tarjeta:"Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 512000, 512K (64K SPIFFS), ck, Disabled, None"
El Sketch usa 233,113 bytes (53%) del espacio de almacenamiento de programa. El máximo es 434,160 bytes.
Las variables Globales usan 32,432 bytes (39%) de la memoria dinámica, dejando 49,488 bytes para las variables locales. El máximo es 81,920 bytes.
Uploading 237264 bytes from C:\Users\nmnerzul\AppData\Local\Temp\arduino_build_881344/humedadesp8266solo.ino.bin to flash at 0x00000000
..........warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
I'm using an 3.3 external power supply with 1A. I connected this to power up the ESP8266 module.
My setting in Arduino IDE are as follows.
I have tried the following:
Reset module before updating, change of flash size (to 1M at 512k), change speed (tested 512000, 9600, 115200) and I'm only able to upload the blink example.
Hope the information is enough. Thanks for your time.