I purchased this power supply https://www.raspberrypi.com/products/type-c-power-supply/. It’s the official power supply so I thought it would be good. Now I am hearing all these stories about what happens when you unplug your power supply and how it can do harm to your raspberry pi and components. The official power supply doesn’t have an on and off button so what is the safest way to turn off your raspberry pi without a power button?
2 Answers
You've mixed two different issues it seems:
For reasons of cost the RPi does not have a built-in power switch like your typical laptop and desktop computers do. Whenever power is supplied to the RPi (via the connector or 5V pin on the header), the RPi will consume power. The RPi has no sleep mode - again due to the cost.
The power supply has a single function: it converts mains (ac) power into 5 Volts DC and can maintain this voltage at its rated maximum load - about 3 Amps. This scheme for powering the RPi is also is driven by cost.
You can buy a power supply from other vendors that has a power switch built into the cord, but you should not remove power from your RPi until you have halted the processor.
Why? Obviously all processing is stopped when power is removed, but because the processor was not instructed to halt
processing before power was removed, there is a risk that your filesystem may be corrupted. The proper two-step sequence is this:
- Issue a
halt
command; this may be done from the terminal as follows:
$ sudo halt
- Pull the power plug, or flip the OFF switch to remove power from the RPi. When you re-apply power, the RPi will sense this, and enter boot mode.
-
Turning off power while a write to the SD card is in progress can corrupt the SD card. So after entering "halt", wait several seconds for all writes to complete before disconnecting power. Is does not matter whether you disconnect power by unplugging or by using an off switch on the power cord. If you turn off power without shutting down the RPi to force the SD to be idle, eventually you will cause a problem. Commented Apr 8, 2022 at 5:10
No unless you want one. It was designed for continuous operation. It has short circuit, overcurrent and over temperature protection built in. You can add a switch circuit if you like for your convenience. You state "I am hearing all these stories about what happens when you unplug your power supply," the same thing would happen with a switch if in the primary side of that unit, same as unplugging it. There are switches available that go in series with the 5V power cord. To connect you plug the power into the switch and the switch into the pi. That would be probably the best solution if you want a switch.