12v battery-->voltage divider-->ADC pin of NodeMCU v3 (esp8266)
I read this particular board has its own internal voltage divider (220kOhm and 110kOhm resistors) which allows 3.3V at the ADC pin, bringing it to 1V at the esp chip.
I've put between the battery and the ADC pin three additional resistors in series 1 x 680kOhm and 2 x 100kOhm), so that at the ESP, 12v is lowered to 1v. adc.read() reads 1024, however I'm struggling to convert this to the actual battery voltage.
Can anyone help me with the formula? Currently I've come up with the following, which I found on the Arduino forum and modified to my case, but I'm not sure it's correct.
Code: Select all
voltsPerBit = 1/1023
ratioV = (1100000 + 100000) / 100000
rawVolts = d1 * voltsPerBit
battery = rawVolts * ratioV
PS: Battery is being charged from solar panel with cmp12 charge controller https://www.amazon.co.uk/MagiDeal-Contr ... ords=cmp12 (not best option but rather cheap one). Does it make any sense to measure voltage when the controller is charging the battery?