I connected the ESP to my Arduino UNO and uploaded a cut-down version of the example code from the dhtESP library:
#include "DHTesp.h"
#ifdef ESP32
#pragma message(THIS EXAMPLE IS FOR ESP8266 ONLY!)
#error Select ESP8266 board.
#endif
DHTesp dht;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)\tHeatIndex (C)\t(F)");
String thisBoard= ARDUINO_BOARD;
Serial.println(thisBoard);
// Autodetect is not working reliable, don't use the following line
// dht.setup(17);
// use this instead:
dht.setup(12, DHTesp::DHT11); // Connect DHT sensor to GPIO 15
}
void loop()
{
delay(dht.getMinimumSamplingPeriod());
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();
Serial.println(dht.getStatusString());
Serial.println(humidity, 1);
Serial.println(temperature, 1);
}
The connections I made are as follows:
Arduino ESP
3.3V ---------------Vcc, Rst, CH_PD/EN
GND ----------------GND, GPIO0, GPIO15,
Reset (connect to the Arduino's ground)
TX ------------------TXD0
RX ------------------RXD0
Before starting I had uploaded the bareMinimum example sketch to the Arduino.
Then the DHT11 was connected to GPIO12 of the ESP, and the code was uploaded.
It worked!
Next, I'll try and connect it to the MQ gas sensor.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.