Skip to content

Instantly share code, notes, and snippets.

@elktros
Created March 12, 2021 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/fd8a1abb51d652ff37a527344ce48a11 to your computer and use it in GitHub Desktop.
Save elktros/fd8a1abb51d652ff37a527344ce48a11 to your computer and use it in GitHub Desktop.
Code for measuring analog voltage using ESP32 ADC.
#define ADCPIN A0
int adcValue;
float voltValue;
void setup()
{
Serial.begin(115200);
}
void loop()
{
adcValue = analogRead(ADCPIN);
voltValue = ((adcValue * 3.3) / 4095);
Serial.print("ADC Value = ");
Serial.print(adcValue);
//delay(1000);
Serial.print(" ");
Serial.print("Voltage = ");
Serial.print(voltValue);
Serial.println(" V");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment