Same values whether I dip the moisture sensor in water or not

Zeni241
Posts: 41
Joined: Tue Nov 20, 2018 4:28 am

Same values whether I dip the moisture sensor in water or not

Postby Zeni241 » Wed May 29, 2019 1:36 pm

I am following example esp-idf/examples/peripherals/adc/ and copied exactly the code in adc1_example_main.c in my project. But somehow I am getting same values as below whether I dip the moisture sensor in water or not.

Code: Select all

eFuse Two Point: NOT supported
eFuse Vref: NOT supported
Characterized using Default Vref
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
 Raw: 4095        Voltage: 1039mV
.
.
.
I am using ESP32 development board,esp-idf 3.2 (recent release), and connections are as below:
Moisture sensor ESP32 DevBoard
VCC ------------------> 3V3
GND ------------------> GND
A out ------------------> GPIO34 (as code is using ADC_CHANNEL_6)
If I use Arduino IDE for analog read, I get correct results (different values when moisture sensor is dipped and undipped in water) with same hardware configuration.
I spent lot of time, but couldn’t figure out what I am doing wrong. :x :x
Any guess please.

ESP_Dazz
Posts: 142
Joined: Fri Jun 02, 2017 6:50 am

Re: Same values whether I dip the moisture sensor in water or not

Postby ESP_Dazz » Wed May 29, 2019 2:29 pm

What is the voltage range of your moisture sensor vs your ADC attenuation configuration?

Zeni241
Posts: 41
Joined: Tue Nov 20, 2018 4:28 am

Re: Same values whether I dip the moisture sensor in water or not

Postby Zeni241 » Fri May 31, 2019 5:31 am

Thanks a lot @ ESP_Dazz , changing ADC attenuation configuration was game changer. :D :D

Code: Select all

Now with capacitive moisture sensor and static const adc_atten_t atten6 = ADC_ATTEN_DB_6;
With out water:
No.1, Raw: 4095 Voltage: 1877mV
No.2, Raw: 4095 Voltage: 1877mV
No.3, Raw: 4095 Voltage: 1877mV
No.4, Raw: 4095 Voltage: 1877mV
No.5, Raw: 4095 Voltage: 1877mV
No.6, Raw: 4095 Voltage: 1877mV
No.7, Raw: 4095 Voltage: 1877mV
No.8, Raw: 4095 Voltage: 1877mV

and with fully dipped in water:
No.21, Raw: 2509        Voltage: 1191mV
No.22, Raw: 2510        Voltage: 1192mV
No.23, Raw: 2510        Voltage: 1192mV
No.24, Raw: 2510        Voltage: 1192mV
No.25, Raw: 2509        Voltage: 1191mV
No.26, Raw: 2508        Voltage: 1191mV
.
.

No.34, Raw: 2509        Voltage: 1191mV
No.35, Raw: 2510        Voltage: 1192mV
No.36, Raw: 2511        Voltage: 1192mV
No.37, Raw: 2511        Voltage: 1192mV
No.38, Raw: 2510        Voltage: 1192mV
No.39, Raw: 2510        Voltage: 1192mV
No.40, Raw: 2510        Voltage: 1192mV
No.41, Raw: 2510        Voltage: 1192mV
No.42, Raw: 2510        Voltage: 1192mV
.
.
No.250, Raw: 2507       Voltage: 1191mV
No.251, Raw: 2508       Voltage: 1191mV
No.252, Raw: 2505       Voltage: 1190mV
No.253, Raw: 2508       Voltage: 1191mV
No.254, Raw: 2508       Voltage: 1191mV
No.255, Raw: 2506       Voltage: 1190mV
No.256, Raw: 2506       Voltage: 1190mV
No.257, Raw: 2506       Voltage: 1190mV
No.258, Raw: 2507       Voltage: 1191mV
No.259, Raw: 2508       Voltage: 1191mV
No.260, Raw: 2511       Voltage: 1192mV
Thanks again ESP_Dazz :lol: :lol:

Who is online

Users browsing this forum: ESP_Prasad, Jarml0x0F and 18 guests