How to send data from DHT11 ESP8266 ESP01 to ADAFRUIT

Hello there,

i am fresh new and i have DHT11, CH340 USB to ESP8266 ESP-01 ESP-01S Programmer and Arduino IDE...

I found code for DHT11 to show me Temperature and Humidity through WIFI in Web browser, but i cannot find anywhere code which can send data to Adafruit and be visible there.

Also this code should be transferred from Arduino IDE to ESP-01 through CH340 USB programmer without reporting errors.

Does any know what should i add to existing code that works, to be able to read sensor data on Adafruit page or does any knows where to find complete code for this?

Thanks in advance.

I've deleted/merged your other cross-post @neznamnista.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Did you look at the Adafruit IO documentation? Right there in the "Adafruit IO Basics" they have a tutorial "Adafruit IO Basics: Temperature & Humidity":

Yes, it's for the DHT22, but adapting the code to DHT11 is a matter of a tiny change to a single line of the code.

Yes i was there but there is no code how to send data from dht11 to adafruit using CH340 USB programmer

Adafruit IO is in the cloud. That means you need to send it data over the Internet. The only way you could send the data through the CH340 is if you had some application running on your computer that receives the serial data from the ESP8266 and then sends it to Adafruit IO via the API:

But why do that when your ESP8266 can send the data over the Internet without any need for the computer?

well thanks for your reply
i have no experience in this
i wanted to create gauges for humidity and temperature and also for esp8266 relay to be everything on one place

main reason is to have dashboard on the phone (android) to have everything (esp8266 relay, dht11 and sonoff basics) on one place and to be free of course

do you have any suggestion how to do that?

Sure, just use your ESP8266 to send the data over the Internet to Adafruit IO.

Maybe I'm missing something. Why do you want to use the CH340 instead of WiFi to send the data?

No my friend, i dont want to use CH340 instead of ESP8266

i use CH340 for transferring data (programming) from arduino IDE ( on PC) to ESP-01 which i put on ch340

after transffering, i put esp-01 on esp8266 DHT11 and want to see data on adafruit io.

thats my plan

OK, sounds good. Just follow that tutorial I linked above and you should be set.

To use it with DHT11 instead of DHT22, just change this line:

DHT_Unified dht(DATA_PIN, DHT22);


DHT_Unified dht(DATA_PIN, DHT11);

can you paste it here the whole code with those changes not to make any mistake?

i cant find the whole code on internet, only found code for sending data from DHT11 to Web

and if i found code for this, it wasnt for CH340, and errors were showed

thats why i need help for the whole code that is working and is able to send data from DHT11 to Adafruit


The code is one of the examples of the Adafruit IO Arduino library. You can get it, and the required dependencies by doing this:

  • (In the Arduino IDE) Sketch > Include Library > Manage Libraries
  • Wait for the download to finish.
  • In the “Filter your search…” box, type “Adafruit IO Arduino”.
  • Click on “Adafruit IO Arduino by Adafruit”.
  • Click the “Install” button.
  • Wait for the installation to finish.
  • In the “Filter your search…” box, type “DHT sensor library”.
  • Click on “DHT sensor library by Adafruit”.
  • Click the “Install” button.
  • If you’re using Arduino IDE 1.8.10 you should now see a dialog asking you whether you want to install the dependencies. Click the “Install all” button.
  • Wait for the installation to finish.
  • In the “Filter your search…” box, type “Adafruit MQTT library”.
  • Click on “Adafruit MQTT Library by Adafruit”.
  • Click the “Install” button.
  • Wait for the installation to finish.
  • In the “Filter your search…” box, type “ArduinoHttpClient”.
  • Click on “ArduinoHttpClient by Arduino”.
  • Click the “Install” button.
  • Wait for the installation to finish.
  • Click the “Close” button.
  • File > Examples > adafruitio_15_temp_humidity

Here’s the modified code:

// Adafruit IO Temperature & Humidity Example
// Tutorial Link:
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016-2017 Adafruit Industries
// Licensed under the MIT license.
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"

/************************ Example Starts Here *******************************/
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

// pin connected to DH22 data line
#define DATA_PIN 2

// create DHT22 instance
DHT_Unified dht(DATA_PIN, DHT11);

// set up the 'temperature' and 'humidity' feeds
AdafruitIO_Feed *temperature = io.feed("temperature");
AdafruitIO_Feed *humidity = io.feed("humidity");

void setup() {

  // start the serial connection

  // wait for serial monitor to open
  while(! Serial);

  // initialize dht22

  // connect to
  Serial.print("Connecting to Adafruit IO");

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {

  // we are connected


void loop() {

  //; is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  //, and processes any incoming data.;

  sensors_event_t event;

  float celsius = event.temperature;
  float fahrenheit = (celsius * 1.8) + 32;

  Serial.print("celsius: ");

  Serial.print("fahrenheit: ");

  // save fahrenheit (or celsius) to Adafruit IO


  Serial.print("humidity: ");

  // save humidity to Adafruit IO

  // wait 5 seconds (5000 milliseconds == 5 seconds)


Make sure to set your Adafruit IO user name and key and your WiFi router’s SSID and password in the “config.h” tab.

thank you so much

tomorrow i will add this to my esp-01 and will try and will tell you the result

thanks a lot Pert

ok, as i told
i put esp-01 on CH340 and add code you sent me but when i tried to compile it it says

exit status 1
Error compiling for board Generic ESP8266 Module.

It says much more than that. “exit status 1” is just the generic error message that only tells us something went wrong. There are a near infinite number of possible causes of this error. You need to scroll the black console window at the bottom of the Arduino IDE window up to see the specific error messages that will tell you what went wrong.

Please do this:

  • When you encounter an error, you’ll see a button on the right side of the orange bar “Copy error messages” in the Arduino IDE (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button…
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
  • Press “Ctrl + V”. This will paste the error between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the text exceeds the forum’s 9000 character limit, save it to a .txt file and post it as an attachment. If you click the “Reply” button here, you will see an “Attachments and other settings” link.

Pert and GM

I made mistake, i didnt install library ArduinoHttpClient by Arduino as Pert told

now everything works

i just tried to change F to C in code and i did works

what i see as a problem now is that temperature shows 27 C in room where is 23

is there any solution?

p.s. Pert you are the boss, thanks a lot

You're welcome. I'm glad to hear it's working now!

A common cause of temperature sensors reading higher than room temperature is local heating from electrical components near to the sensor. The solution is to mount the sensor away from any sources of heat. The biggest source of heat usually is the voltage regulator, but the microcontroller and other components will also generate heat.

thanks again pert and i am also glad that is working now

now i opened new problem with relay…you can put eye on it if you have time…i am sure that you know where is the catch :wink:

p.s. see att. there is a pic of your code