This tutorial tells you about using Arduino as a web server. So let's get started!
Things you'll need:
->Arduino Board (I recommend Arduino Uno. Any other board compatible with the shield will also work.)
->Ethernet Shield.


(Image Source: https://www.arduino.cc/en/Tutorial/WebServer)
=>Put your ethernet shield over the Arduino Board by lining up the pin names on the shield with those on the Board.
=>Plug your Arduino to your Computer using the USB Cable.
=>Open the Arduino IDE. Click on arduino-00xx -> libraries-> Ethernet -> WebServer example.
=>Upload the WebServer sketch to your Arduino. To open your website, type:
http://192.168.1.177
or
http://192.168.1.177:8080
or
http://192.168.1.177:8081
=>Now, the webpage can only be accessed by a device connected to your router. To solve this, we will use PORT FORWARDING. Now this requires a tutorial of its own, but you can check out portforward.com or your router manufacturer's website. Forward port 80 on your computer, the port that listens to (or expects to receive) from a Web client.
=>To open the website from outside your network, you will need to know your computer's IP Address. To know that, go to www.myipaddress.com. Let us suppose your IP address is 00.00.00.00. To open the website, go to http://00.00.00.00:8080 or http://00.00.00.00:8081.
=>Most probably, your IP address is DYNAMIC, that is, it changes every time your router is switched off and then back on. To solve this issue, you may get a domain name to access your website. http://www.noip.com is a free domain name provider.
Warning:
This example doesn't require an SD card. If an SD card is inserted but not used, it is possbile for the sketch to hang, because pin 4 is used as SS (active low) of the SD and when not used it is configured as INPUT by default. To avoid this, add these lines of code in the setup():
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
Note: The above method just uploads a SINGLE WEBPAGE, that too has limitation on its size. So, in order to host a full-fledged website with a lot of web pages, images, videos etc, you need to plug in an external SD Card in the Ethernet Shield. An SD Card upto 64gb should be enough for your website's needs. :)
Now, you can connect whatever devices you want to your Arduino Board and control them remotely, through internet. You can also check the values of various sensors by reading their input values and updating the web page accordingly. As I say, the possibilities are infinite!!! :)
Best blog...
ReplyDelete