Trying to use Grow Soil/Moisture sensor with esp32s2

I have been trying to get accurate readings using the grow moisture sensors without the Grow hat using an esp32s2 (QTpy ESP32s2). I have had luck with my circuitpython script running and giving me consistent readings from a couple of other 3-pin moisture sensors that I had lying around, but when I use the Grow sensors, it get very inconsistent readings which is pretty useless. I bought six of them and have tried another from the batch and get the same results. I know I have the pins correct and I’ve tried it with 3v, 5v, with a pull-up resistor and without. I can’t figure out what is wrong.

My calibration script is as follows:

import board
import busio
from analogio import AnalogIn
import time

Create an analog input on pin SDA

moisture_sensor = AnalogIn(board.A0)

create a list to hold the calibration values

calibration_values =

take 5 readings of the sensor in dry soil

print(“Place sensor in dry soil and press enter.”)
input()
for i in range(5):
reading = moisture_sensor.value
calibration_values.append(reading)
print(“Calibration reading”, i+1, “:”, reading)

take 5 readings of the sensor in wet soil

print(“Place sensor in wet soil and press enter.”)
input()
for i in range(5):
reading = moisture_sensor.value
calibration_values.append(reading)
print(“Calibration reading”, i+5, “:”, reading)

calculate the min and max values

min_value = min(calibration_values)
max_value = max(calibration_values)

print(“Calibration complete. Min value:”, min_value, “Max value:”, max_value)

Hi, does the moisture_readings function on the following help? It is micropython but might show how they do it.

Thanks for you reply. I couldn’t get that function to work in circuitpython but the readout consistently bounces from high to low with the grow sensor but works as expected with other sensors:

52408
Moisture level: -0.00%
834
Moisture level: 99.69%
893
Moisture level: 99.58%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
873
Moisture level: 99.62%
913
Moisture level: 99.54%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
873
Moisture level: 99.62%
873
Moisture level: 99.62%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
873
Moisture level: 99.62%
873
Moisture level: 99.62%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
873
Moisture level: 99.62%
873
Moisture level: 99.62%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
933
Moisture level: 99.50%
873
Moisture level: 99.62%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
52408
Moisture level: -0.00%
873
Moisture level: 99.62%