Embedded device¶
Hardware overview¶
Sending and receiving data¶
The data which is measured by the DHT11 sensor, is being retrieved and saved in de variables temperature and humidity. Then, the request is being prepared to send the measured data to the API endpoint. After that, the GET-request is being made and the data is send to the database.
// Measure temperature and humidity from DHT11
float temperature = dht.getTemperature();
float humidity = dht.getHumidity();
// Sent the data to the back-end
WiFiClient client;
HTTPClient httpClient;
// Prepare request to server
httpClient.begin(client, "http://82399e9bb85a61.lhrtunnel.link/api.php?temperatureC_inside=" + String(temperature) + "&temperatureC_outside=14&humidity_inside=" + String(humidity));
// Make GET-request
httpClient.GET();
// Get response from GET-request
String payload = httpClient.getString();
Input¶
The embedded device contains two input types, a pushbutton and the DHT11 temperature-humidity sensor. The data which the DHT11 sensor measures is send to the backend of the website and is stored in the database. Then, the data from the database is fetched and displayed on the website.
Output¶
Besides the website there are also two other output types on the physical product. First, there is a LED light which can be turned on by pressing the button. Secondly, there is a LED strip with three light, of which two of them are used. The first LED light shows whether the temperature is right or not and the second light does that for the humidity. There are three colors the LED lights mey show. Blue is shown when the temperature is too low, of the humidity percentage is too low. Green is shown when the values are good and red is shown when the temperature is too high or the humidity is too high.
Studies show the ideal temperature is between 19 and 23 degrees Celsius and the ideal humidity is between 40 and 60 percent. These are the values I use to determine whether the values are good or bad.
WiFi¶
In this part of the code I made a connection to WIFI. If the user want to change the WIFI network, they have to change the networkname and the password in the project_iot.ino file.
// Connecting to WIFI
WiFi.begin("iotroam", "CJx2iaRyUt");
// Keep in while-loop while the device is not connected to your accesspoint.
while (WiFi.status() != WL_CONNECTED) {
delay(delay); // Waiting on connection...
}
Wiring diagram¶
In this diagram you can see how to physically build the hardware part of this project. If you want to know what exact parts I used building this project, see the Bill of materials.
Bill of Materials¶
To build the weather station, I used several hardware parts. If you also want to build my project, you will find all the necessary parts below, including the costs and a link to a website to purchase the part immediately.