How can i get the voltage on pin VIn?
I am using an electron and i want to detect the voltage on Vin so i can publish it.
Fuel.getVCell gets the voltage of the small 3.7V lipo plugged into the Electron, but I need to know the voltage on Vin because I am supplying it with 5V from a solar backup battery.
The PMIC must know the voltage on VIn because it decides when to use what input for charging, however the documentation on the PMIC is incomplete, it doesnt explain how we can extract this from its registers.
I could also power the Electron off the USB and measure that voltage, but I dont see any way of reading that voltage either.
It’s not possible to read a voltage value from the bq24105.
The reason is that the bq24105 doesn’t use an ADC to read the value and decide whether to use VBUS or battery, it uses a DAC to generate a reference voltage and uses a comparator.
You can use a voltage divider and connect VIN to an unused Electron analog input. Make sure you use a voltage divider since the maximum voltage on an analog input is 3.3V, not 5V.
Thanks RWB and thanks for your tips on solar, I am building a river water level monitoring system for our kayaking club so we know which rivers to visit on the weekends!
my challenge is the lidar sensor needs 4-6v it doesn’t work when powered from the 3.7 lipo, so i will use an external 5v supply which will also charge the electron.
I have put the lidar power supply on a mosfet to turn it off .
Currently using 4xAA re-chargeables which I will also connect to a PV.
I tried your code to check battery levels before turning on the celluar, I got myself in knots trying SEMI_AUTOMATIC mode so I’m using full AUTOMATIC, but before going back to sleep, I check battery level and if its below certain levels I tell it to sleep for longer.
My problem is I also need to monitor the voltage of the 4xAAs because that is more representative of available power.
Everything has to be extremely small and discreet because it will be glued underneath a bridge over the river, and the kids in those areas will steal it or destroy it for fun if they notice it!
The rivers are about 4 hours away so once installed, thats it! It better work!!
I would connect the boost regulator to the Li input pin which connects to the LiPo battery directly.
Then make sure you use a pin to put the regulator to sleep when it’s not being used and make sure your regulator is like the one I linked to that only consumes 1uA when disabled to prevent excessive battery drain.
You can easily measure the voltage on the Vin pin and publish it. I made a 10:1 voltage divider using a pair of 18k ohm 1% resistors in parallel connected between Vin and A1 and a single 1k ohm 1% resistor connected from A1 to Gnd. This works great for measuring the external voltage. Just multiply whatever value you get by 10.