pimoroni / enviro

MIT License
104 stars 83 forks source link

Ability to adjust overall and individual wet/dry detection points for Grow sensors #7

Open retropangy opened 2 years ago

retropangy commented 2 years ago

With current code sensors have been showing 100 moisture level in almost completely dry pots (to the point of wilting plants) - ability to set wet/dry points and for the scaling to be adjusted appropriately is really needed (similar to Grow Hat functionality).

retropangy commented 2 years ago

Clicked the wrong button. 🙄

lowfatcode commented 2 years ago

@retropangy have you ever seen a value other than 100? Have you got three sensors plugged in? Anything else about your setup you can share?

retropangy commented 2 years ago

@lowfatcode Eventually, but I had to go into the code and make some fairly substantial changes to have individual scaling settings for each pot - I tried to find a single "scaled =" that meant that something appeared for all my pots, and was going to tweak the "pump points" for each, but there just wasn't a range where at least one pot wasn't pegged at 100 or at zero. I have two balanced now - watering when it goes below 50 - and need to work on getting the final one perfect, but roughly - and I apologise for terrible coding practice in advance - what I have is;

if i==0:
          scaled = (min(20, max(0, average - 78)) / 20) * 100
if i==1:
          scaled = (min(20, max(0, average - 90)) / 20) * 100
if i==2:
          scaled = (min(20, max(0, average - 65)) / 20) * 100

The last one is the final pot which is quite small and has a compost which gets very damp very fast so is still pegging at 100 for part of the time.

lowfatcode commented 1 year ago

@retropangy I'm not sure it's a concern that all of the scales map directly on to each other - in fact I don't think it even really makes sense. However the values certainly shouldn't clamp to the extremes as that is useless.

I've extending the min/max range which hopefully means it will now return values for all three of your pots.

There is now a way to setup auto watering thresholds in https://github.com/pimoroni/enviro/commit/5a8646942d78a787be102afca15b144ecff31be8

retropangy commented 1 year ago

I've extending the min/max range which hopefully means it will now return values for all three of your pots.

Tried 0.0.8 and it was pegged at 100 on all three. What I've done is make sure the pots are thoroughly "water in the saucer" saturated and changed the min_ms and max_ms values so that the scaled result is just nearly at 100 and I'll monitor the values as they dry out. (min_ms to 50 and max_ms to 105 IIRC). I am having a few issues with the uploads to adafruit_io failing and the board flashing a red warning light - not quite sure what is going on there, don't think it's grow.py at fault though.

ZodiusInfuser commented 1 year ago

@retropangy Did your changes to the min_ms and max_ms values work? Did the moisture number go down as the plants dried out?