ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

tele_player
Posts: 90
Joined: Sun Jul 02, 2017 3:38 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby tele_player » Wed Sep 06, 2017 5:12 am

Interesting, it never occurred to me that he wasn't calling the functions - that would definitely explain it.

vseven
Posts: 21
Joined: Wed Aug 30, 2017 3:22 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby vseven » Wed Sep 06, 2017 12:35 pm

I didn't know I had to call those within a function so they kept throwing "expected constructor, destructor, or type conversion before '(' token", I was trying to put them with my define lines since I thought they needed to be called before anything else and logically that made sense to me. So when they threw errors I looked at the examples and made them match which now I realize, as you pointed out, I was just defining them and not calling them.

I put them into my setup() and now they compile correctly. I'll test it tonight and see if it worked. Thanks.

vseven
Posts: 21
Joined: Wed Aug 30, 2017 3:22 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby vseven » Wed Sep 06, 2017 4:40 pm

FYI - my results after making the changes for anyone that could use it:
ESP32-ADC-12-Bit.png
ESP32-ADC-12-Bit.png (17.56 KiB) Viewed 29426 times
ESP32-ADC-11-Bit.png
ESP32-ADC-11-Bit.png (19.81 KiB) Viewed 29426 times
Orange = 6db attenuation
Blue = 11db attenuation
Last edited by vseven on Wed Sep 06, 2017 5:10 pm, edited 1 time in total.

vseven
Posts: 21
Joined: Wed Aug 30, 2017 3:22 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby vseven » Wed Sep 06, 2017 4:42 pm

Apparently there is a three file max on posts so here is the raw data
Attachments
ESP32-S ADC Mapping 11-bit.csv
(586 Bytes) Downloaded 1404 times
ESP32-S ADC Mapping - 12-bit.csv
(1.75 KiB) Downloaded 1512 times

mnemonix
Posts: 9
Joined: Mon Jan 23, 2017 11:07 pm

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby mnemonix » Thu Sep 07, 2017 12:15 am

The -6dB range with 11 bits looks quite linear, if only this 0.1V offset would not exist.
But for your application with a 0..10V Input you need anyway an external resistor voltage divider, so you can just add a third resistor to lift the voltage by 0.1 V. Here is a possible circuit:
ADC0-10V.png
ADC0-10V.png (4.82 KiB) Viewed 29537 times

vseven
Posts: 21
Joined: Wed Aug 30, 2017 3:22 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby vseven » Thu Sep 07, 2017 1:21 am

My sensors are actually 4-20ma that I'm converting already with a current -> voltage adapter. The one i have lets me change the zero and max so i have it set for what seemed to be the most linear part of the range which was 0.20v (105 on ADC) and ending at 1.85v (1980 on ADC). I then scalled my sensors, temperature and humidity, to map to that ADC range.

Actual Temp: 61.96* / ESP32 Temp: 62.42*
Actual Humidity: 62.14% / ESP32 Humidity: 62.17%

I'm only reading every minute and a thunderstorm was rolling in (temp was dropping rapidly) so I'm calling it a success even with the slight difference in temperature. I also did a max range test, sending 4ma down the 20ma and i was within 0.1% of both high and low ends.

HUGE difference in linearity using 6db and in reduction of noise using 11-bit.

tele_player
Posts: 90
Joined: Sun Jul 02, 2017 3:38 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby tele_player » Thu Sep 07, 2017 2:30 am

What are you using to determine actual temperature and humidity?


tele_player
Posts: 90
Joined: Sun Jul 02, 2017 3:38 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby tele_player » Thu Sep 07, 2017 3:11 pm

Interesting.
You compare actual to ESP32 above. What was being compared?

vseven
Posts: 21
Joined: Wed Aug 30, 2017 3:22 am

Re: ESP32 ADC Non-linear Issues - How do I fix / change Attenuation or width?

Postby vseven » Thu Sep 07, 2017 3:16 pm

I have a commercial grade device that reads 4 - 20ma and scaled the temp and humidity for those readings. I compared that to known good calibrated temperature and humidity sensors. Once that was calibrated I used that reading against the ESP32 reading to verify the accuracy.

Who is online

Users browsing this forum: No registered users and 115 guests