Tutorials
Home > Learn > YKRUD Setup Guide
YKRUD SETUP GUIDE
To get started with the YKRUD board follow these steps:
1
Configure Raspberry Pi
2
Connect YKRUD board
3
Test it
CONFIGURE THE RASPBERRY PI

To configure Raspberry Pi system to interact with YKRUD you need to:

Configuring the GPIOs

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.

#!/bin/sh

#GPIO23 will connect to YKRUD IN
sudo echo "23" > /sys/class/gpio/export
sudo echo "out" > /sys/class/gpio/gpio23/direction

#GPIO22 will connect to YKRUD OUT
sudo echo "22" > /sys/class/gpio/export
sudo echo "in" > /sys/class/gpio/gpio22/direction

#Show YKRUD that raspi is OFF
sudo echo "0" > /sys/class/gpio/gpio23/value

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.

bash /home/user_name/bin/gpio_setup.sh

Setting up the listener script

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.

#!/bin/sh

sudo echo "1" > /sys/class/gpio/gpio23/value

while true
do
# checks if YKRUD OUT is set
ykrud_out=$(sudo cat /sys/class/gpio/gpio22/value)
if [ "$ykrud_out" = "1" ]; then
# put YKRUD IN Low
sudo echo "0" > /sys/class/gpio/gpio23/value
sleep 1
ykrud_out=$(sudo cat /sys/class/gpio/gpio22/value)
if [ "$ykrud_out" = "0" ]; then
# put YKRUD IN High
sudo echo "1" > /sys/class/gpio/gpio23/value
sleep 1
ykrud_out=$(sudo cat /sys/class/gpio/gpio22/value)
if [ "$ykrud_out" = "1" ]; then
# put YKRUD IN Low
sudo echo "0" > /sys/class/gpio/gpio23/value
sleep 1
# Power Off Raspberry Pi
sudo poweroff
fi
fi
fi
sleep 5
done

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.

bash /home/user_name/bin/ykrud.sh &
CONNECT THE YKRUD BOARD

To connect the YKRUD board to Raspberry Pi you need to:

Connecting YKRUD IN/OUT control pins to Raspberry Pi GPIOs

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.

Connecting YKRUD 5V OUT to Raspberry Pi Power In

Connect the YKRUD 5V OUT terminal (mini USB) to Raspberry Pi power input (micro USB terminal).

Connecting the power supply

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.

TEST IT

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.

This site uses cookies to enhance your experience. By continuing to browse the site you accept their use. To find out more read our cookies policy.
Not logged @YEPKIT
Need an account? Register here!
Forgot Password? Recover here!
€ Euro
$ US Dollar
£ British Pound
$ Australian Dollar
$ Canadian Dollar