
Then, we read data from the DHT11 sensor, print the value of the temperature & humidity on the Serial port. You can see that all the measurement part is contained inside the loop() function, which makes the code inside it repeat every 2 seconds. Wait a few seconds between measurements. Read temperature as Celsius float t = dht.readTemperature() Reading temperature and humidity float h = dht.readHumidity() This is the complete code for this part: // Libraries # include "DHT.h" // Pin # define DHTPIN 5 // Use DHT11 sensor # define DHTTYPE DHT11 // Initialize DHT sensor DHT dht (DHTPIN, DHTTYPE, 15) Here, we will simply print the value of the temperature inside the Serial monitor of the Arduino IDE. Again, remember that we are using the Arduino IDE, so we can code just like we would do using an Arduino board. Make sure that you connected everything according to the instructions above, or you won’t be able to continue. This is the final result, not showing the USB-to-Serial FTDI converter: Then, connect the left pin of the sensor to the 3.3V pin of the ESP8266, the right pin to GND (blue power rail), and the pin next to VCC to the GPIO5 pin on your ESP8266 board. Once this is done, simply insert the DHT11 sensor on the breadboard. First, place the Adafruit ESP8266 board on the breadboard. We are first going to see how to configure the hardware to use the ESP8266 board. On your Raspberry Pi, you will also need to have Node.js installed. You can install it from the Arduino library manager, that you can access from Sketch>Include Libraries>Manage Libraries inside the Arduino IDE. You will need to have the latest version of the Arduino IDE installed.

This is a list of all the extra components that will be used in this chapter: I used a DHT11 sensor, which is cheap, very easy to use & that will allow us to measure the ambient temperature & humidity.

You will also need a fully configured Raspberry Pi board, with the Raspbian operating system installed on it. Let’s start!įor this project, you will of course need an ESP8266 chip. Here, I used the Adafruit ESP8266 board. The nice thing is can you can apply this in several other projects, to make the Raspberry Pi the ‘hub’ of your home, with several ESP8266-based devices connected to it. The Raspberry Pi will then access this data via WiFi, and display it graphically. To do so, we will run a simple web server on the ESP8266 chip. However, here, we are actually going to grab that data from a Raspberry Pi, and make the Pi display the data on a simple graphical interface. We will connect a DHT11 sensor to an ESP8266 board, and access the data via WiFi. In this project, we are going to make a typical home automation project: a WiFi weather measurement station.
