To configure Raspberry Pi system to interact with YKRUD you need to:
Select two available GPIOs. In this guide we will use GPIO 22 and GPIO 23 (pins 15 and 16 respectively) to connect with YKRUD.
For more information on the Raspberry Pi GPIOs refer to this page.
To configure the GPIOs use the following bash script.
Name the above script as gpio_setup.sh and save it to /home/user_name/bin/ folder. Note that "user_name" must be replaced by you actual user name in the above script.
The GPIOs should be configured automatically during the boot process. To ensure this add the following line to the /etc/rc.local script in your system.
The listener script will handle the interaction with YKRUD and trigger the poweroff Linux command when required to. It will be periodically monitor the YKRUD Out GPIO to check if the shutdown command was triggered by the user (through the pressing of the push button in YKRUD board). If so, it will execute a confirmation communication protocol with YKRUD and if everything is OK it will issue the Linux poweroff command.
Use the script bellow as the listener script.
Name this script ykrud.sh and save it in /home/user_name/bin.
Like the previous, this script should be called during the boot process. To achieve this add the following line to /etc/rc.local script.
To connect the YKRUD board to Raspberry Pi you need to:
Connect the YKRUD OUT pin to Raspberry Pi GPIO 22 (pin 15) and YKRUD IN pin to Raspberry Pi GPIO 23 (pin 16).
Note that you can use any other two GPIOs, just don't forget to reflect the change in the scripts shown above.
Connect the YKRUD 5V OUT terminal (mini USB) to Raspberry Pi power input (micro USB terminal).
The last step is to connect the power to YKRUD board. You can use the same power supply that you used to power the Raspberry Pi directly, or any other 5V power supply (e.g., cellphone charger).
By physically turning ON the power supply it will automatically power up Raspberry Pi.
With everything connected, when you turn ON the 5V power supply to YKRUD it will also power up Raspberry Pi. The LED will keep on blinking and once the boot process is complete (up to the point the ykrud.sh script is executed) the LED will stop blinking and stay continuously lighted.
To do a soft shutdown of the Raspberry just press once the push button. The LED will blink, halt for a short while and then it will start blinking again. If the LED suddenly stops blinking and stay continuously ON or OFF, press the push button again. Once the Raspberry Pi is off it will wait a short while and then it will cut the power to the Raspberry Pi board. At this point the YKRUD LED will turn off, but the YKRUD board is still powered on and working waiting for a press of the push button to power on the Raspberry Pi board triggering the boot process again.
For additional support, you can reach us through the form in our support page.
For more information and resources for the YKRUD board please visit the product page.