Is it possible to hookup several soil moisture sensors and have them in a garden bed, and the pump irrigating different parts of the the bed as needed through say a relay? I’m an older adult with a Pi 4 8gb, wanting to do something with it when the Pi 5 comes out. I’m new to programming, but this plant_io project has sparked my interest.
Sure is! The Pi SBCs might not be the best candidate for this vs the Pico since there are dedicated ADCs and they are quite a bit more expensive.
Pimoroni have their Grow boards which might be worth a look in.
There’s a couple other additions I think would be worth adding so will be making some custom PCBs in the future, if you have any suggestions, send them through!
Shall do. I’m thinking redundancies that could be actioned through IoT, like refilling the water reservoir, using a camera and viewing progress of the plants’ growth while away, or to have a visual record to go with the data from seed to adult plant.
Almost exactly what I am thinking, with cameras not limited to SBC’s and now usable with MCU’s like the Pico there are so many possibilities. Once I’m finished uni assignments there ought to be some updates on this project
The parameters provided to the normalise_x function appear not to be compatible with V2 of the soil moisture sensor.
All values fall out of range.
By debugging / trial and error I was able to determine an approx range of the new sensor. 11_200 to 21_500.
I think it’s working, for example: being out in the air it’s close to 0%, and it’s 100% when completely submerged in Water. However, slightly damp soil (what I’m targetting) gives a value of 90% which is perhaps higher than I’d expect
These soil sensors are super cool technologies but the values they produce can look pretty wild.
I found that changing the size of the pot, or the type or soil, or the number of roots, changed what kind of values I could expect. I noticed that adding more soil reduced the conductivity of the system and helped scale my values.
Consider also an alternative to the normalize funciton like writing a function that takes a values between “11_200 and 21_500” and remaps them to a function. For example:
Scaled by the max of an unsigned 16bit int
# put me inside the Plant_io class
def natty_loggy_that_bad_boy(self, k):
#remaps to the nat log
#args : unsigned 16 bit int
#returns : a float between 0.0 and 1.0
if not isinstance(k, int) or not (k >= 0 and k < 2**16):
raise ValueError('That is not a u16 champion')
return math.log(k) / math.log(2**16 - 1)
Perhaps you prefer taking an average of the last 1000 samples?
def measure_soil(self):
self.readings = []
for _ in range(5):
self.readings.append(self.soil.read_u16())
if len(self.readings) > 999:
self.readings.remove(0)
sleep(0.05)
scaled_readings = map(self.readings, natty_loggy_that_bad_boy)
soil_adc_reading = sum(scaled_readings) / len(scaled_readings)
#...
Maybe you want to control the range of your scaling function
# put me inside the Plant_io class
def natty_loggy_that_bad_boy(self, k, a, b):
#remaps to the nat log
#args : unsigned 16 bit int
# : min expected value (int)
# : max expected value (int)
#returns : a float between 0.0 and 1.0
if not isinstance(k, int) or not (k >= a and k < b):
raise ValueError('How very dare you!')
return math.log(k - a) / math.log(b - 1)
Do you want to see finer details in the last 20% off your soil conductivity?
# put me inside the Plant_io class
def raise_the_roof(self, k):
#remaps to the nat log
#args : unsigned 16 bit int
#returns : a float between 0.0 and 1.0
if not isinstance(k, int) or not (k >= 0 and k < 2**16):
raise ValueError('That is not a u16 champion')
return math.pow(k, 3) / math.pow(2**16 - 1, 3)
Thanks for offering some creative remixes @Pixmusix Stoked you actually decided to peek behind the curtain and hack up our plant_io.py file @Marc67778 I think we could still detune the scaling to make it a bit more flexible. After all the “moisture %” is totally arbitrary anyway and the user sets their own threshold depending on their conditions.
I’ll make a commit to the library now based off your results - I think I’ll leave the upper bound where it is and decrease the lower bound. This should make the envelope most useful to most people out-of-the-box.
Hi! This project sounds cool but haven’t got it to work >.<. i had issues with the capacitive soil moisture sensor reading 68% when it was dry.
Anyone having issues with the pump working? I couldn’t get it to work over USB, it made some noise, but there was no suction or flow of water. Tried the provided batteries, same thing, noise but didn’t work. Saw that the pump said U: 6V P: 5W, so I tried using 4 x 1.5V alkaline batteries, and this made the pump sound like it was going faster, but still didn’t pull any water.
I’ve got the pins and cables lined up correctly, the soil moisture sensor works but isn’t calibrated correctly, and the pump isn’t working, even after the different powering options and having the tubes fitting snug… Any advice?
EDIT: Managed to solve the pump. The rotor wasn’t spinning the wheels in the bottom correctly, so I opened it up, and pressed in the plate holding the wheels as the rotor was spinning, until the wheels started to spin too. Now it works! Still don’t know how to calibrate the soil moisture sensor though.
also I was kind of anticipating the water to pump until the threshold for wetness was met, but it seems as though it only pumps for 10 seconds if the moisture isn’t at the threshold. right now i have it set to 100%, which should be 100% water, because the sensor is calibrated so high.
Glad you’re enjoying the project, and it’s good to hear you’re already fixed the pump issue!
Regarding the moisture sensor calibration, I take it you’ve already performed the “Test Soil Moisture Sensor” portion of the guide? Have you confirmed that the output of the sensor is 0, or close to it, when completely out of the soil/water?
It may help to send some code snippets, if you’re able to!