0

I have a gas sensor that I am trying to read. I have connected the sensor to the analog input of ESP-S2 TFT Feather. When I change the analog to digital and read the measured voltage, the measured voltage is very very high. I figured out the resolution of this board is 13 bit. But, the measured voltage is still very high.

 int analogInPin = A2; 
 void readco() {
 // read the analog in value:
 sensorValue = 0;
 const int res = 8191; //resolution = 13-bit and 2^13 - 1 = 8191
 
  sensorValue = analogRead(analogInPin) + sensorValue;   
  iaq_data.co_0=(float) sensorValue*3.3/res;
1
  • If you are using Arduino-ESP32, the default ADC resolution is 12-bit except for ESP32S3. Read the doc to see how to set the analogReadResolution(). Commented Oct 25, 2022 at 1:02

1 Answer 1

0

From the ESP32-S2 docs found here,

Resolution of ESP32-S2 ADC raw results under Single Read mode is 12-bit

Are you sure your resolution is 13 bit?

Also, you seem to be adding sensorValue to itself every time. You initialise it to 0 every time so it should not matter but I would remove that.

This code should work:

int 12_bit_resolution = 4095; // 2^12 4096 - 1
input_voltage = analogRead(analogInPin) * (3.3 / 12_bit_resolution);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.