Soil moisture value reading
Re: Soil moisture value reading
Why don't you use the attentuator of the ESP32 and set it to 11db? That gives you a range of 0-3.5V. The lienarity is even worse than usual, but for your application that should not matter.
Re: Soil moisture value reading
because:
- Do not know how to change attentuator on ESP32
- I would like to have several soil moistures connected, can this be done for more than one PIN?
Re: Soil moisture value reading
Yes, the documentation is extremly sparse for the ESP32 build.
And yes, you can do that for more than one input. At the moment, ADC1 is supported, with its inputs at GPIO32 to GPIO39
Code: Select all
from machine import Pin, ADC
adc=ADC(Pin(34))
adc.atten(adc.ATTN_11DB)
Re: Soil moisture value reading
Learning something new every day here. I do not quite understand this function. Should I use pin34 with attent function to connect to sensors VCC (meaning that Pin34 will provide reduced voltage to 1V) or is it supposed to be used to receive analog in from Sensor (since Pin34 is also A6)
Re: Soil moisture value reading
Pin34 is just one of the ADC inputs. And setting the attenuation to 11db means, the ADC range changes from 0-1V into 0-3.3V. If your humidity sensor is operated with 3.3V, then you will not need the resistor voltage divider. Depening on the length of the wires, it is still recommended to add some protective circuitry, like at least a serial resistor of 10kOhm, and a small capacitor at the ADC input to GND, like 1 nF.
Re: Soil moisture value reading
resistor would be between sensor Analog output and ADC input on ESP32?
Re: Soil moisture value reading
Yes, close to the analog input of the esp32, to limit the inrush current in case of spikes etc. The current itself will then be absorbed by the built-in ESD protection diodes of the ESP32.