Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Soil Moisture Detector
import time
from import cpx
import touchio
import simpleio
import board
cpx.pixels.brightness = 0.2
touch = touchio.TouchIn(board.A1)
DRY_VALUE = 1500 # calibrate this by hand!
WET_VALUE = 2100 # calibrate this by hand!
while True:
value_A1 = touch.raw_value
# fill the pixels from red to green based on soil moisture
percent_wet = int(simpleio.map_range(value_A1, DRY_VALUE, WET_VALUE, 0, 100))
cpx.pixels.fill((100-percent_wet, percent_wet, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.