Band 4 · Night Guard
Swap The room monitor
A sensor that hands you degrees and a percentage, already meant. The one time somebody else did the calibrating.
Sketches for this project
Every file opens with a plain-English header saying what it does and how to wire it, hole by hole.
The one sensor that answers in units
Every other sensor in this course hands you a number between 0 and 1023 and leaves the meaning to you. The knob, the light sensor, the rain plate: all of them make you go and find out what their numbers mean in your room.
This one hands you degrees. And a percentage. Already meant.
That is worth building precisely because it is the exception, and because of the question it raises.
analogRead, never uses map, and never meets the division trap in Part 9. Those are three of Band 4's four big ideas, and you will be asked about them in Check yourself. So do Parts 1 to 9 first and do not skip them. This page replaces Part 10, the night guard, and nothing earlier. What it adds instead is the question the night guard cannot ask: what do you do when somebody else has already decided what a number means?Somebody else did the calibration, and you should still check it
Inside the DHT11 is a small sensor and a small chip. The chip does what you did by hand in the night guard: it takes a raw electrical reading and turns it into a number that means something, using a table put there at the factory.
So the calibration did not disappear. It moved somewhere you cannot see, done by somebody you cannot ask, for a room that is not yours.
That is a reason to check it, not a reason to relax. This build ends with you putting it next to a real thermometer and writing down the difference.
Three wires
25 mina to e, so use the pair of rails along the bottom edge, the ones nearest row a. Band 4's own builds used the top pair, so move your two rail wires down: + rail to the Arduino's 5V pin, − rail to a GND pin, both on the bottom pair. On most boards the top rails and the bottom rails are not joined to each other, and mixing them means nothing works and nothing looks wrong.Which DHT11 have you got?
Count the pins on yours. This decides whether you need a resistor.
A module. The resistor it needs is already on the board.
→ Push its three pins into a25, a26, a27. Its pins fill those holes, so every wire goes into row b of the same column: b25, b26, b27. Then, reading the printing on your own board rather than counting positions: the ground pin, marked -, G, GND or −, gets its wire to the − rail; the power pin, marked +, V, VCC or 5V, to the + rail; and the data pin, marked S, OUT, DATA or DAT, to pin 4.
Different factories use different letters for the same three pins. Read the printing on your board rather than counting positions, because the order is not the same on every module either.
The raw part. It needs a 10k resistor that the module version has built in.
→ Hold it with the holes facing you and push its four pins into a30, a31, a32, a33, left to right. Then: wire b30 to the + rail, wire b31 to pin 4, nothing at all in column 32, wire b33 to the − rail. Finally the 10k resistor from c30 to c31. Note the letters: b30 holds a wire so the resistor goes in c30, because a hole takes one leg.
The 10k resistor holds the data line up when nobody is talking,
c because row b already holds a wire.
| Part | Wiring |
|---|---|
| Green light | long b3, short b4; resistor a3 to a1; wire b1 to pin 7; a4 to − rail |
| Red light | long b7, short b8; resistor a7 to a5; wire b5 to pin 8; a8 to − rail |
| Power | One wire from the + rail to the Arduino's 5V pin |
| Ground | One wire from the − rail to a GND pin |
Install the library. Tools, then Manage Libraries, search SimpleDHT, install the one by Winlin. Once, on one machine.
No such file or directory. Nothing is broken. On any machine that does have a connection, search for the library, download it as a .zip, and carry it here on a phone or a USB stick. Then use Sketch, then Include Library, then Add .ZIP Library, and point it at the file. If your kit came with a folder of libraries on a stick or a disc, it is already in there. Do this before you wire anything, because without the library nothing you build can be tested.Upload b4_07_room_monitor.ino and open the serial monitor at 9600.
WARNING from the very first readingNothing is wrong, and near the coast this is likely. The sketch ships with tooHumid = 80, and in Aiyinasi the air sits above that most of the day. Open the sketch, set tooHumid to 95 for now so you can see the fine case and the green light working, then set both numbers properly from your own room in the Measure section below. Choosing those numbers is this build.fine. The green light is on. Both numbers are whole numbers and the temperature should be somewhere plausible for the room you are sitting in.delay(2000) at the bottom of loop is still there.Breathe on it, gently, from a few centimetres away, and watch.
Check the factory's work
30 minYou have been handed a number in units. Now find out whether to believe it.
Put it next to any other thermometer for five minutes: a wall thermometer, a kitchen one, the weather reading on a phone, or somebody else's DHT11 if a classmate built one. Working alone, a phone's weather reading for your town plus one indoor thermometer is enough for the table; note that the phone's number is for outside, and say in your log why that makes it a weak comparison rather than a useless one.
| What | Says | Difference from yours |
|---|---|---|
| Your DHT11 | — | |
| Another thermometer | ||
| Somebody else's DHT11 |
Now choose your two thresholds, tooHot and tooHumid, by measuring your actual room over a day rather than by guessing.
Read it in the morning, in the afternoon and at night. Write the three pairs down. Then pick numbers that would have warned you at the right moment and not before.
Two questions for your log
- The night guard made you invent the meaning of a number. This build handed you the meaning. Which device would you trust more in a place you had never been, and why?
- This sketch has only one threshold for each value, not two. Given what the rain alarm and the night guard both taught you, what will happen when the room sits exactly on 32 degrees? What would you change?
Something to check yourself against
1. There is no right answer, but there is a better argument, and it is probably not the one you expect. The DHT11 is more convenient in a place you have never been, because it arrives already meaning something. The night guard is more trustworthy, because you calibrated it in the room it is standing in and you know exactly what it was compared against. The DHT11's factory table was made for an average room by somebody who has never seen yours. So: trust the DHT11 to be roughly right anywhere, and trust the night guard to be exactly right in one place. Say which of those your device actually needs, and you have answered the question properly.
2. The warning will flicker on and off as the reading wobbles between 31 and 32, because there is only one line and the reading sits on it. It needs two numbers: warn above 32, clear below 30. That is the same fix as wetLevel and dryLevel, and the same fix as the deadband in Band 6. Adding it is the best Bronze task on this page, and it is deliberately left undone in the sketch so that you can find it.
Make it yours
35 min- Bronze
- Fix the flickering threshold you found in question 2, using two numbers instead of one for both temperature and humidity.
- Silver
- Remember the highest and lowest temperature since it was switched on, and print all four numbers every time. Then leave it running for a whole day and see what the room actually did.
- Gold
- Work out the heat index, which is how hot it feels once the humidity is high, and warn on that instead of on temperature. If you cannot get online, use this rule of thumb, which is close enough below about 40 degrees: add one degree for every ten percentage points of humidity above 40. So 32 degrees at 80 percent humidity feels like about 36. If you can get online, find the real formula, use it, and be honest in your log about how much of it you understood. Either way, say why a device that warns on how it feels rather than on the temperature might be the more useful one in Aiyinasi.
You still owe Band 4 the same evidence
This Swap replaces the night guard. To claim Band 4 you still need:
- A video of it working, including a warning happening
- Your comparison table against another thermometer, and your day's readings
- Your two chosen thresholds and a sentence on why those numbers
- Your build log
- Both
analogReadandanalogWritein your glossary, with their different ranges. This build uses neither, so take them from Parts 5 to 9, which you did before coming here - Five or six correct answers in Part 14, the Check yourself questions, including question 6
The Check yourself questions are about analogRead and the 0 to 1023 range, which this sensor never gives you. Answer them anyway. If you cannot, spend twenty minutes with the light sensor and the knob before claiming the band, because that range is the thing almost every other sensor you meet will speak in.
Ship it
One video under sixty seconds, and one post of five lines. You built something different from the person next to you, so your video is the one nobody else in the room can post. Say in the post which build you chose and why — that choice is itself worth a line.
The four shots: three seconds of the thing still, fifteen of you doing something to it, fifteen of it responding all the way to the end, and ten of your measurement or the thing that went wrong first.
Show your work has the template and the three checks to
make before anything goes public. Tag it #BozomaBuilds.