Open patman141414 opened 3 years ago
After the Current_Power_Readings = Status_Object.GetStatus()
and Battery_Charge = Status_Object.GetChargeLevel()
you should first check if the 'error' key is 'NO_ERROR'.
If not "data' contains an error message.
I guess this is what is happening.
Note that due to varying CPU load the clock varies and with it the I2C clock.
THis can cause errors in I2C transactions.
Thanks for the help, I will be sure to include code to check the 'error' key.
Is there anything that I would be able to do on my end to reduce the likelihood of those I2C transaction errors?
Which Pi are you using? On Pi4 in /boot/config/txt set core_freq_min=500 (provided you do not enable enable-tvout or 4kp60). This forces the freq to be constant at 500 (possibly at the expense of battery life).
On other models use force_turbo=1
in /boot/config.txt
I am using the PiJuice.py source code to pull values usually visible only in the PiJuice GUI and utilize them in my own python program for the purposes of active power monitoring, displaying battery info in my separate application, etc.
The base code below is how I am pulling this data from the source code. '
`
This code executes once every second while the program is running. Frequently, but not consistently, the following error is thrown.
I can't find a reason for this error at the moment, because when I print the value of 'Current_Power_Readings', the following value is outputted:
The key is very clearly 'data'. This error is also thrown for the variables 'Current_Battery_Charge' and 'Current_Rtc_Time_Minutes'. It happens seemingly at random and only affect the variables I have mentioned, even though there are other variables referencing the exact same array that don't throw the key error.
Once again, this error does not happen as soon as the program begins running, nor can I seem to isolate any condition which triggers the error.