Go Down

Topic: [SOLVED] Arduino Uno + WAMP + Ethernet, what are the IPs i need? (Read 2414 times) previous topic - next topic

ODRedHavoc

May 15, 2013, 08:10 pm Last Edit: May 16, 2013, 07:26 pm by ODRedHavoc Reason: 1
As the title has stated, i got a WAMP Server etc on Windows 7, and i need my Arduino Uno to connedt through ethernet with my ethernet shield and it needs a couple of IPs.

I got the Arduino straight connected on the Ethernet of my laptop (laptop with wireless connection to the inernet)
and all i need are some clear instuctions on how to find the suitable IPs needed in the beginning of the Arduino code like
Code: [Select]
byte ip[] = { 192,168,1,3 };
byte serverName[] = { 192,168,2,1 };


The local ethernet connection between laptop and arduino is set at Properties->IPv4Properties-> specific IP (192,168,2,1 ) the one used for serverName and the proper Mask.
Also the ip[] i 've used is the one i have found at cmd->ipconfig->IPv4 from wireless LAN

I would greatly accept any explanation of the way it is properly done, how to find and set those IPs with WAMP,
and what i am doing wrong and it doesn't connect at my server (in order to put a value from analog input to a database..)
Code: [Select]
client.connect(serverName, 80);

SurferTim

Keep them in the same subnet. I changed the w5100 ip below.
Code: [Select]
byte ip[] = { 192,168,2,3 };
byte serverName[] = { 192,168,2,1 };


ODRedHavoc

I was expecting it to fail, and it did.
I tried as changed above with "2"s, and i also tried by changing the set ethernet IP to 192.168.1.1 so i got  serverName[] = { 192,168,1,1 };
Thank you for the reply tho!
Is there some general reason to keep the same subnet?

SurferTim

Quote
I tried as changed above with "2"s, and i also tried by changing the set ethernet IP to 192.168.1.1 so i got  serverName[] = { 192,168,1,1 };

You can't just make up some of this. The WAMP server ip is static, isn't it? What is the network settings on your WAMP ethernet port that is connected to the ethernet shield?
Quote
Is there some general reason to keep the same subnet?

Yes. If you want to connect to anything else, it must be in the same subnet. If you assign 192.168.1.2 to your Arduino and do not specify a netmask, it presumes the localnet is all 192.168.1.x devices. It also expects the gateway to other non-localnet ip addresses is 192.168.1.1.

If your server is 192.168.2.1, then the Arduino presumes that is not on the localnet, and tries to send the request to 192.168.1.1 (gateway), but there isn't a gateway at 192.168.1.1. Or is there?

ODRedHavoc

Well i ll try to shed some light as i got little experience with these and maybe i don't understand well even my questions:

1) running ipconfig i got these:
-For the LAN-wireless: IPv4: 192.168.1.3, subnet mask: 255.255.255.0, default gateway 192.168.1.1, DHCP: 192.168.1.1
[now that i saw this, i changed the IPv4 of the ethernet connection to 192.168.1.8 from .1, as i thought that was the reason why when i connect my arduino to this IP it blocks my internet and pages don't load]

-With my arduino connected to the ethernet ipconfig shows what i ve "planted" anew: IPv4:192.168.1.8 and Mask: 255.255.255.0

2) When i try with those parameters, if i got my WAMP closed, it "connects", otherwise, it does not once more.

3) I installed my WAMP, if that's the correct way of saying so, to localhost, aka 127.0.0.1 . When i enter on my browser either of these OR 192.168.1.3 OR 192.168.1.8  they ALL get me to the first page of my wamp apache server.

I think i am doing something wrong.. Thank you again for the reply!

SurferTim

You need to change the localnet on your ethernet port. It is the same subnet as your wireless interface. That causes a routing problem.

If the ip of your wireless interface is 192.168.1.3, then change the ip on your ethernet port to 192.168.2.1, and use 192.168.2.2 on the Arduino. Then use 192.168.2.1 for your server ip in the Arduino. That will eliminate the routing problem.

ODRedHavoc

I set in the Ethernet options IPv4 192.168.2.1 , and if i got it well, you told me to also change parameters like this:
Code: [Select]
byte ip[] = { 192,168,2,2 };    // The arduino IP
byte serverName[] = { 192,168,2,1 };

Still doesn't work.. Won't connect

ps. maybe you mean something else by "use 192.168.2.2 on the Arduino"?

SurferTim

Have you tried a computer connected the same way to the WAMP server? You may have a firewall problem. Do you have the firewall set to allow access to port 80? Checking with a web browser on the server is not a valid check. It does not test the firewall.

ODRedHavoc

Well, mr SurferTim, it seems we have solved the issue here and i thank you very much! It seems to connect, tho it doesn't do the next stuff, but that's another matter i hope :)
I HAVE ONE LAST QUESTION:
Can you please explain to me how you selected the Arduino IP? I mean, what is the thought behind it?

The solution is in few words, was to change the correct IPs, and then [google search, immediate walkthroughs] add an inbound rule at the Windows Firewall for port 80 both TCP and UDP in different inbound rules. I don't know if that's cool, but i just made both.

Thank you again SurferTim and all those who even thought for a potential solution.

SurferTim

You don't need udp port 80, but it won't hurt if it is a localnet server.

The ip choice is fairly logical. Don't use one that is already in use. I avoid ip addresses that may be issued by a dhcp server. The ips must be in the same subnet. That will depend on the netmask.

Don't feel intimidated. It took me 20 years to learn all this.

ODRedHavoc

Thanks again SurferTim! All was clear and good.
This thread is considered closed :)

Go Up