Intro: NAS Over Ethernet ON Switch / WOL / Remote on for NAS ENC28J60
Ok, First Instructable. Here we Go!
This project is designed for those that want to remotely turn on their NAS/Computer via ethernet (ENC28J60), but their motherboard does not support WOL (Wake On Lan). This simple project takes an inexpensive ENC28J60 Ethernet shield, an Arduino, and a relay and makes it possible to turn on your NAS over ethernet.
--Relay Or Transistor (Your choice. I recommend the relay as you don't have to worry about the grounds being tied together.).
--4 pin Molex connector(cut off old power supply, or computer recycling shop).
--3.3 volt Regulator (like a LM 1117, or LM 317). Optional. You can just use the 3.3v line from Arduino.
UIPEthernet for Arduino. This library is very similar to the Ethernet library already used in Arduino IDE.
Microsoft Visual Studios Express. You can download this, and copy my code into a Consule Application, or just use my exe file. Not sure if I will be able to upload an exe though...
Thanks to Hansc44 for his tutorial :https://www.instructables.com/id/Add-Ethernet-to-an...
This is a good tutorial as well: http://www.tweaking4all.com/hardware/arduino/ardui...
Step 1: 3.3V Power
Lets get our power down to 3.3v.
The LM1117 has 3 pins: Ground, Output, input. I regulated this with 2 10uf capacitors (as seen in the images).
You can just use the Arduino 3.3v line if you like.
HERE IS THE FRITZING I know it may not be all hooked up perfect, but the basic hookup idea is there.
Please post comments if something is not right, and how to fix it. It's my first time with Fritzing.
NOTE: Not all ENC28J60's pinouts are the same. Look at your module before hooking up.
Step 2: Connect the ENC28J60
Step 3: Arduino Code
Here is the code that I use. NOTE: I am a noob, so .... If you have a better way - post it, and I will update my code. Thanks.
I attached the files (As ino, and txt). I could not seem to get the code to look correct here without a lot of extra work.
Step 4: Check the Voltage
Before turning on the NAS/Computer you want to make sure it's not already on. I check the 5v line from the computer MOLEX 4pin connector (red line) always verify with volt meter.
I removed a molex plug from an old power supply, added a voltage divider (2 1k resistors) to bring the voltage down to 2.35 volts (or so...).
Its hard to tell in my picture, but I have a 1k resistor from the 5v molex line to the A1 arduino line (sensing point [Vout]). From that junction(sensing point [Vout]), a 1k resistor to ground. The led anode is from the sensing (Vout) point to molex ground. I know this is not very clear - so sorry...
In the Arduino Code you will see that I check for voltage (voltage < 1)....
Step 5: Send the Packets...
Now we need to send a packet to the ethernet shield to turn on the NAS.
I tried Chrome and Firefox, but a browser tends to want to send multiple packets (this is a pain).
So I wrote a small VB program in Visual Studios to send a simple packet with a variable to the arduino:
"192.168.1.177/1" - Turn on the NAS
"192.168.1.177/2" - Turn off the NAS
"192.168.1.177/3" - Is the NAS on (Check, return Voltage)
I tried to attach the files, or the exe, but was unable to do so. If someone knows a way that I can attach an exe, please let me know. I will continue to look for an option.
Here is the Microsoft Visual Studios VB Consule Application Code:
Sub Main() Dim connectString As String = "" Console.WriteLine("Enter variable 1/2 and press enter.") Dim v As Integer = Integer.Parse(Console.ReadLine) If v = 1 Or v = 2 Or v = 3 Then connectString = ("192.168.1.177/" & v) Console.WriteLine("Connecting... " & connectString) Dim URL As String = ("http://" & connectString) Dim uri As New Uri(URL) If (uri.Scheme = uri.UriSchemeHttp) Then Dim request As HttpWebRequest = HttpWebRequest.Create(uri) 'request.Timeout = (10000) request.KeepAlive = False
request.Method = WebRequestMethods.Http.Get
Console.WriteLine("Request Sent.") Console.WriteLine("Waiting for response.") Try If v > 0 Then Dim webClient As New System.Net.WebClient Dim result As String = webClient.DownloadString(URL) Console.WriteLine(result) Else Using response As HttpWebResponse = request.GetResponse() Console.WriteLine(response.StatusCode & ", " & response.StatusDescription & ", " & response.ResponseUri.AbsoluteUri)
End Using End If
Catch ex As Exception Console.WriteLine("Request Failed! Error!") Console.WriteLine(ex.Message) End Try
Console.WriteLine("Response received!") Console.WriteLine("Closing.")
End If End If
Step 6: Just a Video
Here is a video of the first rendition of the prototype