Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
add_powerdevices_rpi_only [2020/08/21 00:05] lbrpdxadd_powerdevices_rpi_only [2024/02/25 03:12] (current) – [Table] dmanlfc
Line 1: Line 1:
-====== Add Powerdevices and Buttons to your Raspberry ======+====== Add Powerdevices and Buttons to your Raspberry Pi 1 - 4 ======
  
-To keep the price down, the Raspberry Pi Baird doesn't ship with a power button, yet it's easy to add your own! This guide will show you how to add a power button to your Raspberry Pi that can turn on/off your BATOCERA system. +**The Raspberry Pi 5 uses new GPIO code, the details below are not applicable to these boards** 
 + 
 +To keep the price down, the Raspberry Pi board doesn't ship with a power button, yet it's easy to add your own! This guide will show you how to add a power button to your Raspberry Pi that can turn on/off your BATOCERA system. 
  
 If you don’t want to build your own, several popular commercial options are available. They will add a power switch to your Raspberry Pu, sometimes provide a temperature-controller fan... and add a stylish look to your board.  If you don’t want to build your own, several popular commercial options are available. They will add a power switch to your Raspberry Pu, sometimes provide a temperature-controller fan... and add a stylish look to your board. 
  
   * Commercial Power Switches   * Commercial Power Switches
-    * provide real power cuts +    * Provide real power cuts 
-    * costs are around 10-25 USD +    * Costs are around 10-25 USD 
-    * usually need some space to build in+    * Usually need some space to build it in
  
   * Simple Buttons or latching switches   * Simple Buttons or latching switches
-    * very simple setup +    * Very simple setup 
-    * low cost +    * Low cost 
-    * no powercut possible+    * No powercut possible
  
-==== Why is a Raspberry Pi power button important? ====+===== Why is a Raspberry Pi power button important? =====
  
-You should never "yank" the power cord out of your Pi as this can lead to severe data corruption (and in some cases, physically damage your SD card). Even if BATOCERA is best prepared against file corruption it is recommended to safely shut down your Pi via BATOCERAs Quit Menu or even better, use a power button or switch +You should never "yank" the power cord out of your Pi as this can lead to severe data corruption (and in some cases, physically damage your SD card). Even if Batocera is best prepared against file corruption it is recommended to safely shut down your Pi via Batocera's **Shutdown** Menu or even better, use a power button or switch.
  
->Note: When we "shut down" the Pi, it will send it into a halt state, which still consumes a very small amount of power. This is similar to how all modern computers work. In this guide walk through the process of adding a power button that will both halt and wake the Pi up from halted state. Additionally, after your Pi has shut down, you can safely disconnect the power supply (should you desire) without the worry of data corruption.+<WRAP center round info> 
 +When Batocera "shuts down" the Pi with a simple button/latching switch, it will send it into a halt state, which still consumes a very small amount of power. This is similar to how all modern computers work. In this guide we will only go into halt state so that we can still power it up again later without having to replug the power sourceYou can safely disconnect the power supply (should you desire) without the worry of data corruption while in the halt state. 
 +</WRAP>
  
-==== Commercial Power Switches ====+This method gives the best user experience if you use the GPi-case from Retroflag for example. This nice housing only has one button switch to simply turn on/off the Raspberry. Since Batocera 5.25 the OS is best prepared for all kinds of power devices connected to the Raspberry. But you will lose your game SRM save (your in-game save file) if you just trigger the power button //inside// a game session.
  
-Here are some commercial powerdevices that are currently supported. These offer a real power cut, that means the Raspberry is really switched off. Usually these small power devices are plugged on top of the Raspberry using it's 40 Pin header. For further install instruction use the links provided.+===== Save data protection =====
  
-^Device Name                 ^system.power.switch   ^Where to buy and additional help to install                                       ^SideNotes^ +  - Download the provided script below 
-|ATXRaspi                    |ATX_RASPI_R2_6        |http://lowpowerlab.com/atxraspi/#installation|                                    | +  Save this to ''/userdata/system'' 
-|Mausberry Circuits          |MAUSBERRY             |http://mausberry-circuits.myshopify.com/pages/setup|                              | +  Set executable bit with ''chmod +x /userdata/system/custom.sh'' 
-|Pimorini OnOffShim          |ONOFFSHIM             |https://shop.pimoroni.com/products/onoff-shim|                                    | +  Setup your power device according to further below
-|msldigital PiBoard r2013    |REMOTEPIBOARD_2003    |http://www.msldigital.com/pages/support-for-remotepi-board-2013|                  | +
-|msldigital PiBoard r2015    |REMOTEPIBOARD_2005    |http://www.msldigital.com/pages/support-for-remotepi-board-plus-2015|             | +
-|UUGear Witty Pi             |WITTYPI               |http://www.uugear.com/witty-pi-realtime-clock-power-management-for-raspberry-pi| +
-|Retroflag Cases             |RETROFLAG             |http://www.retroflag.com                                                          |enable UART in config.txt for LED action| +
-|Argon One for RPi4          |ARGONONE              |https://www.argon40.com/argon-one-raspberry-pi-4-case.html                        |see below for more details|+
  
 +<code bash| custom.sh>
 +#!/bin/bash
 +# custom.sh - place to /userdata/system
 +# by cyperghost 23/11/19
 +#
  
-==== Simple pushbutton or switches ====+if [[ $1 == stop ]]; then 
 +    batocera-es-swissknife --emukill 
 +fi 
 +</code>
  
-It is possible to add a button to turn on and turn off your BATOCERA console properly! But how?+===== Commercial Power Switches =====
  
-==== Which button to use? ====+Here are some commercial power switches/commercial cases with power switches that are currently supported. These offer a real power cut, that means the Raspberry is really switched off. Usually these small power devices are plugged on top of the Raspberry using it's 40 Pin header. For further install instruction use the links provided.
  
-You can add a power button to switch on/off BATOCERA. The button can be either a push button (momentary button) or a switch button (latching switch).+Here are the values you can put as ''system.power.switch=<value_below>'' in ''batocera.conf'': 
 + 
 +^ Device Name                                    ^ system.power.switch  ^ Where to buy and additional manufacturer information                                                                                   ^ Notes related to Batocera                                                                 ^ 
 +| Argon One for RPi4                             | ARGONONE             | https://www.argon40.com/argon-one-raspberry-pi-4-case.html                                                                             | [[add_powerdevices_rpi_only#argon_one|Get more details here]]                             | 
 +| ATXRaspi                                       | ATX_RASPI_R2_6       | http://lowpowerlab.com/atxraspi/#installation                                                                                          |                                                                                           | 
 +| DeskPi Pro case                                | DESKPIPRO            | https://deskpi.com/collections/frontpage/products/deskpi-pro-for-raspberry-pi-4                                                        |                                                                                           | 
 +| Mausberry Circuits                             | MAUSBERRY            | http://mausberry-circuits.myshopify.com/pages/setup                                                                                    |                                                                                           | 
 +| msldigital PiBoard r2013                       | REMOTEPIBOARD_2003   | http://www.msldigital.com/pages/support-for-remotepi-board-2013                                                                        |                                                                                           | 
 +| msldigital PiBoard r2015                       | REMOTEPIBOARD_2005   | http://www.msldigital.com/pages/support-for-remotepi-board-plus-2015                                                                                                                                                             | 
 +| OneNineDesign Powerhat                         | POWERHAT             | https://github.com/redoakcanyon/HATPowerBoard                                                                                          |                                                                                           | 
 +| Pimoroni OnOffShim                             | ONOFFSHIM            | https://shop.pimoroni.com/products/onoff-shim                                                                                          |                                                                                           | 
 +| UUGear Witty Pi                                | WITTYPI              | http://www.uugear.com/witty-pi-realtime-clock-power-management-for-raspberry-pi                                                        | Script uses WiringPi.                                                                     | 
 +| Retroflag cases                                | RETROFLAG            | http://www.retroflag.com                                                                                                               | **NEW** NESPi4 support! [[add_powerdevices_rpi_only#retroflag|Get more details here.]]    | 
 +| Retroflag cases with buttons                   | RETROFLAG_ADV        | http://www.retroflag.com                                                                                                               | Same as the previous one, except the button can trigger actions, like stopping emulators 
 +| Retroflag GPIO case                            | RETROFLAG_GPI        | https://www.retroflag.com/GPi-CASE.html                                                                                                | [[:choose_a_handheld#retroflag_gpi_case|Get more details here.]]                          | 
 +| Kintaro Super Kuma/Roshambo Retro Gaming case  | KINTARO              | https://www.amazon.com/dp/B079T7RDLX/?tag=electromake-20 / https://www.electromaker.io/blog/article/roshambo-retro-gaming-case-review  |                                                                                           | 
 +| Pironman Raspberry Pi 4 Case                   | PIRONMAN             | https://www.sunfounder.com/products/raspberry-pi-4-case                                                                                | Run pironman from the terminal to configure the OLED, RGB & Fan                           | 
 + 
 +===== Simple push-button or switches ===== 
 + 
 +It is possible to add a button to turn on and turn off your Batocera console properly! But how? 
 + 
 +==== Which GPIO PIN should I use? ==== 
 + 
 +You can add a power button to switch on/off Batocera. The button can be either a push button (momentary button) or a switch button (latching switch).
 Note on the push buttons: some GPIO have resistors pull-up built-in (resistors connected to the + 3.3V), so it is preferable to use switches normally open (abbreviated NO) with these pins. Note on the push buttons: some GPIO have resistors pull-up built-in (resistors connected to the + 3.3V), so it is preferable to use switches normally open (abbreviated NO) with these pins.
  
 {{ batocera_pin56.png?400 |}} {{ batocera_pin56.png?400 |}}
  
-to connect the switch to the Raspberry Pi GPIO, plug a PIN on the GPIO3 (physical PIN 5 above on the left) and another on the mass located just to the right on the right (physical PIN 6):+to connect the switch to the Raspberry Pi GPIO, plug a PIN on the GPIO3 (physical PIN 5 above on the left) and another on the mass located just to the right on the right (physical PIN 6)
  
 ===== Activation of the switch ===== ===== Activation of the switch =====
  
-==== Manual ====+==== GUI Menu Mode ==== 
 + 
 +Get a terminal window by quitting EmulationStation with a Keyboard or get a [[access_the_batocera_via_ssh|access to terminal by SSH]]. Now enter  ''/etc/init.d/S92switch setup'' and you will see a terminal window like in picture below. From there you can select and activate your power or switch device. The script will show you an already activated device (**ONOFFSHIM** in this case) and will latter show you a small message box, if the value setup was successfully set up. After this reboot the device and everything should work fine. 
 + 
 +{{ 65899397-ef014600-e3b3-11e9-9465-ce7629125e19.png?nolink&600 |}} 
 + 
 +==== Manual activation ====
  
 Check in the table above what is the type of power switch you need.  Check in the table above what is the type of power switch you need. 
Line 59: Line 96:
   * For a latching switch edit batocera.conf with your preferred text editor and add ''system.power.switch=PIN56ONOFF''   * For a latching switch edit batocera.conf with your preferred text editor and add ''system.power.switch=PIN56ONOFF''
   * Reboot the system   * Reboot the system
-  * Alternatively, if you don’t want to edit the file and you are logged in with SSH or you've a terminal open then enter+  * Alternatively, if you don’t want to edit the file and you are logged in with SSH or you have a terminal open then enter:
  
-    batocera-settings --command set --key system.power.switch --value PIN56ONOFF+    batocera-settings-set system.power.switch PIN56ONOFF 
 +     
 +then reboot. Your Batocera system can now be turned on/off with a button!
  
-Your BATOCERA system can now be turned on/off with a button!+==== Retroflag ====
  
-==== GUI Menu Mode ====+Retroflag is the manufacturer who takes focus on retro case for Raspberry Pi series and for origin looking retro game controllers. In the last years they've managed to bring some pretty nice looking housings to the market. These are inspired of gaming devices from the golden era of game consoles. If you are a proud owner of [[Retroflag GPicase|a GPicase]], then take a look here. 
 +Besides the nice looking there are **always** working buttons for power and/or reset possible. But you have to take a few steps there.
  
-Get a terminal window by quitting EmulationStation with a Keyboard or get a [[access_the_batocera_via_ssh|access to terminal by SSH]]Now enter  +  - Enable the **Safe Shutdown Switch on the PCB**! This small switch depends on the used housing, refer to the shipped manual from Retroflag how to do this
-  ''rpi_gpioswitch'' or  +  - Edit ''batocera.conf'' and set the correct switch mode. 
-  * ''/etc/init.d/S92switch setup''  +    You can edit the config file from SAMBA share with your dedicated text editor 
-and you will see a terminal windows like in picture down. From there you can select and activate your power or switch device. The script will show you an already activated device (**ONOFFSHIM** in this case) and will later show you a small message boxif the value setup was successfully setted upAfter this reboot the device and everything should work fine.+    * or use SSH and you can edit the config file with ''nano /userdata/system/batocera.conf'' 
 +    or [[add_powerdevices_rpi_only#gui_menu_mode|use the GUI mode]], you need SSH for this methodtoo. 
 +  - Activate or Select the correct powerswitch ''system.power.switch=RETROFLAG'' 
 +  - Reboot, this will activate the Safe Shutdown feature
  
-{{ 65899397-ef014600-e3b3-11e9-9465-ce7629125e19.png?nolink&600 |}}+<WRAP center round info> 
 +**For the NESPi 4 case only**
  
 +You have to do an additional reboot!
 +Sorry guys, but we need to make an autoconfig behind the scenes!
 +</WRAP>
 +
 +Also, for the NESPi4 case, you might experience some sluggishness using the HDD/SSD "cartridge". Here is [[https://www.reddit.com/r/RetroPie/comments/i9f45b/retroflag_nespi_4_ssd_boot_slowness_and_workaround/|a Reddit link]] that gives you a way to fix it (even if the reddit post was written for RetroPie, it has been reported as OK on Batocera too).
  
 ==== Argon One ==== ==== Argon One ====
  
-By default, the fan starts at 55 degrees Celsius. Your can define own temperature/fan speed ladder by editing the file ''/userdata/system/configs/argonone.conf'' (it can be also edited from the networkvia the SHARE SMB folder).+Activate the Argon One fan by adding ''system.power.switch=ARGONONE'' in the configuration file ''batocera.conf'' and that's it. Don't use any external script, the support for Argon One is already included in the Batocera Linux distribution.  
 + 
 +By default, the fan starts at 55 degrees Celsius. Here is the default fan curve configuration: 
 + 
 +<file argonone.conf
 +# Configuration file for Argon One Pi4 case 
 +# temperatures are in Celsius 
 +# fan_speed are from 0-100 percent 
 +# syntax is: temp_threshold=fan_speed 
 +# default is: 
 +45=0 
 +55=10 
 +60=55 
 +65=100 
 +</file> 
 + 
 +With this fan curve configuration, the behavior would be as follows: 
 +  - At lower than 55°C, the fan is off 
 +  - At 55-59°C, the fan runs at 10% speed 
 +  - At 60-64°C, the fan runs at 55% speed 
 +  - At 65°C and higher, the fan runs at 100% speed 
 + 
 +From the vendor recommendations, it is safe to start the fan at 55 degrees onlyLess noisy. ;-)
  
-  # Configuration file for Argon One Pi4 case +You can define own temperature/fan speed ladder by creating a new ''argonone.conf'' file at ''/userdata/system/configs/argonone.conf''.
-  # temperatures are in Celsius +
-  # fan_speed are from 0-100 percent +
-  # syntax is: temp_threashold=fan_speed +
-  # default is: +
-  45=0 +
-  55=10 +
-  60=55 +
-  65=100+
  
-With this ladder, fan starts at 10% when reaching 55 degrees, and rises up to 100% when reaching 65 degrees Celsius.  
-From the vendor recommendations, it is safe to start the fan at 55 degrees only. Less noisy. ;) 
  • add_powerdevices_rpi_only.1597961143.txt.gz
  • Last modified: 4 years ago
  • by lbrpdx