loading

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.

<p>i tried adapting the sketch to work in attiny85 but it's giving a lot of errors compiling</p>
<p>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.</p><p>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.</p>
<p>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 &quot;digital input&quot; and the 3.3V is high enough that it should register as a logic one. </p><p>(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.)</p><p>What am I missing? Why won't the same trick work with a digital input?</p>
<p>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.</p>
<p>Nice pi project.</p>

About This Instructable

10,749views

43favorites

License:

More by Dalton63841:Turn Raspberry Pi ON w/ Remote Control 
Add instructable to: