Adding a switch



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.

piborg's picture

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.

Hi Im a bit of a newbie, is there a wiring diagram for adding a button pls?

piborg's picture

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's picture

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's picture

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.

Subscribe to Comments for "Adding a switch"