Band 4 · Night Guard
Swap The rain alarm
Washing on the line, and a number that goes down when it gets wet. Calibration you cannot avoid doing.
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 question you cannot dodge
Band 4's night guard makes you pick a number for “dark”, and it is possible to fudge it. Set the threshold anywhere near the middle and the lamp does something, and you can convince yourself that was the plan.
This build does not let you. What number counts as wet? A damp finger, three drops, a light shower and a soaking are four completely different readings, and until you have gone and measured them you cannot write a useful line of code.
So this is the same lesson as the night guard, with the escape route closed.
And it surprises everybody the first time
The number goes DOWN when it gets wet.
Dry, the two copper lines on the plate are not joined, so almost nothing flows and the reading sits high, often above 800. Water bridges them, current flows, and the reading falls. A well-soaked plate can read under 300.
In the night guard, dark was also a small number, for a completely unrelated reason. Do not carry either habit anywhere. The only way to know which way a sensor runs is to go and make it happen while watching the number.
Wire it
30 minA0, which is the pin this build needs for the rain sensor. Two wires in one pin is forbidden here as everywhere, and the knob would win: your alarm would follow the knob and ignore the plate, with no error and nothing to tell you.a 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.Only the plate goes anywhere near water. The small board has a chip on it and must stay dry. People drown the wrong half of this sensor every year.
| Part | Goes to | Note |
|---|---|---|
| The sensor board itself | Push its four pins into a25, a26, a27, a28. Its own pins fill those holes, so your wires go into row b of the same columns: b25, b26, b27, and nothing in b28, because DO stays empty. A hole takes one leg, and the five holes in a column are joined underneath. | Read the printing on your board and match each wire to the column its pin is in. The pin order is not the same on every board, so do not count positions. |
Sensor board VCC | the + rail | |
Sensor board GND | the − rail | |
Sensor board AO | pin A0 | The one that gives a number. This is the one you want. |
Sensor board DO | nothing | Leave it empty. See the note below. |
| The plate | the board's two screw terminals or pins | Either way round |
| 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 | |
| Buzzer | long b40, short b42; wire a40 to pin 6; wire a42 to − rail | No resistor. If the legs will not reach two holes apart, use b40 and b43 and move the − wire to a43. |
| Power | one wire, + rail to the Arduino 5V pin | The bottom pair of rails |
| Ground | one wire, − rail to a GND pin | The bottom pair of rails |
| Check this twice before the USB goes in. The + rail wire must be in the pin marked 5V and the − rail wire in a pin marked GND. Swapped, the sensor board is powered backwards and is destroyed in seconds. If any part feels warm after you plug in, unplug at once and check those two wires before anything else. | ||
DO stays empty, and why the little knob on the board is a trapThe board has a small screw on it and a pin marked DO. Together they give you a yes-or-no answer: wet or not wet, with the screw setting where the line is.That sounds easier and it is worse for you. It moves the decision into a screw you cannot see, cannot write down, and cannot explain.
AO gives you the number and makes you own the threshold, which is the entire subject of Band 4. Use AO. Ignore the screw.tone, which needs the kind with a small green circuit board underneath. If yours is the active kind, the solid black one Band 3 asked for, it still works: it beeps at its own single note instead of the rising one. If you would rather it were exact, replace each tone(buzzerPin, ...) with digitalWrite(buzzerPin, HIGH) and each noTone(buzzerPin) with digitalWrite(buzzerPin, LOW), and put a 220 ohm resistor in its pin leg as Band 3 does. Run id_01_which_buzzer.ino if you are not sure which you have.Upload b4_06_rain_alarm.ino and open the serial monitor at 9600, with the plate completely dry.
dry. The green light is on and nothing is beeping.DO rather than AO. DO has already made the decision for you and only ever says yes or no, so analogRead sees either nothing or the full five volts and never a middle. Move the wire one pin. This is the most common fault on this build, and the little screw on the board is what decides where DO flips, which is exactly the decision you are supposed to be making yourself.VCC reaches the + rail and the + rail reaches 5V, then that the − rail really reaches a GND pin.AO wire is loose or has come out, so A0 is floating. You met floating pins in Band 3. A floating pin does not read 0; it reads whatever it feels like, and the drifting is the giveaway.Find your two numbers
30 minThis is the part that matters. Do it properly and write everything down.
Guess first. Before you wet anything, write a guessed reading in the middle column for all six rows. You will be wrong, and being wrong on paper is the point: it is the only way to find out which of your ideas about this sensor were made up. Band 4 asked the same of you in Part 1.
Then fill the table in for real, reading the serial monitor for each state and waiting a few seconds for the number to settle. Keep both sets of numbers.
| State of the plate | Reading | Should this set off the alarm? |
|---|---|---|
| Bone dry | ||
| Breathed on, then wiped | ||
| One drop of water on it | ||
| Five or six drops spread out | ||
| Properly wet, water running off | ||
| Wet, then dried with a cloth |
Now choose wetLevel. Pick a number that sits between the last reading you would ignore and the first reading you would act on.
Then choose dryLevel, and make it noticeably higher. Not one higher. Fifty or a hundred higher.
dryLevel equal to wetLevel and put a single drop right on the boundary. The alarm will start and stop several times a second, because the reading wobbles across the line.With 500 to alarm and 700 to clear, the plate has to genuinely dry out before it goes quiet, and no amount of wobble in between changes anything. You met this in Band 4 with the light threshold and you will meet it again in Band 6 as the deadband. Three bands, one idea.
Put your two numbers in the sketch, upload, and test all six states from your table again.
The honest note about leaving it outside
These plates corrode. Current passing through water eats the copper, slowly, the whole time the board is powered and the plate is wet. A plate left in the rain for a week is a measurably different plate by the end of it, and its readings will have drifted.
That is not a fault. It is what they are, and it is why real rain sensors are built differently and cost more. If you build something permanent from this, plan to re-measure your two numbers every few weeks, and write in your log what you found.
Make it yours
35 min- Bronze
- Add a button that silences the buzzer without disarming the alarm, so the red light stays on. Then say why somebody would want that, in one sentence, thinking about who has to live with the device.
- Silver
- Make it report how wet rather than wet or not: three levels, with a different beep rate for each. Your table already contains the numbers you need.
- Gold
- Make it only power the sensor when it is about to read, by running the sensor's
VCCfrom a spare Arduino pin instead of from 5V, and switching that pin on for a moment before each reading. Then explain in your log why this makes the plate last much longer.
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 the moment it decides
- Your six-row measurement table, which is this band's real deliverable, and your two chosen numbers with a sentence on why
- Your guessed readings for all six states, written down before you measured, next to what you actually found
- Your build log
- Both
analogReadandanalogWritein your glossary, with their different ranges - Five or six correct answers in Part 14, the Check yourself questions, including question 6
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.