In the last post on Arduino, I briefly wrote about my experiments with setting up a wireless communication between a host computer and an Arduino board using XBee. Here, we explore talking to the world of the Internet(s!) using Arduino. Time for giving your Arduino an IP address! Instead of using an Ethernet shield on an Arduino UNO, I thought the EtherTen might be a better idea to try, since it has onboard Ethernet. I am glad, I chose Etherten for various reasons!
Arduino Webserver
Hook up your Arduino to your computer and plug in the Ethernet cable into the board, with the other end connected to a router. If you see the Webserver example (under File -> Examples -> Ethernet) shipped with the Arduino IDE, you will see that it uses the Arduino Ethernet library.
It however requires you to set up a static IP address for your Arduino. However, in a multi-user home/university network, there is a fair chance that the IP addresses are allocated dynamically, hence I would like to use DHCP in my Webserver sketch. Now, that said: using dynamic IP address for a web server isn’t the greatest of ideas technically. But, we shall not go there in this exercise.
I used Georg Kaindl’s Arduino DHCP library to obtain the IP address dynamically and integrated with the Web server example. Here is the complete sketch. Once, you compile and load the sketch to your board, and open the Serial Monitor, you should see something like this:
Attempting to obtain a DHCP lease...
A DHCP lease has been obtained.
My IP address is 10.0.0.97
Gateway IP address is 10.0.0.138
DNS IP address is 10.0.0.138
Now, go to your web browser, and type in: 10.0.0.97:8080 and you should see:

Arduino sends the sensor readings from the Analog pins 0-5 (I don't have any sensor connected to this pins, so they are just random readings)
Now, let us use the telnet program to send a request to our Arduino:
Resources and misc.
- Webserver DHCP sketch
- Tweet from your Arduino board: This sketch builds upon the example here by obtaining the IP address using DHCP
- Arduino Ethernet
- DHCP with Arduino
- Moving forward with Arduino: Ethernet
- O’Reilly’s Arduino Cookbook has some Ethernet + Networking recipes in Chapter 15.
That’s it for this time. (My previous posts on Arduino.)


Arduino and the Internet? Easy. « freetronicsblog
Hello Amit, I am currently working on a project for my university, and I need to be able to connect on the schools network with an arduino through wireless. So i need DHCP support, do you have any recommendations ?
thank you
Hi Fenx, do you mean to say you want to use the Arduino to connect the school network via a wireless connection? What do you mean by connect: what do you want to do?
Hello Amit,
I will have an aruidno + gps + wifi module to be able to track the school golf carts. The gps will send the coordinates through the wifi and to a server in the school. But i need a wifi shield that can connect via DHCP.
help??
Are you the poster here: http://www.reddit.com/r/arduino/comments/110drk/wifi_shield_with_dhcp_support/ ? If not, then certainly he/she has the same problem as you. I am not sure what shield you have, but a bit of Googling led me to this one: https://github.com/watterott/RedFly-Shield. It seems to have DHCP support.. Hope that helps you.
Also, have you considered other methods of wireless communication? For example, XBee? Isn’t that suitable for you?
Hi, thanks for this post. I am now able to read the digital signals in my browser when the pc is connected to the same net, i.e. arduino ethernet connected to the router and pc connected wirelessly to the same router. What’s the next step to access these readings from outside this local net? If I try to connect to IP:8080 from my mobile phone over 3G I get an error message (“this webpage is not available” in chrome).
Thanks for your help
Mauri
PowerGen Power-U Dual Port USB Car Charger charges your iPad, iPhone, iPod, HTC, Blackberry, MP3 Players, Digital Cameras, PDAs, Mobile Phones.