Turn Raspberry Pi ON W/ Remote Control

Introduction: Turn Raspberry Pi ON W/ Remote Control

I'm loving using my Pi with Openelec for my media center, but the need to pull the cord to cut power was just keeping it below the WAF(Wife Acceptance Factor). So I sat down and came up with this. In the future, the arduino will be replaced with an ATTiny, but for now I already had this on hand.

First off, I will start with what does NOT work...

Step 1: What Does NOT Work

Rule #1 for my design was that the Pi should need NO software or modification for this to work. One should be able to hook up any Pi with an operating system on it and have it work. This eliminated almost every option out there right now.

In my researching, I learned that the UART TX pin goes high on bootup, and stays that way, until a shutdown is completed, and then it goes low. I spent some time going with that, but it ultimately was a dead end. The Pi knows it is high/low, but the arduino/microcontroller still just sees a floating pin, regardless of the configuration.

Step 2: What DID Work

In the end, I realized that using an arduino/microcontroller to sense a digital high/low on the Pi was not going to work, BUT it did lead me to the right path... When a pin on the Pi is high, it is outputting ~3.3v, but when it goes low, it drops to under 1v, so I just needed to connect a ground between them, and watch for the voltage to drop under 3v using an analog pin.

Step 3: The Bad Schematic

The schematic above was drawn to help, but it's pretty bad, so I will spell it out...

+5v to Arduino
+5v to Relay

Ground to Arduino

Ground to Relay

Arduino Ground to Raspberry Pi Ground

Arduino Ground to IR Receiver Ground

Arduino 5v to IR Receiver Vcc

Arduino pin 11 to IR Receiver OUT

Arduino pin 5 to Relay IN1

Arduino pin A0 to Raspberry Pi pin 8(UART TX)

Relay out inline with Raspberry Pi power input

Step 4: The Arduino Code

First off, you will need to delete the IRRemoteRobot libraries that are built in to the Arduino software, and then install the IRRemote libraries included here. Then program your Arduino with the IR Decoder code. This will show you the HEX codes of the IR signals in Serial.print. Find the Hex code of the button you want to use to turn on your Pi.

Then edit the "PI Power.ino" code by changing the variable "const long StoredCode". Leave the "0x" and change the Hex code after that. Then upload that to the Arduino.

This code is written so that it will stay off until the remote button is pushed. Once on, the arduino will ignore remote button presses, and will wait for a clean shutdown to be performed. On Kodi-based distros this is easily done also by remote. Once a clean shutdown is performed, it cuts power, and then goes back to watching for the remote button press.

Step 5: Final Notes

Now when you first plug everything in, the Pi will power on for a few seconds, then kick off and stay off. Just the nature of the relay while the arduino is booting. After that, it won't happen again. Just use your remote to power it on. When you issue a shutdown from the OS, it will wait until the shutdown is completed, and then cut power to the Pi.

I have Openelec on my Raspberry Pi, and I set it up with a Real Time Clock and a GPIO IR receiver. Everything fit inside the case of a Motorola SB6121 modem, with the HDMI port and power routed to the back side with the USB and ethernet ports. Now it is a completely self contained system that can be entirely controlled with a remote, and doesn't even need internet to keep time.

I know that the first pic looks pretty nasty in there, but in my defense it is a "first time test", and will get redone at a later point.

Be the First to Share


    • Anything Goes Contest 2021

      Anything Goes Contest 2021
    • New Year, New Skill Student Design Challenge

      New Year, New Skill Student Design Challenge
    • Photography Challenge

      Photography Challenge



    Tip 1 year ago

    I put together a more detailed diagram incase it helps others:


    1 year ago

    First off thanks for doing this excellent project, you have saved me £$£ as the remote power modules for Pi are silly expensive!

    Just a quick note, if you are going to be making this for the Pi 4 then I found I needed to make a few tweaks to get it working on my 4GB Pi 4b.
    (This guide worked perfect however for my OG Pi 1)

    First thing is the constant 3.3v signal line seems to have moved from pin 8 (GPIO14) to pin 10 (GPIO15) on my newer Pi 4. So connect Arduino pin A0 to Raspberry Pi 4 pin 10 (GPIO15) instead.

    The final problem was that compared to my older Pi the Pi 4 was a bit slower at generating the 3.3v on the pin 10 (GPIO15) and the relay wasn't staying on long enough to detect it!

    This was easily fixed by editing Pi Power.ino (I used notepad++ but any text editor should work). I just increased the value " long gpiocheckDelay = 2000; " instead I used 9999 so my code looked like " long gpiocheckDelay = 9999; "
    Now when I press the power button the relay stays on long enough for the 3.3v to appear on GPIO15 and the relay stays on.

    Once again thanks for writing this guide, top work fella ;-)


    5 years ago

    i tried adapting the sketch to work in attiny85 but it's giving a lot of errors compiling


    6 years ago on Introduction

    You can also add pins and a jumper to RUN, which also acts as a hard reset, or you can add a jumper to pin5/GPIO03 and pin6/GRND. An ir sensor works connected to pin5, but it's too touchy.. my Logitech mouse would set it off, causing it to turn on by itself.

    If the 5v relay's being fed by the Arduino, can it control a 3.3v signal from the Pi? I'm building a diy Arduino right now, and wasn't sure how I'd actually go about this.. I've never used a relay before, only controlled led drivers with the Arduino using an NFET and transistor.

    Are you sure that the Arduino's digital input pin won't work? If it can read the voltage on an ADC input, it should also work on an "digital input" and the 3.3V is high enough that it should register as a logic one.

    (If you're using an AVR Arduino at 5V, the thresholds for low/high are 2.1V and 2.6V respectively: pp. 610-611 in the Mega328 datasheet.)

    What am I missing? Why won't the same trick work with a digital input?


    Reply 6 years ago on Introduction

    I had originally expected it to work that way, but I spent a few months banging my head against that wall. For whatever reason, at least with the arduino micro, it just saw the Pi's gpio pins as floating, regardless of what state the Pi had them in. Asking around on arduino.cc forums basically led me to the conclusion that I COULD get that to work right, with the inclusion of some extra peices, but this is much simpler and achieves the same end goal.