I’m somewhat perplexed as to why I’m unable to get a stable and accurate voltage reading. I suspect its my voltage divider, resistance is too high. I chose 64k resistors to reduce power consumption and hopefully to protect the microcontroller from the 50V+ it will be connected to if I can get it working.
The SSR is just a load to drain down the two 18650 cells. I was hoping to see the voltage slowly drop but somethings wrong. It is dropping but the reading is too high. The voltage should read about 8V.
Disconnected from the microcontroller these are the voltages I get.
I connected a brand new AAA Duracell battery to it(1.6v). I got 2.281v returned via Blynk…
I think a voltage of 3.3v applied to A0 is what is required to give the maximum reading of 1023.
So, applying 3.99v will be (slightly) swamping the input and result in a constant maximum reading.
It’s actually slightly confusing when you read some of the ESP8266 documentation, because the bare chip only enquires 1v to gove the maximum reading, but NodeMCUs etc have an onboard voltage divider which extends the 0-1v range to 0-3.3v range.
Changed it to 3.45v and it gives me a pretty accurate reading now as long as the voltage I’m measuring isn’t above 6v. Is that because of the 3v limit on the A0 pin?
So for higher voltages(50v+) I’m going to need a much better voltage divider, one with multiple resistors as the one I’m using now only halves the voltage?
As I said earlier. 3.3v on the pin gives maximum ‘deflection’ of 1023.
If you calculated the voltage divider so that your nominal 50v input give a 50% ‘deflection’ then 512 would be the corresponding reading.
Meaning that you’d be getting roughly 0.1v resolution.
If you sized your voltage divider so that 50v gives an output of 1000 on the sale of 0-1023 then the resolution would be 0.05v, but you’d only have a 1.15v margin at the top end, so 51.15v would give you maximum ‘deflection’ with a maxed-out reading of 1023.
Could a pentiometer be used as a voltage divider?
Give me an easy way of calibrating the whole thing for high and low voltages ?
I have a couple somewhere, I guess I could just try it …
Yes, potentially
But, TBH you are better-off using high tolerance fixed value resistors to give the maximum stability.
If you want to measure two different voltages using the same device then you’re probably better using an ESP32 which has multiple pins that can be used as analog inputs. A couple of things to watch out for though, some of those pins can’t be used the same time as WiFi (those in the ADV2 group), and the default is that you’ll get 4095 as the maximum output for a 3.3v input.