Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects
Notifications
Clear all

Vin low voltage cutoff not adjusting

10 Posts
2 Users
0 Likes
102 Views
(@matt-schneider)
Posts: 8
Active Member Customer
Topic starter
 

Hello, I have a WittyPi 4 mini with a Pi Zero W and have wired all three wires on P2, including Pin to the battery (USB-C un-populated).  Regardless of what I set the low voltage cutoff, as well as adjust the calibration of Vin, WittyPi 4 turns off the pi always at 2.0V at Vin.  Good news is the low voltage cutoff is indeed working, but I can't adjust it to be 2.5V (for LFP).  Again, I tried many variations of the low voltage cutoff, as well as multiple Vin calibration adjustments, and it turned the pi off at very near 1.9 to 2.0Vdc.

Is there a "apply changes" button that I'm not hitting?  I can see the values displayed in the menu, so it seems WittyPi is taking my values.  It is just not listening to them, and always turning off the pi at <2.0V.

Thanks for the help!

 
Posted : 25/05/2025 5:37 am
(@admin)
Posts: 611
Member Admin
 

2.0V is a very low voltage and is already way lower than the MCU's normal working voltage (3.3V). From your description I can not tell if the system was gracefully shut down, or directly power cut due to really low voltage on the MCU. Anyway, although the software allows to set low voltge threshold to 2.0V, the input voltage should never go this low.

Witty Pi 4 Mini doesn't have a DC/DC on board, but you may use the Vin pin to monitor a voltage.

According to your description, it seems you are using a power bank (which has USB-C port removed) as power source. Your Vin pin needs to monitor the raw battery's voltage, instead of the 5V output. Usually the power bank will maintain the output voltage (5V) until the battery runs out. Monitoring the 5V output from power bank will not achieve what you want.

 
Posted : 25/05/2025 9:20 am
(@matt-schneider)
Posts: 8
Active Member Customer
Topic starter
 

Thanks for the reply.

More details on system:

On P2 all three terminals are connected, 5V/Gnd are connected from an external DCDC providing 5Vdc all the time, and Vin is connected directly to the battery. The battery supplies the DCDC with power.  The wittypi USB-C connector is not connected, since power comes in via the P2 pins.

The source of energy is solely an 18650 lithium iron phosphate (LFP) battery, that feeds a DCDC, which then feeds wittypi.

What I am hoping for is for the wittypi to turn off the pi when the battery voltage, measured by Vin, goes below 2.5Vdc.  But as described above, wittypi only turns off the pi when the voltage at Vin drops below 2.0Vdc, regardless of the settings I set in software.  

Note that the pins 5V will always have 5V to it, and so the wittypi should have plenty of voltage at all times.

Thanks again.

 
Posted : 26/05/2025 4:50 am
(@admin)
Posts: 611
Member Admin
 

@matt-schneider Your wiring seems correct, however 2.5V low-voltage threshould is really too low for a 18650 battery: it should be set to at least 3.0V.

The recommended 3.0V is the minimum discharge voltage for 18650 battery. Although some 18650 batteries claims 2.5V instead, it is not always true and 3.0V is a safer value.

Also you may need to consider your DC/DC, can it still work properly when voltage drops under 3V? Some DC/DC may not output stable voltage in such case and may cause the MCU to hang.

 
Posted : 26/05/2025 7:03 am
(@matt-schneider)
Posts: 8
Active Member Customer
Topic starter
 

@admin The specific chemistry of the 18650 is lithium iron phosphate (LFP), which has a different allowed voltage range than other lithium chemistries.  LFP batteries are charged up to 3.6V for 100%, and depleted down to 2.5V for 0%, and the nominal flat part of the curve is around 3.2V.  So, I am hoping to achieve an additional level-of-protection from under-voltage by having wittypi turn off the pi if the battery voltage via Vin goes below 2.5V.

The DCDC that I am using puts out a reliable 5.13V with an input voltage as low as 1.8V.  I have this system setup and am monitoring all voltages while varying the battery voltage using a power supply in its place, temporarily.

I attempted setting the low voltage cutoff at 3.0V, but that also didn't work, as the cutoff was still at 2.0V.  I did this thinking that possibly wittypi's ADC had an offset, but that did not appear to be the case.  I also tried to scale the Vin ADC value, but again I saw no change in result, it always has a cutoff at 2.0V.

Is there a way for me to see what the ADC value is for Vin?  via wittypi.sh I can see the value of Vout (to the pi), but in none of the selections could I see a value for Vin (so that I can be sure its measuring a voltage correctly).

 
Posted : 26/05/2025 6:07 pm
(@admin)
Posts: 611
Member Admin
 

@matt-schneider Vin data can be accessed via I2C register 1 and 2: https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L48-L49

You can get their value with

i2cget -y 1 0x36 1

i2cget -y 1 0x36 2

For example, if register 1 is 0x03, register 2 is 0x05, then Vin is 3.05V

 
Posted : 27/05/2025 6:20 am
(@matt-schneider)
Posts: 8
Active Member Customer
Topic starter
 

@admin Thanks, that was helpful.  I was able to read the I2C registers.  From this I see two potential items that might be the cause of my root issue: which is, having the wittypi turn off the pi at 2.5V, instead of it always turning off at 2.0V.  

a) I had to change the address to 08 from 36, per your example above.  Is there somewhere where I confirm this address is configured properly in wittypi?

b) some of the values to the right of the decimal had letters in the last position (see below).  Although my known Vin value matches these I2C values decently well, I'm worried that the intermittent letters are having an impact on the voltage triggering - somehow forcing it to always shutdown the pi at 2.0V, instead of the set trigger of 2.5V.

Thanks for your ongoing support!

 
Posted : 29/05/2025 5:29 am
(@admin)
Posts: 611
Member Admin
 

From your screenshot I can see your Witty Pi's I2C address has been changed to 0x08, otherwise you wouldn't get the values from I2C registers.

i2cget command prints the value in HEX format. If register 1 is 0x03 (3), register 2 is 0x3f (63), then Vin is 3.63V

In the firmware, the integer part and decimal parts are always updated together. The low voltage detection is also done in the firmware. The register value read by i2cget command would not affect the logic on the firmware side.

1748494114-values.png
 
Posted : 29/05/2025 6:48 am
(@matt-schneider)
Posts: 8
Active Member Customer
Topic starter
 

@admin Ok, knowing they are in hex (sorry for not looking that up first), the ADC values appear to be quite close to my measured values, within -/+ 0.01V.

I confirmed the low voltage threshold was set (here set to 3.0V), then measured the battery voltage via Vin and I2C and compared to the known DMM measured value (see screen grab below).  So the Vin-vs-DMM values are quite close.  But, when we went below the 3.0 low voltage cutoff, the pi did not shutdown.

Is there anywhere else I can look, to confirm I have everything properly setup?

 
Posted : 30/05/2025 3:22 am
(@admin)
Posts: 611
Member Admin
 

@matt-schneider In such case I would suggest to look into the firmware source code, where the low voltage detection is done:

https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L954-L977

I think you will need to set the I2C_CONF_IGNORE_POWER_MODE register to 1, because you are using fixed 5V (power mode is 0), and you want to perform low voltage detection on VIN.

 
Posted : 30/05/2025 7:45 am
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.