For a project to control a Solar Can Heater I have installed a few small 12V solar panels. These Solar panel are charging a 12V batter via a solar power controller.
I am already measuring the voltage of the panels (R1 and R2). This works okay. However I would like to also measure the battery voltage. The issue is that a NodeMCU has only one analog input ( 0 - 3.3V )
I know that I can use analog to I2C converter, bit I2C does not proper work with the Wire library which I will use for the temperature sensors that I need to control the airblower speed.
I am not an electronic engineer so I need some advise on the restrictor values.
What I want is minimum current loss and a correct voltage after the transistors.
The GPIO4 and GPIO5 are used to switch on/off the transistors.
I'd suggest using a purpose specific analog multiplexer after your voltage dividers.
If you use bipolar transistors as in your schematic, I think you'll need a pull down resistor to ground on the A0 node and the measured voltage won't be linear with voltage. It could probably be made to work, but I'd rather not.
I considered an anolog multiplexer, but I do not have that available at the moment. The pulldown restrictor can be done. Can you help how I can calculated the current and voltages around the the transistors. When the GPIO4 or 5 is set to O or 3.3 V ?
It is the best solution as there is no voltage drop in the analog switch as there is as a matter of course in the transistor.
The 74HC4066 has an "on" resistance of about 60 Ohms. As long as the input of the ADC is a much higher impedance (and it is) this will not affect the readings and it is quite linear - that is, it acts as a resistance rather than some sort of non-linear diode with a voltage drop (and resistance).
EddyBin:
I have order the 74HC4051.....but I still would like to understand how I should calculated the voltages around the transistors.
The values you have for resistors are reasonable except that I think you need a pull down from A0 to ground.
Loosely, the considerations include:
R1 & R2 selected to get the voltage divider ratio, which you've done
Input impedance to A0 < 10k Ohms which is about the parallel value of R1 & R2 and you've done this.
Base current sufficient to ensure transistor is fully turned on (for the very small current this circuit is switching) without pulling down the voltage divider, so R3 large relative to than R2, say 120k Ohm
Pull down resistor on A0 has same constraint as R3, so 120k as well.
If you were to read the ADC twice and take the second value, the 10k input impedance requirement could be relaxed and all resistances could be higher and draw lower quiescent current, but the reading probably gets noisy at some point which isn't obvious with much much more rigorous analysis or by prototyping the circuit.
Or one could just use the 74HC4051 and the hard part has been done by somebody better at this than I and using more appropriate technology.
Circuit cannot work as drawn, a BJT is not isolated from its base, so you are directly changing the
voltage by driving the base.
You need FETs to switch between dividers, they have an isolated gate.
Alternatively you can use PNP transistors to switch a single divider between the two voltage sources.
You'll have to level-shift to drive the PNPs, and an advantage is they will draw no current when not
active.
Something like this circuit, with two of them and a single load (being the voltage divider).
Thanks.....I have ordered the 74HC4051 so that I can it in the final project and adjust the breadboard so that I can work on the control in the meantime. Good thing about he 74HC4051 is that I can add a few more analog inputs
I tried anolog to I2C earlier, howeverr in the project I use 3 temperature sensors (DS18B20) that work with the OneWire libary. It appears that I2C and OneWire do not work together. Not sure if this is solved.
For the same reason I have a separate ESP8288 to show results on a small OLED screen.