Overclock.net banner

1 - 20 of 32 Posts

·
Premium Member
Joined
·
14,339 Posts
Discussion Starter #1
The Problem: my PC doesn't like to sleep (the fans never turn off) and Wake-On-Lan can be really touchy, usually turning on my PC when I didn't ask it to and after only 2-3 minutes of sleep. Also, sometimes I forget to turn on my computer when I am at work or school so I can't access any of my files or services.

The Solution: I'm going to buy a Raspberry Pi. The Pi will host a web server (via wireless) which will have a single web page with a single button to Power On or Off my PC. When I click the button, I will use the GPIO pins on the Raspberry Pi to switch a relay connected to the power pins on my PC. This will all fit nicely inside my PC case.

So, I need to set up a web server on Linux, which I can do. I need to wire up a relay circuit which I can sorta do but my EE roommate can help me with. Then I need to code the web page to actually switch the relay which I have no idea how to do but my roommate says he does.

All in all I'm not sure how I'm going to fit this project into my time but I hope to get it done in the next month or so. Anyone done this sort of thing before?

EDIT: Final update here: http://www.overclock.net/t/1429479/remote-power-switch-for-my-pc-using-a-raspberry-pi/0_50#post_21592386
 

·
Premium Member
Joined
·
14,339 Posts
Discussion Starter #4
Look what showed up today!



Raspberry Pi, USB power brick, Wireless N adapter, and an old 4GB SD card I had lying around.


Installing the OS was extremely easy. Download the image, format the card, copy the files, and let it do its thing.


Setup was a breeze. I had to edit a few lines of text for my wifi settings and one or two clicks to enable SSH. I'm installing the web server components now and then I need to start reading up on coding for the GPIO pins and how to get my webpage to send a command there.
 

·
Premium Member
Joined
·
4,217 Posts
As long as the button on the web page is a giant red one that says "DO NOT PRESS THIS BUTTON", I approve.
thumb.gif
 

·
Premium Member
Joined
·
2,313 Posts
Call me old school. But I am just a fan of the good old power button! One to power it on, the other to power it off.
smile.gif

00-vt.jpg
 

·
Premium Member
Joined
·
7,860 Posts
Cool project!

I've been meaning to play around with a raspberry pi for a while.

Strongly recommend securing that page via htaccess or other means - is there a web based API you're using to interface the site with the hardware?
 

·
Premium Member
Joined
·
14,339 Posts
Discussion Starter #10
Quote:
Originally Posted by _02 View Post

Cool project!

I've been meaning to play around with a raspberry pi for a while.

Strongly recommend securing that page via htaccess or other means - is there a web based API you're using to interface the site with the hardware?
I was thinking about that. I'll do some simple security and might move it to an isolated VLAN so I don't have to worry about and intrusions. The web page will run on a non-standard port which will help.

As for interfacing the site with the hardware, I found that you can run terminal commands via php and so I should be able to run the python API triggers directly. I may wire up the reset button as well and then have the power button ping the PC first so it doesn't switch if the PC is already on, if that makes sense.
 

·
Premium Member
Joined
·
14,339 Posts
Discussion Starter #11
I spent a couple hours tonight learning to code some PHP and how to interface the PHP with the Linux terminal. I also mocked up some shiny buttons for fun. The web page is up and running and looks like this:



It's not pretty (besides my sexy 5 minute buttons) but the data you see at the bottom is all scraped from direct shell commands. Once I script the python for GPIO pins, it will be as simple as running one of the scripts when I press the button.
 

·
Premium Member
Joined
·
7,860 Posts
That's awesome that you get I/O access with the terminal. I'm sure you have or will think of it before implementing, but just in case, PHP provides functions to sanitize arguments for functions like shell_exec.
 

·
Premium Member
Joined
·
14,339 Posts
Discussion Starter #13
Alright, I'm on my way. I purchased an optoisolator for the circuit to switch on the PC. I need this to isolate the Raspberry Pi GPIO pins from the motherboard. Wouldn't want to fry either of those! This way, I can send a signal from a single GPIO pin and it will open the circuit and turn on the PC (or Reset it, if it is the second circuit). Those pins are controlled by simple python commands so it shouldn't be a big deal coding them. I'm guessing I have about an hour's worth of actual work to get this working. Then I'll waste countless hours making the website pretty, etc.
tongue.gif
 

·
Registered
Joined
·
1,313 Posts
Very nice idea. I have a Pi in my Amazon cart (its been there for a month) and maybe I should finally order it and start a project of my own. Either way, this is getting bookmarked under "Pi projects"...so dont be surprised if I copy your idea!

And I am with XiCynx, RE: one power button. So I think I would do this on my back-up box, get it working, and then use the Pi for something else.

BTW, how were you setting up the Pi as a server? I have seen it mentioned countless times but I know nothing about that process. I was hoping someone, somewhere, had a two step tutorial for idiots like me.
 

·
Premium Member
Joined
·
14,339 Posts
Discussion Starter #16
Quote:
Originally Posted by DMatthewStewart View Post

Very nice idea. I have a Pi in my Amazon cart (its been there for a month) and maybe I should finally order it and start a project of my own. Either way, this is getting bookmarked under "Pi projects"...so dont be surprised if I copy your idea!

And I am with XiCynx, RE: one power button. So I think I would do this on my back-up box, get it working, and then use the Pi for something else.

BTW, how were you setting up the Pi as a server? I have seen it mentioned countless times but I know nothing about that process. I was hoping someone, somewhere, had a two step tutorial for idiots like me.
I'm pretty sure I just googled "host web page from raspberry pi". If I recall correctly, I just had to install Apache and maybe some PHP components. It was only a few commands.
 

·
Premium Member
Joined
·
4,564 Posts
I have wanted something like this for agesssss.

You could probably sell these if they work well.

Are you making it so the PC's switch can be connected tot he power board and used normally?
 
1 - 20 of 32 Posts
Top