title: ESP8266 with DHT11
body: <p>I'm trying to get the ESP8266-01 to work with my DHT11 sensor and post data to Thingspeak.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>The code I'm trying to upload is the following:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// www.arduinesp.com
  //
  // Plot DTH11 data on thingspeak.com using an ESP8266
  // April 11 2015
  // Author: Jeroen Beemster
  // Website: www.arduinesp.com
  
  #include &lt;DHT.h&gt;
  #include &lt;ESP8266WiFi.h&gt;
  
  // 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 +="&amp;field1=";
  postStr += String(t);
  postStr +="&amp;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);
  }
  </code></pre>
  
  <p>And the error message I get is the following:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I'm using an 3.3 external power supply with 1A. I connected this to power up the ESP8266 module.<br>
  My setting in Arduino IDE are as follows.</p>
  
  <p><a href="https://i.stack.imgur.com/DgbQE.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DgbQE.gif" alt="Arduino IDE settings"></a></p>
  
  <p>I have tried the following:</p>
  
  <p>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.</p>
  
  <p>Hope the information is enough.
  Thanks for your time.
  <img src="https://i.stack.imgur.com/Q2yMO.jpg" alt="conectipns">
  <img src="https://i.stack.imgur.com/ufFnK.jpg" alt="ftdi module"></p>