Skip to content

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.

Wiring diagram

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.

SKU Manufacturer Part name Part description Part quantity Part cost Example url
000071 Ever-muse Breadboard MB-102, 830 points 1 €4,00 https://www.tinytronics.nl/shop/nl/gereedschap-en-montage/prototyping-toebehoren/breadboards/breadboard-830-points
000902 WEMOS Wemos D1 Mini Pro 1 €8,00 https://www.tinytronics.nl/shop/nl/wemos-d1-mini-pro-esp8266-cp2104
000072 Unbranded Jumper wires Male-to-male, 65 pcs 1 €3,00 https://www.tinytronics.nl/shop/nl/kabels-en-connectoren/kabels-en-adapters/prototyping-draden/dupont-compatible-en-jumper/breadboard-draden-65-stuks-verschillende-maten
000318 Unbranded Resistor 220Ω, 1% tolerance 2 €0,05 https://www.tinytronics.nl/shop/nl/componenten/weerstanden/weerstanden/220%CF%89-weerstand-(led-voorschakelweerstand)
000138 Unbranded Resistor 10KΩ, 1% tolerance 1 €0,05 https://www.tinytronics.nl/shop/nl/componenten/weerstanden/weerstanden/10k%CF%89-weerstand-(standaard-pull-up-of-pull-down-weerstand))
000113 Aosong Electronics Temp. and Humidity Sensor DHT11 1 €2,50 https://www.tinytronics.nl/shop/nl/sensoren/lucht/vochtigheid/dht11-thermometer-temperatuur-en-vochtigheids-sensor
000438 WorldSemi RGB LED Strip WS2812B 1 €12,00 https://www.tinytronics.nl/shop/nl/verlichting/led-strips/led-strips/ws2812b-digitale-5050-rgb-led-strip-60-leds-1m
001204 Unbranded Tactile Pushbutton Switch Momentary 4pin 12127.3mm 1 €0,25 https://www.tinytronics.nl/shop/nl/schakelaars/manuele-schakelaars/printplaatschakelaars/tactile-pushbutton-switch-momentary-4pin-12127.3mm
030601 Unbranded Button cap 12x12x7.3mm, blue 1 €0,15 https://www.tinytronics.nl/shop/nl/componenten/knoppen,-doppen-en-kapjes/knopkapje-voor-tactile-pushbutton-switch-momentary-12x12x7.3mm-blauw
000098 Unbranded LED 5mm, yellow 1 €0,10 https://www.tinytronics.nl/shop/nl/componenten/led’s/led’s/gele-led-5mm-diffuus

Last update: October 10, 2022