Close

using the ADC with the arduino IDE

A project log for Ignore this ESP8266 board

I stole from every one. The huzza from Adafruit. Matts breakout board. Al1s board from here. NodeMCUs DevKit.

davedarkodavedarko 12/04/2015 at 19:350 Comments

I've changed the two ADC resistors to 10k and 3.9k, giving me a range of 0V - 4.9V to be able to check the battery connected to the system.

Here's a little conversion script for reading and printing the values. I'm high on sugar, so it took me longer than I am able to admit :D

int r1 = 3883;
int r2 = 1000;

void setup() {
  
  Serial.begin(9600);
}

void loop() {
  float val = analogRead(A0);
  
  float vout = (val) * (r1 + r2) / r2 / 1023;
  Serial.print(val);
  Serial.print(" - ");
  Serial.println(vout);
  delay(200);
}

Discussions