1

Trying to read from a voltage divider circuit using two 240 Ohm resistors. Getting a reading of 6.0, when it should be 1.65. Circuit is powered by a bench 3.3V and both the Huzzah32 and circuit are grounded. Using USB for the Huzzah32. Any thoughts?

  void setup() 
{
  Serial.begin(9600);
}
void loop() 
{
  int sensorValue = analogRead(A9);
  float voltage = sensorValue * (3.3 / 1023.0);
  Serial.println(voltage);
  delay(1000); 
}

circuit diagram

6
  • Please add the schema. Oct 21 '20 at 7:10
  • My multimeter reads the correct Vout... Oct 21 '20 at 8:03
  • this gets me closer, but still low... float voltage = (sensorValue * 3.3) / (4095); Oct 21 '20 at 8:26
  • ESP32 chips have a problem with ADC and WIFI at the same time. Maybe disable WIFI ?
    – tavis
    Oct 21 '20 at 9:01
  • both the Huzzah32 and circuit are grounded ... are the grounds joined? ... your schematic does not show a common ground
    – jsotola
    Oct 21 '20 at 16:54
1

First, ESP32 ADC is 12-bit, not 10-bit. therefore the formula should be:

float voltage = sensorValue * (3.3 / 4096.0);

Secondly, ESP32 ADC is not really linear, and tend to have lower reading than the actual value. You will need to do some calibration if you want to get a more accurate reading. You can take a look at my github on esp32-adc-calibrate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.