![]() ![]() If you’re using a DHT11 sensor, uncomment the next line, and comment the previous one: sensor = dht.DHT11(Pin(14))ĭon’t forget to add your network credentials on the following lines: ssid = 'REPLACE_WITH_YOUR_SSID' You also need to initialize the sensor by creating a dht instance on GPIO 14 as follows: sensor = dht.DHT22(Pin(14)) Import the Pin class from the machine module and the dht module to read from the DHT sensor. Import the necessary libraries to create a web server. So, we’ll just take a look at the relevant parts for this example. We’ve covered in great detail the web server code in a previous tutorial. Copy the following code to your boot.py file. boot.pyĬreate a new file in your MicroPython IDE. The main.py file contains the code that runs the web server to serve files and perform tasks based on the requests received by the client. This includes importing libraries, network credentials, instantiating pins, connecting to your network, and other configurations. Wire the DHT22 or DHT11 sensor to the ESP32 development board as shown in the following schematic diagram.įor this project you’ll need a boot.py file and a main.py file. The boot.py file contains the code that only needs to run once on boot. You can use the preceding links or go directly to /tools to find all the parts for your projects at the best price! DHT11 or DHT22 temperature and humidity sensor.Here’s a list of parts you need to build the circuit: ![]() You need to use a 10k Ohm pull-up resistor. To follow this tutorial you need to wire the DHT11 or DHT22 sensor to the ESP32 or ESP8266.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |