digiplant

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.

v.0.0.1

This version creates a systems that detect when your plant is needing some water and activate a pump to save it.

What do you need?

Steps?

You can find detailed instructions here

  1. Connect the Bonsai board to the Micro:bit.
  2. Wire the pump and the crocodile pins to the Bonsai board.
  3. Connent the micro:bit to your computer.
  4. Go to python.microbit.org
  5. Connect to the board.
  6. 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)
  1. Check that the pump is activated when you put the pins close or far away.