filipmu / Raspberry-Pi-Battery-Power-Monitor

Monitors voltage, current, and power of a battery and if voltage goes below a threshold, shuts down the Raspberry Pi
Apache License 2.0
2 stars 1 forks source link

`Unprivileged users are not permitted to log in anymore` After installing the scripts #2

Open eimparas opened 2 months ago

eimparas commented 2 months ago

hello i installed the scripts as per the instructions and executing battery i got image

after a reboot i connected the battery on the sensor and when trying to login from SSH i get :

System is going down. Unprivileged users are not permitted to log in anymore. For technical details, see pam_nologin(8).

or the hdmi gives me : image I am giving power to the INA chip and i have wired it as you suggested.

Any ideas are appreciated

eimparas commented 2 months ago

got back to shell by booting up without the sensor attached.

i had VBS connected to the in+ but it read 0 Volts!

Any ideas ?

eimparas commented 2 months ago

Just in case i have hocked somthing up wrong here is a photo of the setup : image

Here is a quick sch explanation . image Im powering it from my bench psu and i have connected the sensor first to a test load so i can manage currents a bit better than connecting to my portable pi circuit for debuging (that would be hell). To connects the Bench PSUs GND with Pi GND i have a dupond wire from the test lead to the Breadboard (that orange one) .

Hope its clear enough

filipmu commented 2 months ago

The system going down message is as expected when the voltage is low, because the script is meant to protect the batteries from full discharge by initiating a shutdown. You could edit the script changing the cutoff value to -1v so it does not shut off to debug.

I am surprised that In+ is reading 0v on a voltmeter, when your supply is clearly providing current. The In+ terminal is connected to the PSU + terminal with a trace on the board. Is PSU+ terminal reading 0v too? Maybe the trace is broken?

VBS is the terminal that measures the voltage and its acting like its at 0v. Can you measure that terminal? You could disconnect VBS from IN+ and connect VBS with a wire to wherever you can get a voltage of the PSU+. Even a small battery to VBS and GND should cause a voltage reading.

What seems to be working is INA226 IC is powered, IC communication, current measurement is happening, script behaving as it should. Voltage is the problem.

My guesses:

eimparas commented 2 months ago

The system going down message is as expected when the voltage is low, because the script is meant to protect the batteries from full discharge by initiating a shutdown. You could edit the script changing the cutoff value to -1v so it does not shut off to debug.

I would sugest to add a "FirstRun" / "Calibration" / "No Shutdown" mode , that would also calibrade the battery capacity (or perhaps i missed it if there is any way to add it ) so it would prevent from these situations in case of no voltage reading

I am surprised that In+ is reading 0v on a voltmeter, when your supply is clearly providing current. The In+ terminal is connected to the PSU + terminal with a trace on the board. Is PSU+ terminal reading 0v too? Maybe the trace is broken?

Same the mondule comunicates with the Pi , reports the drawn mAh but no voltage ! I have tried to connect with that white wire the VBS pin to the PSUs Vcc "crocodile" clip , so to bypass any traces on the mondule but no luck .

VBS is the terminal that measures the voltage and its acting like its at 0v. Can you measure that terminal? You could disconnect VBS from IN+ and connect VBS with a wire to wherever you can get a voltage of the PSU+. Even a small battery to VBS and GND should cause a voltage reading.

The terminal on the pin header has the correct voltage , i didnt measure the IC pin if it has voltage ,so to eliminate bad traces. will do tomorow

What seems to be working is INA226 IC is powered, IC communication, current measurement is happening, script behaving as it should. Voltage is the problem.

Thats the conclustion im drawn too . i have 2-3 more INA226 ICs on the mail , expecting to arrive in the morning . will test with them and report back .

Thanks for the help

eimparas commented 2 months ago

Hello again @filipmu Im back with the tests

1. Test with new IC.

I had orderd 4 breakout boards, one came damaged, the 2nd was the one i initialy tested with, then the other is the one i tested now. Both report Amps , and 0 volts.

2. Measure voltage on the VBS pin .

Voltages check out fine between VBS and GND, Even on the IC itself , not only on the breakout: image

Honestly im out of ideas . At this point with all i know it could be that i run into a problematic batch..

3. Same issues :

I found the followin threads on varius sites talking about a similar issue , but on the arduino side ,

https://forum.arduino.cc/t/defective-ina-226-solved/622085

https://e2e.ti.com/support/amplifiers-group/amplifiers/f/amplifiers-forum/583150/ina226-ina226-about-the-current-the-voltage-and-the-power-detection-issues

https://arduino.stackexchange.com/questions/38108/problem-with-arduino-and-ina226-power-meter-module

They seem to fix the issue with diferent programing . Could there be a issue with the scripts?

filipmu commented 2 months ago

Those threads refer to current measuring issues it seems, which depends on the particular resistance pick. You are reading the current fine.

I looked at my own wiring and it's the same as yours where it counts (my load is a switching regulator)

Are you sure the ground of the PSU is attached to the ground of the ina-226 board? if not you would still read a current but no voltage wrt the rpi ground. Test by using a meter between the ground of the ina-226 board and the vbs terminal of the board.

The only other thing I can think of is the rpi OS. I run bullseye on the Pi Zero W. But I don't think that would impact just the current. I looked at the script and thought maybe it was running out of shared memory because your current is higher than I track (<200ma), adding more digits, but it's not that because the CPU temp is coming through and stored after the voltage in the shared memory. Except for the shared memory between the two programs, the code is pretty straightforward.

I think it might be a bad ground connection in the proto board or the clip leads.

eimparas commented 2 months ago

Those threads refer to current measuring issues it seems, which depends on the particular resistance pick. You are reading the current fine.

Yes , silly me i read voltage detection issues and got confused..

Are you sure the ground of the PSU is attached to the ground of the ina-226 board? if not you would still read a current but no voltage wrt the rpi ground.

Yes , it is , look this picture :

IMG_20240731_232043

that orange wire goes from the GND pin on the IC breakout to the GND of the PSU (ps , i know usualy we use black wires as ground but these pesky dupont wires always disappear when you need them )

If i probe GND on the pi (eg. the HDMI sheild or its gnd pins on the gpio) and the VBS pin i do indeed get my psu's voltage.

The only other thing I can think of is the rpi OS. I run bullseye on the Pi Zero W. But I don't think that would impact just the current

im running latest pi os . And now you gave me a idea , to get a arduino , install the library and use a example scetch instead of the Pi just to see if it will report voltage. thus to rule out hw failure .

Lastly , if you could explain why this needed to be sutch elaborate with inner prosses coms etc ? i dont consider my self a "noob" on programing , although im better at Hardware desing i know my ways around python and C and i found your implementation a bit confusing id appreciate it if you explain the rational behind

eimparas commented 2 months ago

Helllo ! 😎 image

as i said, i went ahead and tested with al the breakouts i had ordered on a Arduino instead of a Pi , for faster debugging (wouldn't have to wait for system boot , terminal etc ) . I used this Library and the 3 chips i initially tested on the pi showed 0vbus on the Arduino too . Thus i ruled a Hw failure. Proceed to check my remaining stock and i found a IC that would work!

Connected it all up back to the pi and i got vbus !

(i wont close this issue yet , somehow now its displaying current useage with no current flowing through the shunt , i dont have time now , will test later tonight )

@filipmu thank you for your help!