Basically I'm trying to use the analogRead() function to monitor voltage usage for a voltage divider set up. In this documentation (Battery Voltage - Photon 2 - Battery voltage | Reference | Particle), there is the constant 0.0011224 multiplied to the function, and it says that it calculated this based on two resistors (R1 = 806K, R2 = 2M) that lower the 3.6V LiPo battery output to a value that can be read by the ADC.
My question is: How did they calculate this constant? I am also trying to use two resistors to lower a 5V output to a 3.3V or less.
Thank you. Yeah, I used one of those to determine that my R1 = 1.125 megaohms and R2 = 2 megaohms. However, I'm trying to figure out where Particle got the 0.0011224 value from
This means that at full ADC input of 3.3V, the Vin (high side of the voltage divider) must be 4.6299V. This corresponds to a value of 4095 from analogRead.
4.6299 / 4095 = 0.00113062
That's not exactly the same as the value in the docs, but it's close and I'm not sure why it's different.