Read MSEGQ7 with ESP32 (Read 5v from a 3.3v input)
Posted: Thu Mar 21, 2024 5:47 pm
I'm trying to read the output of MSEGQ7 (DfRobot) from an ESP32.
I have done 2 tests:
Arduino Mega (works):
- Analog input 0-5v
- 10 bits (0-1023)
ESP32 (not working):
- Analog input 0-3.3v
- 12 bits (0-4095)
Comparative video on YouTube https://youtu.be/1cE5tiCEpbg
As explained here https://github.com/G6EJD/ESP32-ADC-Accu ... n/issues/3 I have used a voltage divider (R1 = 1700 ohm, R2 = 3300 ohm) and I convert the 5v into 3.3v , but something doesn't work.
The values that I recover in ESP32 are very low:
0,243,12,44,190,167,0
0.242.0.0.204.74.0
0,153,114,207,250,242,0
0.75,12,140,237,231.0
0,0,34,128,149,154,0
0,0,63,45,69,76,0
0,0,0,0,9,21,0
0,0,0,0,0,0,0
0.252,19,0,199,179,0
The first and last columns are almost always worth 0
The code I run for the 2 tests is the same. I guess I have to do something like
but the values that I recover in ESP32 are very low
My Loop()
I have done 2 tests:
Arduino Mega (works):
- Analog input 0-5v
- 10 bits (0-1023)
ESP32 (not working):
- Analog input 0-3.3v
- 12 bits (0-4095)
Comparative video on YouTube https://youtu.be/1cE5tiCEpbg
As explained here https://github.com/G6EJD/ESP32-ADC-Accu ... n/issues/3 I have used a voltage divider (R1 = 1700 ohm, R2 = 3300 ohm) and I convert the 5v into 3.3v , but something doesn't work.
The values that I recover in ESP32 are very low:
0,243,12,44,190,167,0
0.242.0.0.204.74.0
0,153,114,207,250,242,0
0.75,12,140,237,231.0
0,0,34,128,149,154,0
0,0,63,45,69,76,0
0,0,0,0,9,21,0
0,0,0,0,0,0,0
0.252,19,0,199,179,0
The first and last columns are almost always worth 0
The code I run for the 2 tests is the same. I guess I have to do something like
Code: Select all
map(value,0.4095,0.1023); //12 bits to 10 bits
My Loop()
Code: Select all
Audio.ReadFreq(FreqVal);//return 7 value of 7 bands pass filiter
//Frequency(Hz):63 160 400 1K 2.5K 6.25K 16K
//FreqVal[]: 0 1 2 3 4 5 6
for(int i=0;i<7;i++) {
Serial.print(max((FreqVal[i]-100),0));
if(i<6) Serial.print(",");
else Serial.println();
}
paintColumns();