Create a digital twin of a plant that take cares of the real twin :)
Disclaimer: This is a small side project mainly created to give as prize in the sdsc-hackathons, genAI 2023 by SDSC. Also it still requires to be polished a little bit, so if you want to give a hand please feel free to do a PR.
This version creates a systems that detect when your plant is needing some water and activate a pump to save it.
- Plant
- Water recipient
- BBC micro:bit v2
- Plant Care Kit for micro:bit or CLUE
You can find detailed instructions here
- Connect the Bonsai board to the Micro:bit.
- Wire the pump and the crocodile pins to the Bonsai board.
- Connent the micro:bit to your computer.
- Go to python.microbit.org
- Connect to the board.
- Write this code:
from microbit import *
def read_and_average(analog_in, times, wait):
analog_sum = 0
for _ in range(times):
analog_sum += analog_in
sleep(wait)
return analog_sum / times
while True:
# Take 100 readings and average them
analog_value = read_and_average(pin1.read_analog(), 100, 0.01)
# Calculate a percentage (analog_value ranges from 0 to 1024 )
percentage = analog_value / 1024 * 100
# Display the percentage
#display.show("V:{}%".format(int(percentage)))
sleep(2000)
# Note: reading of ~64% when no contact
if percentage < 84:
# Motor on
display.show(Image.UMBRELLA)
audio.play(Sound.TWINKLE)
#pin2.write_digital(1)
else:
display.show(Image.HAPPY)
#pin2.write_digital(0)
- Check that the pump is activated when you put the pins close or far away.