Arduino And IR Remote Turn Off Raspberry Pi

With all of the cool features on the Raspberry Pi, it is somewhat notable that it lacks a power button. In a simple setup, the only way to cut power to the tiny computer is to physically remove the power cord. [Dalton63841] found that this was below his wife’s tolerance level for electronics, and built a simple remote control for his Raspberry Pi.

[Dalton63841] started this project by trying to use the UART TX pin, but this turned out to be a dead-end. He decided instead to use an Arduino to monitor the 3.3V power rail on the Pi. When the Pi is shut down in software, the Arduino can sense that the Pi isn’t on any more and disconnect the power. The remote control is used to turn the Pi on. The Arduino reads the IR code from a remote and simply powers up the Pi. This is a very simple and elegant solution that requires absolutely no software to be installed on the Raspberry Pi.

We know that this isn’t the most technically complex project we’ve ever featured, but it is a good beginner project for anyone just getting started with a Pi, Arduino, or using IR. Plus, this could be the perfect thing to pair up with a battery-backup Raspberry Pi shutdown device that allows it to power itself down in a controlled way when a power outage is sensed.

18 thoughts on “Arduino And IR Remote Turn Off Raspberry Pi

  1. I used a pic micro and the video out pin as the indicator for whether the pi was shut down or not, it was the only thing I could find that was 100% correct. Initiating a shut down is not hard but knowing when it was completed was the difficult bit as I had a lot of databases to save before powering off, the shut down time was not something I could use, it varied too much.

  2. Erhm. From reading the instructable I get the impression that he *is* monitoring the UART TX line and not the power rail. Specifically, in the list of connections there’s an “Arduino pin A0 to Raspberry Pi pin 8(UART TX) “. I think the dead end referred to not being able (for some reason) to drive the 5V Arduino digital input pins from the 3.3V Pi output pin.

    Apparently he’s now monitoring the 3.3v from the UART TX with an analog input pin and switching a 5V relay (directly from the output pin and without flyback diode).

    1. Yes that is correct. Question though… I need to add a flyback diode in this scenario? I know I would need one with a bare relay, but it’s my understanding that the arduino relay boards come in an onboard flyback.

      1. Ah. I wasn’t aware that you were using a relay board. Makes sense. The flyback would likely be included on the board then, probably along with a driver transistor.

    1. LOL! This whole thing was a learning process for me.(Literal first timer here) The arduino will be getting replaced with something more discreet, but I already had the arduino micro, so I used that to kind of test things out.

  3. FTA: “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.”

    What it sounds like is that he wasn’t connecting the ground together when he was trying to sense the Pi TX pin. Then when he tried to go analog, he figured out that connecting the grounds together helped.

    If he had simply connected the grounds together to begin with, the digital IO would have worked fine. 3.3V to 5V works fine. It was designed to be compatible that way. What is a problem (and really only under certain circumstances) is that 3.3V lines are not always 5V tolerant. Though even then, a simple resistor between the two is all that is needed.

    The highs and lows of 3.3V and 5V logic are compatible. But yeah, you need to connect the grounds together. I see this mistake very often with people toying with an Arduino.

    1. I would comment than Arduino is overkill because it is more than likely drawing more current while running than a shutdown Pi, but since he wanted IR control, it is probably the simplest way to accomplish it unless he found a matching IR decoder for his remote.

      1. Since an arduino is nothing more than a Atmel µC with some bird food around it you can of course put this one into deep sleep and wake it up by an external event like a IR receiver ringing on a pin.

    2. All that information led to much head banging for me! I knew that much going in, and I did tie their grounds together, but it still just would not work. It is entirely possible that there is just something wrong with my arduino, but with the way I wired it up now, it works perfectly and consistently, so I’m happy with it.

      I will be replacing it soon with an actual microcontroller. When I do I may backtrack and try using the digital pin again.

      1. Well, that certainly is odd. I respect that you witnessed what you say you did. A tip for next time would be to use a pullup resistor to 3.3V on the Pi side. Oh, and don’t enable the pullup on the arduino when setting up the pin as input unless you place a resistor in series. If you had enabled the pullup, the Pi was probably not able to pull the pin down because it couldn’t source any current. If the Pi is off, there would be no connection to ground and the digital I/O would read high.

        There should not have been any reason it didn’t work.

  4. Good LORD. I cannot believe this hot mess is on hackaday. I’m still in the process of cleaning this project up a lot.

    To answer questions…
    1. Yes, I realize the power requirements between an arduino and a Pi aren’t THAT different and that makes it seem kind of pointless. The reality is this is my first time tinkering with a microcontroller of any kind, and this is basically a proof of concept before I try using an ATTiny or perhaps just a 328P. I’m still learning all that.

    2. I tried about 2 dozen times using an arduino digital pin to monitor the Pi UART TX pin(I knew that pin was key given its behavior). I understood that the 3.3v on that pin should have provided a logic high, but it just didn’t. The arduino just always saw a floating pin, whether I grounded separately, together, or both to chassis. This might be something wrong with my arduino, but it would be odd considering that it works otherwise fine.

    3. As stated, this is basically a way, combined with openelec and a GPIO IR receiver of its own on the Pi, to control power ON and OFF with the remote. I know that turning the Pi off is basically unnecessary, but the less computer literate around me are just completely against leaving something on 24/7.

Leave a Reply to Dalton63841Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.