I have a SPST rocker switch I would like to add in between the battery pack and the Battborg module. Is it ok to wire this straight in or do I need any other components.
However, just flicking the switch will turn the PI off and potentially corrupt the SD card. Is there a away to detect the switch off and then shutdown the OS before power is disconnected (like the MOPI)?
You would need to make a circuit which signals a GPIO pin to warn that the power will be disconnected soon before actually disconnecting the power. This is a bit tricky as each Pi and distribution have different shutdown times so you would need to allow for whatever your worst case is.
While it is possible to corrupt an SD card this way we have quite a few robots which we do this to fairly regularly without issues. The worst we have seen is that a log file we have been writing to is missing the last two or three minutes of log messages. Typical experience is the last ~30 seconds of writes to the card get lost (the files are still intact).
Generally if you are not writing to the SD card you should not see any corruption regardless, it happens when power is interrupted mid-write at the hardware level.
piborg
Thu, 04/23/2015 - 21:36
Permalink
SPST switch
You should be fine wiring the switch in between without any additional components.
You will want to put the switch on the V+ wire ideally.
ed7919
Fri, 05/05/2017 - 11:22
Permalink
Hi Im a bit of a newbie, is
Hi Im a bit of a newbie, is there a wiring diagram for adding a button pls?
piborg
Fri, 05/05/2017 - 16:26
Permalink
BattBorg with a switch
The switch is really easy to wire in, it just connects between the battery pack and the screw terminals. Quick picture of the wiring below.
vfunnell
Mon, 09/25/2017 - 21:42
Permalink
What about safe shutdown of OS when switch activated
Hi - this info is great.
However, just flicking the switch will turn the PI off and potentially corrupt the SD card. Is there a away to detect the switch off and then shutdown the OS before power is disconnected (like the MOPI)?
piborg
Tue, 09/26/2017 - 10:31
Permalink
Not without making a circuit
You would need to make a circuit which signals a GPIO pin to warn that the power will be disconnected soon before actually disconnecting the power. This is a bit tricky as each Pi and distribution have different shutdown times so you would need to allow for whatever your worst case is.
While it is possible to corrupt an SD card this way we have quite a few robots which we do this to fairly regularly without issues. The worst we have seen is that a log file we have been writing to is missing the last two or three minutes of log messages. Typical experience is the last ~30 seconds of writes to the card get lost (the files are still intact).
Generally if you are not writing to the SD card you should not see any corruption regardless, it happens when power is interrupted mid-write at the hardware level.