Before you start to wire sensors to the microcontroller, I would explain what’s the breadboard and how does it work, because I used it to wire my sensors to the microcontroller.
A breadboard is a tool used in electronics to build and test circuits without soldering. It's like a reusable platform where you can connect electronic components, such as sensors and wires, to create circuits quickly and easily.
It has rows and columns of holes, with metal strips underneath that connect them together.
Note how all holes in the selected row are connected together, so the holes in the selected column. The set of connected holes can be called a node:
To interconnect the selected row (node A) and column (node B) a cable going from any hole in the row to any hole in the column is needed:
Breadboards are great because they allow you to experiment with different circuit designs without needing special tools or making permanent connections.
You can rearrange components like sensors and microcontroller and try out different ideas until you find the one that works best.
Connecting a DHT11 sensor to an ESP32 is pretty easy. Begin by placing the ESP32 on your breadboard, making sure that each side of the ESP32 is on a different side of the breadboard.
Place the sensor on your breadboard. Connect the sensor’s DATA pin to any of the free GPI pins (I used pin 16). Check the PINOUT diagram of ESP32 to find out the name of the pins.
Continue with connecting the VCC pin to the ESP32’s 5V or 3.3V pin, and finally, the GND pin to the GND pin of the microcontroller.
Usually you have to download the sensor’s library and upload it to the microcontroller, as you will do with the two other sensors. Luckily for you, the DHT11’s library is included in recent versions of MicroPython, so you already have this library on your microcontroller.
To test if sensor is working, connect to the microcontroller and run the following commands in the terminal:
1import dht
2import machine
3d = dht.DHT11(machine.Pin(16)) #if you connected the sensor's DATA pin to another GPI pin, change 16 with the number of that pin
4d.measure()
5d.temperature() #you should see the temperature as the output of this function
6d.humidity() #you should see the humidity as the output of this function