快猫短视频

Electronics projects for beginners: Sensors for talking to plants

Ever wanted to know if your plant is happy or sad? A BBC micro:bit and a moisture sensor will get you and your garden plants communicating

Moisture-sensing plant

IN OUR previous 10-week 鈥淗ow to be a maker鈥 series, we went on a tour of the basics, culminating in building an autonomous biscuit-fetching robot. If you missed it, you can catch up online at the address below.

This second series will explore some practical applications of the skills you learned and help you get in touch with plants, wildlife and the great outdoors. Projects will range from a tweeting wildlife camera to a pest-resistant bird feeder. Whether your outdoors is a window box or a wildlife reserve, there will be something for you.

To start off, we are going to enable plants to communicate. My spider plant Marvin is delighted, although he might not look it from the picture.

For this project, you need a soil moisture sensor. It will have two legs with metal strips down the middle. The sensor works by passing a current through the soil between the legs and seeing how much resistance there is to its flow. The more water there is, the lower the resistance. That lets us estimate how wet the soil is.

Using the crocodile clips and jumper wires, attach the sensor鈥檚 鈥済nd鈥 wire to the micro:bit鈥檚 ground, its 鈥渧cc鈥 to the 3V pin and its 鈥渁o鈥 (analogue out) to pin 0. Then, go to the online micro:bit MakeCode editor to create a program. From the 鈥淏asic鈥 menu on the left, grab a 鈥渟how number鈥 block, then put it in 鈥渇orever鈥. Next, from the 鈥淧ins鈥 menu (under 鈥淎dvanced鈥), take an 鈥渁nalogue read pin p0鈥 and clip it in 鈥渟how number鈥. Now you have a simple program to display the sensor output. Download it to the micro:bit and attach its battery.

Time for an experiment. Poke your sensor into some dry soil and note the reading, then do the same for freshly watered soil. I got around 1000 for the dry soil and 400 for the wet. Between these extremes, pick a number that you think represents when your plant might be thirsty. I chose 800.

Back in the editor, grab an 鈥渋f <> then else鈥 from the 鈥淟ogic鈥 menu and clip it into 鈥渇orever鈥. Next, take a 鈥0<0鈥 comparison from the same menu, change the 鈥<鈥 to 鈥>鈥 and clip the comparison over the default 鈥渢rue鈥. Clip another 鈥渁nalogue read pin p0鈥 over the first 0, then change the second 0 to your threshold.

Find 鈥渟how icon鈥 in 鈥淏asic鈥 and nestle it in the if block, picking the sad face icon from the drop-down list. In the else part, add another 鈥渟how icon鈥 with a happy face.

And just like that, your plant can pull faces! It will look miserable when thirsty and smile when satisfied. Remember, though, plants鈥 thresholds can change. A cactus needs to stay dry in winter, for example.

Next week, we will get to know our plants better by improving their communication skills.

To download a printable version of this page click here


New stuff you need

BBC micro:bit starter kit (the same one we used in the first 鈥淗ow to be a maker鈥 series)

Soil moisture sensor

Crocodile clips

Jumper wires


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

9 Remote controlled pest-proof bird feeder part 1

10 Remote controlled pest-proof bird feeder part 2

Topics: Electronics / Plants