0

I bought a ethernet shield for my Arduino Uno. I plug it my Arduino and PC with ethernet cable. There is all led is working on ethernet shield. But when i try to examples about ethernet which is in Arduino IDE as "DHCPChatServer" example.

I hope to see; "Trying to get an IP address using DHCP" "My IP address: 192.168.1.177"

But I just see "Trying to get an IP address using DHCP"

Any problem with my ethernet shield?

4
  • 1
    Are you running a DHCP server on the PC you connect the Arduino to? If not, it cannot obtain an IP. You may want to use a static IP instead. Commented May 12, 2015 at 19:24
  • I tried static IP but it didn't work. Commented May 12, 2015 at 21:06
  • @user3748265 What static IP address did you try? Only certain ranges are valid for local networks. Commented May 12, 2015 at 23:30
  • I check out ip address with ipconfig and i set up my ethernet with this ip address. IP address is 192.168.2.101 subnet mask:255.255.255.0 gateway:192.168.2.1 Commented May 13, 2015 at 8:24

2 Answers 2

1

When you connect your arduino directly to the PC using the ethernet cable, neither of them have any information about the network.

Most ethernet devices attach to switches, routers, and gateways, and one or more of these devices host network services such as DHCP, DNS, or provide a way to obtain those services.

Without DHCP, for instance, neither your PC nor the Arduino know what IP adress to use, what their netmask is, and whether there's a gateway to other IP addresses.

You have a few options:

  • Follow the Automatic Private IP Addressing specification, which windows computers default to when no DHCP server is present or available. Set the IP address of the Arduino to 169.254.x.y where x and y are randomly chosen numbers between 0 and 255, and set th netmask to 255.255.0.0. The windows computer should have done the same if no static IP address was set - use ipconfig on the windows command prompt to find its IP address. Your computer and arduino should be able to talk to each other.
  • Set up a router. It doesn't need to connect to the internet, it just needs to connect to both the PC and the Arduino. It'll implement a DHCP server and make sure, at minimum, that the two devices can talk to each other and the router.
  • Set static IP addresses on both devices. Set up the PC with something like 192.168.42.1 with a netmask of 255.255.0.0 and the Arduino with 192.168.42.2 and the same netmask. Now they should be able to talk to each other.
  • Connect both to an existing network. The network should already have a router with DHCP on it, so it'll take care of everything, and as a bonus you may be able to get internet access as well, which could help with testing since you can use the ethernet shield to communicate with google and other known working services, rather than trying to set up a server on the PC.
-1

I changed my Arduino Uno with Arduino Mega and problem is solved.Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.