Home IoT Hub Series · 06
[Part 6] Should I open the window? Measuring outdoor temperature with a balcony IoT sensor
Measure balcony or outside temperature with a DHT22 sensor node.
This node measures outside or balcony temperature. It reuses the simple DHT22 wiring from the living room node, so the build is mostly copy, paste, and place.
Mount it where rain cannot directly hit the board. A shaded balcony wall or window-side enclosure is better than direct sunlight.
![[Part 6] Should I open the window? Measuring outdoor temperature with a balcony IoT sensor hero image](/iot-lab/assets/outside-temperature-dht22-hero.png)
This article is part of the Home IoT Hub system connected to the central NodeMCU server built in Part 2: Building the Brain. This outdoor node measures balcony or window-side temperature so it can be compared with indoor readings. The collected data is sent over the local
IoT_Hub_Net network and updates slot 3 for outdoor temperature on the central server (/set?no3=value), becoming part of the decision pipeline for the 20-channel smart-home controller.Parts and cost
| Part | Qty | Unit price |
|---|---|---|
| Wemos D1 Mini (ESP8266) | 1 pc | $1.50 |
| DHT22 temperature/humidity sensor | 1 pc | $1.50 |
| Jumper wires 3 pc | — | — |
| Total | $3 |
Pin wiring
| Sensor / module | Board pin |
|---|---|
| VCC | 3.3V |
| DATA | D1 (GPIO5) |
| GND | GND |
Full code
#include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #include <DHT.h> const char* ssid = "IoT_Hub_Net"; const char* password = "iothub1234"; const char* hubURL = "http://192.168.1.1"; #define DHTPIN 5 #define DHTTYPE DHT22 #define INTERVAL 30000 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); dht.begin(); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.print("Connecting to IoT_Hub_Net"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nConnected! IP: " + WiFi.localIP().toString()); } void loop() { float temp = dht.readTemperature(); if (isnan(temp)) { Serial.println("Read failed"); delay(2000); return; } Serial.print("Outside: "); Serial.print(temp); Serial.println(" C"); WiFiClient client; HTTPClient http; String url = String(hubURL) + "/set?no3=" + String(temp); http.begin(client, url); http.GET(); http.end(); Serial.println("HTTP -> " + url); delay(INTERVAL); }
Upload and check
Connect the Wemos D1 Mini to the PC with a USB data cable, select the ESP8266 board and port in the Arduino IDE, upload the sketch, then open Tools → Serial Monitor and set the baud rate to 115200.
Serial Monitor
After uploading, open Tools → Serial Monitor in the Arduino IDE and set the baud rate to 115200. The following is an example Serial Monitor flow for checking normal operation. This is not a real screenshot. It shows the expected flow for sending outdoor temperature to slot 3.
[BOOT] Home IoT Node #06 - Outside temperature [WIFI] RSSI=-61 dBm, connected [SENSOR] outside_temp=29.1C humidity=64.0% [FILTER] sunlight_guard=PASS, value accepted [HTTP] GET /set?no3=29.1 [HUB] 200 OK - slot no3 updated [POWER] usb extension mode, next sample in 300000 ms
- If
Connectedorconnectedappears, the Wi-Fi step passed. - If
HTTP 200or200 OKappears, the value reached the brain server. - If the value does not update, check both the slot number in the URL and the sensor wiring.
Build notes
- Compare the value with the living room temperature. If both values are almost the same, the sensor may still be indoors or too close to the window.
- Power on the hub brain first so the node can join
IoT_Hub_Net. - Use the same slot number written in the source code.
- Open the serial monitor at 115200 baud and confirm
HTTP 200. - If the value does not appear on the hub, recheck wiring, GPIO number, and Wi-Fi connection.
Getting the Most Out of DHT22 for Outdoor/Veranda Temp & Humidity
A single indoor sensor already makes a home smarter, but the moment you add a DHT22 outdoors (veranda or outside the window), the possibilities change entirely. The point isn't one indoor reading, it's being able to see the indoor-vs-outdoor difference. Wiring, pinout, code, and slot numbers were covered earlier, so here we focus only on where to put it and what to do with it.
Troubleshooting checkpoints
The node code can look short, but real home installation is affected by placement, power, Wi-Fi quality, and sensor noise. Check these points before letting the node become a decision input for the brain server.
| Symptom | Likely cause | Field fix |
|---|---|---|
| Readings jump above 40°C at noon | Direct sunlight heats the sensor housing | Use a white shade or simple Stevenson-screen style cover and place it in shade away from wall radiant heat. |
| Values become odd after rain | Water droplets on the sensor membrane disturb the reading | Use a weather cover with lower ventilation holes, not a fully sealed box, and block direct rain from above. |
| The node reboots on cold mornings | A power bank voltage drops in low temperature or USB power is weak | For outdoor nodes, route a Micro USB extension through the window gap and use steady power when possible. |
| Wi-Fi often disconnects near the balcony | Window frames and walls attenuate 2.4 GHz signals | Place the node on the same side as the hub AP/router and avoid sending failed samples to the server. |
How to Use It (Practical Scenarios)
- Ventilation timing: Get an alert to open windows only when outdoor humidity is lower than indoors, so you don't accidentally let more moisture in during the rainy season.
- Condensation/mold prediction: Compare indoor temperature against the outdoor dew point to warn of window and wall condensation in advance. Especially useful against mold in north-facing rooms in winter.
- Laundry-drying index: Use outdoor temperature and humidity to judge whether clothes hung outside will actually dry. An alert to switch to indoor drying above 85% humidity is genuinely handy.
- Protecting veranda plants: Log the pre-dawn minimum in winter so you can bring pots inside before they cross their cold-damage threshold.
- AC condenser / HVAC efficiency: An overheated area around the outdoor condenser unit hurts efficiency, so detecting abnormal heat relative to the outdoor temperature flags an airflow problem.
Where to Install It (and Where Not To)
- A shaded north wall or under the eaves is ideal. No direct sun all day means you measure air temperature, not a sun-baked case.
- Mount it 1.2-1.5m off the ground and at least 5cm off the wall to avoid radiant wall heat and ground heat.
- Avoid: direct sunlight, the AC condenser's exhaust, a railing where rain blows in, and anywhere right in front of a vent or kitchen hood outlet. All give readings that differ from the real outside air.
Field Tips & Cautions
- Waterproof it, but never seal it airtight: The DHT22 is not waterproof. Enclose it in a louvered "Stevenson screen" style shelter: covered on top, vented on the bottom and sides. Fully sealed, humidity will never change.
- Expect response lag: Outdoors, wind and radiation make readings swing. Smooth them with a 5-10 minute moving average to cut false alarms.
- Accuracy at extreme cold: The official range goes to -40C, but below -20C humidity error grows. Treat midwinter lows as rough references only.
- Morning condensation: When dew forms on the sensor surface, humidity sticks at 99% for a while. That's normal recovery, not a fault, so distinguish "persistent 99%" from "temporary 99%."
- Cable length: A long run outdoors causes voltage drop and jumpy values. Beyond 3m, lower the pull-up resistor slightly from 4.7k or use shielded cable.
Frequently Asked Questions
Q. Outdoor humidity always reads 99%. Is it broken?
In the morning it's usually condensation. If it's still 99% an hour or two after sunrise, water has pooled inside the case, so fix the ventilation.
Q. I bought a waterproof housing and sealed it completely, but humidity won't change.
Of course, humidity needs air to flow through to be measured. Add a vent hole at the bottom or use a breathable membrane (Gore-Tex type).
Q. My indoor and outdoor readings differ a lot, is that normal?
It's normal, and that difference is the whole value of this setup. Condensation prediction and ventilation decisions all come from the indoor-outdoor gap.
This article is part of the 20-channel Home IoT system built from the Part 2 central brain server and the distributed edge nodes in Parts 3-19. Use this map to check the slot and sensor flow across the series.
[Part 1] Home IoT Hub overview[Part 2] Central brain server · slots 1-20[Part 3] Stop guessing room comfort · slots 1/2[Part 4] Did I close the door? · slots 9[Part 5] Is the fridge really cooling? · slots 12[Part 6] Should I open the window? · slots 3[Part 7] Stop bathroom mold before it starts · slots 19[Part 8] Is the boiler actually running? · slots 5/17[Part 9] Did I leave the gas stove on? · slots 6[Part 10] Get warned before gas smell becomes obvious · slots 7[Part 11] Catch flame signs while away from home · slots 8[Part 12] Is bad air making you foggy? · slots 13/14[Part 13] Why is the power bill so high? · slots 15[Part 14] Is water leaking, and how much are we using? · slots 16[Part 15] Do not leave windows open in the rain · slots 18[Part 16] Are the lights off and the door locked? · slots 11/10[Part 17] Control the air conditioner from the IoT hub · slots 4[Part 18] Is the dog bowl empty? · slots 20[Part 19] Cool the room only when someone is there · slots 1/4[Part 20] The house finally fits on one screen · slots all