• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoNAS Over Ethernet ON Switch / WOL / Remote On For ...
Previous Next

NAS Over Ethernet ON Switch / WOL / Remote On For NAS ENC28J60

Posted by: Olva , October 19, 2016
Picture of NAS Over Ethernet ON Switch / WOL / Remote On For NAS ENC28J60
IMG_1678.JPG
IMG_1688.JPG
NAS Ethernet Switch_2.jpg
LM1117.png

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.

Parts:

–ENC28J60

–Arduino

–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.

Downloads:

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…

From Here click on “Express For Desktop” Or get the 2013 version from here

Thanks to Hansc44 for his tutorial :http://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

Picture of 3.3V power
3.3V.png

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

Here is a great tutorial on hooking this up (NOTE: I use Pin 10 for CS).

The ethernet shield (ENC28J60) uses SPI to talk to the Arduino. SPI on the Arduino UNO (Pro Mini) is typically:

(SI) MOSI –> 11

(SO) MISO –> 12

(SCK) SCK –> 13

(CS) SS –> 10

VCC –> 3.3v

GND –> Ground

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.

  • WebServer_5_ProMini_Working_v3_WanRead_4.ino WebServer_5_ProMini_Working_v3_WanRead_4.ino
  • WebServer_5_ProMini_Working_v3_WanRead_4.txt WebServer_5_ProMini_Working_v3_WanRead_4.txt

Step 4: Check the voltage

Picture of Check the voltage
voltage_divider2.png

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)….

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:

Imports System.Net
Module Module1

    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)

                            response.Close()

                        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

        System.Threading.Thread.Sleep(3000)

    End Sub

End Module


http://www.instructables.com/id/NAS-Over-Ethernet-ON-Switch-WOL-Remote-on-for-NAS-/

Share!
Tweet

Olva

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors