91ɫƬ

Make a rain alarm with copper tape and a BBC micro:bit

This simple but clever rain sensor means your laundry will never get caught in the rain again

rain sensor

WE CAN’T control the weather, but tech can at least give us a heads-up when the heavens open so we can bring in the washing or anything else left in the garden. We can do this with a digital rain sensor.

Grab a CD case and some copper tape – useful stuff that both conducts electricity and sticks to a surface. Start by fixing strips of tape to two opposite sides of the case, extending one end of each strip beyond the edge of the case and folding them over on themselves to make two tabs. We will attach crocodile clips to these to connect to a BBC micro:bit later.

Next, stick strips perpendicular to the initial ones. These should have a narrow gap between them lengthways, and each should overlap with just one of the two initial strips. Alternate which of the side strips overlaps to create a pattern that looks like two combs with interlocking teeth.

By the way, if your tape’s adhesive isn’t conductive, you will need to fold the ends of the overlapping parts to ensure each strip’s copper side is in contact.

Connect one tab from the case to micro:bit’s pin 0 and the other to ground. The idea is that if a raindrop falls on your sensor, it will bridge the gap between two strips that lead to opposite sides, completing a circuit between pin 0 and ground. We have essentially made a rain button. The large surface area of the CD case increases the chance of detecting raindrops, however sporadic.

Now for the code to tell your phone when rain is detected. In the MakeCode editor, go to “Advanced” then “Extensions” and click on “devices”. This will add a new set of blocks. These ones let you interact with another device, such as a smartphone.

Grab an “if” from “Logic”, then slot in place of “true” a “pin p0 is pressed” from “Input” – this checks if the circuit between p0 and ground is complete. Slot the whole thing into “forever”. Next, go to the “Devices” menu and grab “raise alert to”. Add this to “forever”, then use the drop-down menu to select vibrate or a ringtone, whichever you prefer.

Now pair the micro:bit with your phone to get the notification. to your phone, open it and follow the directions for pairing a micro:bit. You can even send the code from your phone to the micro:bit via Bluetooth. This can be useful if you have trouble connecting. If you do, try pairing the micro:bit again and “flashing” the code from your phone within the app.

Put the rain sensor outside and either stash the micro:bit in a waterproof box or keep it inside and run long cables to it. Now you can relax indoors, at least until the first drop of rain. With your spare kit, you could test the theory that copper tape protects plants from slugs too.


New stuff you need

Old CD case

Copper tape (ideally with conductive adhesive)

For next week

Second micro:bit and battery

environmental sensor


Next in the series

1 Moisture-sensing plant

2 Moisture and temperature-sensing plant

3 Plant auto-waterer

4 Tweeting wildlife cam

5 Pest scarer

6 BBQ thermometer

7 Rain alarm

8 Mini weather station Is it warm and how’s the humidity outside?

9 & 10 Remote controlled pest-proof bird feeder parts 1&2

To download a printable version of this page click here

Email:maker@newscientist.com

Topics: Electronics