[Edit:] This solution doesn't work, since the RRC Battery switches on Alarm_Mode every 60 seconds if it doesn't get reset according to the documentation:
The ALARM_MODE bit is automatically cleared by the Smart Battery electronics every 60 seconds so that any accidental activation of this mode will not be persistent. A SMBus Host which does not want the Smart Battery to be a master on the SMBus must therefore continually set this bit at least once per 45 seconds to keep the ALARM_MODE bit set.
But maybe someone finds this helpful:
The RRC2040 Smart Battery Pack per default is configured to regularly send charge information and alarm messages (for example low battery status). The battery switches from beeing a slave device to the master role to send these messages (it sends without beeing asked). In your case (and mine, too) these messages cause the Raspberry to boot.
According to the documentation (Page 20) you can switch off these status messages. You have to disable ALARM_MODE
and CHARGER_MODE
(0
enables, 1
disables).
In Python3 this can be achieved by:
import smbus2
bus = smbus2.SMBus(1)
def set_bit(value, bit):
return value | (1<<bit)
BatteryMode = bus.read_word_data(0xb, 0x03)
BatteryMode = set_bit(BatteryMode, 13) # disable ALARM_MODE
BatteryMode = set_bit(BatteryMode, 14) # disable CHARGER_MODE
bus.write_word_data(0xb, 0x03, BatteryMode) # Write BatteryMode
You can re-enable the broadcast messages with:
import smbus2
bus = smbus2.SMBus(1)
def clear_bit(value, bit):
return value & ~(1<<bit)
BatteryMode = bus.read_word_data(0xb, 0x03)
BatteryMode = clear_bit(BatteryMode, 13) # enable ALARM_MODE
BatteryMode = clear_bit(BatteryMode, 14) # enable CHARGER_MODE
bus.write_word_data(0xb, 0x03, BatteryMode) # Write BatteryMode
0xb
is the default address of the RRC Smart Battery.
Of course other devices could still wake the Raspberry, but for the RRC Battery this should solve the problem.
wake-from-halt
. I will see if I can reconfigure the PMM240 board in some way to prevent this unwanted behaviour.