I have a humidity analog sensor that I am trying to read. The sensor outputs a 4-20 mA signal. I converted it into a 0 - 3.3V potential with a 165 Ohm resistor.
When I measure the voltage across the resistors with a multimeter, I get the correct values. I get a voltage of around 2.9V which corresponds to about 87 % humidity which seems to be correct.
However the values of ADC are haywire. I get values between 2500 to 4095, which correspond to between 61 % and 100 % humidity. The sensor is quite accurate so its not a problem with the sensor. I am using ADC on pin 25.
My circuit is shown as an attachment. I have also attached the values of ADC measured.
#include <Arduino.h>
// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int Pin = GPIO_NUM_34;
void setup() {
Serial.begin(115200);
pinMode(Pin, ANALOG);
delay(1000);
analogSetAttenuation(ADC_11db);
}
void loop() {
int data = analogRead(Pin);
double vol = (data * 3.3) / 4095;
Serial.print(data);
Serial.print("");
Serial.print(vol);
Serial.print("
");
delay(300);
}
question from:
https://stackoverflow.com/questions/65901942/esp32-analog-to-digital-adc 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…