Reading sensor data is an essential function of the ESP8266. You can do that using MicroPython. To demonstrate it, we are going to read the temperature and humidity from the DHT11 sensor using MicroPython.
In this tutorial, you will need an ESP8266 board, a USB cable, and a few other components, which include:
DHT11 temperature/humidity sensor (https://www.sparkfun.com/products/10167)
10 kΩ resistor
Breadboard
Jumper wires
Mount the ESP8266 board and the DHT11 sensor onto the breadboard. Connect a 10 kΩ pull up resistor to the DHT11 data pin and connect the pin and GND pin to the 3V pin and GND pin of the ESP8266 board, respectively. Finally, connect the data pin of the DHT11 to GPIO 5 of the ESP8266 board. Use jumper wires to do the connections.
The setup is shown in the following diagram:
Note
Refer back to Chapter 2, Your First ESP8266 Projects to confirm the DHT11 pin configuration.