This project involves using an ESP32 microcontroller to read temperature and humidity data from a DHT11 sensor. The data is sent to a specified server endpoint, and commands can be received to display messages on an I2C LCD.
- ESP32 Development Board
- DHT11 Temperature and Humidity Sensor
- I2C LCD Display (16x2)
- Breadboard and Jumper Wires
- Power Supply (USB cable)
- PlatformIO: For writing and uploading code to the ESP32.
- Flask: For running the server scripts.
-
Connect the DHT11 Sensor:
- VCC to 3.3V on the ESP32.
- GND to GND on the ESP32.
- DATA to GPIO 4 on the ESP32.
-
Connect the I2C LCD:
- SDA to GPIO 2 on the ESP32.
- SCL to GPIO 3 on the ESP32.
- VCC to 3.3V on the ESP32.
- GND to GND on the ESP32.
-
Clone the Repository: Clone this repository to your local machine.
git clone https://github.com/tashakid/esp32_dht11.git cd esp32_dht11
-
Install Required Libraries: Ensure the following libraries are included in your
platformio.ini
:lib_deps = adafruit/DHT sensor library adafruit/Adafruit Unified Sensor bblanchon/ArduinoJson @ ^6.21.3 marcoschwartz/LiquidCrystal_I2C@^1.1.4
-
Configure WiFi and API Endpoint: Create a
config.h
file in thesrc
directory with the following content:#define WIFI_SSID "Your_SSID" #define WIFI_PASSWORD "Your_Password" #define API_ENDPOINT "URL endpoint"
-
Build and Upload the Code: Use PlatformIO to build and upload the code to your ESP32:
pio run pio run --target upload
-
Open Serial Monitor: After uploading, open the serial monitor to view the output:
pio device monitor
-
Install Flask: Make sure you have Flask installed in your Python environment:
pip install Flask
-
Run the Server Script: Place the
server_send.py
file in your Lightning Studio IDE environment. Run the script:python server_send.py
This will start the server and listen for incoming requests.
- Ensure the ESP32 is connected to WiFi and is publishing data.
- Check the serial monitor for any errors.
This project allows you to monitor temperature and humidity data from a DHT11 sensor and display messages on an I2C LCD. The integration with a Flask server provides a way to send commands to the ESP32.