Bonsai Buckaroo moisture spikes

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dearmash
 
Posts: 66
Joined: Mon Nov 28, 2011 4:20 pm

Bonsai Buckaroo moisture spikes

Post by dearmash »

I set up my buckaroo, and noticed it seemed like it really never activated. I even marked the water line in the cup to see if it ever went down; not a drop even after a week.

So I ended up porting the plotter sketch to CLUE plant to get some amount of history. Code is below.

Main benefits, each pixel (column) represents a minute of time, so I can see over time how the moisture is detected, first plot. I also added a/b buttons to raise/lower the target percentage on device, which shows up as a second plot. The third plot just goes high/low depending if the motor ever turned on during that period.

I'm noticing these odd "humidity spikes". I'm curious if anyone has a theory why this might happen? I'm not adding water, the motor isn't turning on at all, and they last minutes at a time before they go down.
bonsai.jpg
bonsai.jpg (874.87 KiB) Viewed 189 times

Code: Select all

import time
import board
import digitalio
import analogio
from adafruit_clue import clue
from plotter import Plotter

# Motor setup
motor = digitalio.DigitalInOut(board.P2)
motor.direction = digitalio.Direction.OUTPUT

# Soil sense setup
analog = analogio.AnalogIn(board.P1)

times = 100
last_read = 0
analog_sum = 0
analog_value = 65535
changed = False
last_motor = 0
percentage = 100
target = 50
button_up = True

plotter = Plotter(board.DISPLAY, scroll_px=1, mu_output=True)
plotter.display_on()

plotter.title = "CLUE plant"
plotter.y_range = (0, 100)
plotter.y_full_range = (0, 100)
plotter.y_min_range = 20
plotter.channels = 3
plotter.channel_colidx = (5, 3, 7)
plotter.change_stylemode(style="lines", mode="scroll")

motor_was_on = False

PLOT_RATE = 60
last_plot = 0

while True:
    if time.monotonic() - last_read > 0.01:
        last_read = time.monotonic()
        analog_sum += analog.value
        times -= 1
        if times == 0:
            analog_value = analog_sum / 100
            times = 100
            analog_sum = 0
            changed = True

    if changed:
        changed = False
        # Calculate a percentage (analog_value ranges from 0 to 65535)
        percentage = analog_value / 65535 * 100
        # Display the percentage
        if time.monotonic() - last_plot > PLOT_RATE:
            last_plot = time.monotonic()
            plotter.data_add((percentage, target, target if motor_was_on else 0))
            motor_was_on = False

    if time.monotonic() - last_motor > 0.5:
        if not motor.value and percentage < target:
            last_motor = time.monotonic()
            motor.value = True
            motor_was_on = True
        else:
            last_motor = time.monotonic() + 5 # extra off time
            motor.value = False

    if button_up and clue.button_a and target > 10:
        target -= 5
        button_up = False

    if button_up and clue.button_b and target < 90:
        target += 5
        button_up = False

    if not button_up and not clue.button_a and not clue.button_b:
        button_up = True

User avatar
unawoo
 
Posts: 114
Joined: Thu Apr 14, 2016 9:39 pm

Re: Bonsai Buckaroo moisture spikes

Post by unawoo »

I ran your code, great mod, i didn't get any spikes.
Could be the the alligator clip leads, the wires are usually just crimped on the clips which can lead to all kinds of intermittent problems.
Just a suggestion, try soldering the wires to the clips if you can, or ask a friend to, or use other leads.

Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”