Ä¢¹½Ö±²¥

Electronics projects for beginners: Get your plants talking to you

Well-loved plants are happy plants. Here’s how to wire yours up to a BBC micro:bit so they can tell you when they are too hot, dry or cold

David Stock for <i>New Ä¢¹½Ö±²¥</i>

LAST week, our plants learned to tell us they are thirsty. Now we are going to expand their repertoire.

Spider plants are happiest at between 20 and 30°C. That range suits me too, so it may seem that my spider plant Marvin is fine. But his microclimate may vary, or you might have a plant, an orchid for instance, that is more sensitive. Micro:bits have a temperature sensor built in, so we can use this to enable a plant to tell us in words when it is too hot or cold, as well as too dry.

In last week’s program, you have an “if� block that reads the moisture sensor’s input from pin p0 and compares it with the threshold moisture level. To start, replace the sad face with a “show string� from “Basic�, and in this type: “I’m thirsty�. This will show on the micro:bit screen when the water level drops.

Next, create a variable. We need to include this so that next week we can tell whether Marvin is happy or sad. This week, we are giving him only sad messages.

Go to the “Variables� menu, click “create new� and type “DRY� in the box. Then, grab “set DRY to�, which will have appeared in the menu, and clip into this a “true� block from the “Logic� menu. Place the whole thing under “show string�. Under “else�, replace the happy face with another “set DRY to�, but this time clip in “false�.

Now we want to know if the plant’s temperature goes below 20°C. Place another “if� block underneath the first, and click the plus at the bottom to add an extra if/else section. Next, grab a “0\>0� comparison from “Logic�. Find a “temperature� block from “Input� and clip this in the left of your comparison, then type 20 on the right. Slot this comparison in place of “true� in the first part of your “if� block. Under this line, add a “show string� block like before, but with a message like “I’m too cold�.

Next, another variable. This one enables us to keep track of when the temperature is either too hot or too cold. Call this one “WRONG TEMP� then grab a “set WRONG TEMP to� block and clip into it “true� from the Logic menu. Slot the whole thing under your “show string� block.

In the second part of your “if� block, write a comparison as above, but make it say “temperature \< 30�. Add a string saying “I’m too hot�, and a block to “set WRONG TEMP� to “true� underneath.

Finally, in the “else� section, clip in “set WRONG TEMP to false�. If you get stuck, you can check out online.

Download your code, and connect up the sensor, micro:bit and battery. You will notice that your plant does nothing but complain – we haven’t yet given it a way to say it is satisfied. That comes next week, along with an automatic watering device.

To download a printable version of this page click here


What you need

You should have everything

For next week

jumper wires

Next in the series

1 Moisture-sensing plant

2 Moisture and temperature-sensing plant

3 Plant auto-waterer Your plants will never dry out again

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