Archive for October 2012

Arduino + Ethernet : Web Server

Sunday, October 14, 2012 · Posted in

How to get the WebServer example to work? This is as simple as it gets.

In my case I am using:
Arduino Uno R3
Ethernet Shield (DFRobot)
Operating System : Windows 7
LAN cable (RJ45) and switch

Setup
1. Attach the Arduino Ethernet Sield to the Arduino Uno
2. Connect and power on the Arduino to the PC with the USB
3. Connect the Ethernet board with an LAN cable (RJ45) to the switch (same switch where your PC is connected to).
4. Sensors are optional.


Code
1. Open the Arduino software (Arduino IDE)
2. Go to File > Examples > Ethernet > WebServer
3. Edit or change the ipaddress. The predefined ip 192,168,1,177
  3.1. To change this. Open your command prompt. (Open Run. Type in cmd. Press OK)
  3.2. In command prompt. Type ipconfig. And press enter.
  3.3. Search for your PC IP address. Since the the shield is using IPv4 format. search for IPv4 Address in the command prompt.
  3.4. Change the IP in the example code with the IP you have found.
Although, the last quartet should be slightly different number between 0-254.
example : If your IP is 10.113.18.207, change it to 10.113.18.220. 220 can be change to any number in the range of 0-254. This slightly different IP is the address of the Ethernet Shield.
4. Compile the sketch, there should be no problem. If you have problem resolve it before moving forward
5. Upload the sketch


Testing
1. Open up your internet browser (example : mozilla, chrome)
2. Type in the IP address of the Ethernet Shield in the URL bar.
3. If the page/server is unavailable. You have to change the IP in your Arduino code. Try a different IP address where only differ in the last part (Step : Code 3.4.). This happen when the IP used is already occupied. Thus you have to keep trying until
4. Repeat step 2 and 3, until you able to connect to the your Arduino Server.

The output of the code, which you can see in your browser will be something like this :
analog input 0 is 543
analog input 1 is 423
analog input 2 is 351
analog input 3 is 318
analog input 4 is 276
analog input 5 is 283


Leave a thank you comment if this helps :)

Powered by Blogger.