Enviro Grow: Split string & control pumps


I’m in the middle of writing some code to activate the pumps on the Enviro Grow. The idea is that I use the logged string of sensor measurements and extract the values for the 3 moisture sensors. I’ve tried the “split” and “partition” syntax, but I don’t think these are supported.

example string: {'moisture_1': 1, 'moisture_2': 1, 'temperature': 29.7, 'pressure': 1013.39, 'moisture_3': 1, 'humidity': 28.92, 'light': 1.16}

From the above, I’d like to extract each of the 3 values as separate variables, which can then be used to trigger the pumps if below a predetermined value.

Anyone got any ideas on how I get achieve the required end result?


The above issue has been solved. Created custom code and used the following:

import enviro
from enviro.boards import grow
reading1 = round(grow.moisture_readings(2000)[0],2)
reading2 = round(grow.moisture_readings(2000)[1],2)
reading3 = round(grow.moisture_readings(2000)[2],2)

Full code has been shared via github:

1 Like