Go Down

Topic: Get Arduino data from external web site [SOLVED] (Read 7574 times) previous topic - next topic


Did you see my "Add:" above? Set up the Arduino, then power cycle your router, waiting a few seconds with it off. Try again.


Thanks ! Effectively I didn't see your add. The problem you had seems to be mine !
It's a very good idea ! I will try this when I'm at home ...
I'll keep you informed tonight or tomorrow...


Let me know how it goes.

BTW, I made that troubleshooting seem like I figured it out immediately. That was NOT THE CASE! That fix involved many dozen tries and a lot of cursing!  :)


I will do this, but I wonder ...
If I change the MAC@ and the IP of the Arduino, that should be the same than switch Off and On the box, no ?


Mar 06, 2012, 03:47 pm Last Edit: Mar 06, 2012, 04:01 pm by SurferTim Reason: 1
You can lie to the router by using the same mac address on both devices, but this comes at a cost. You can no longer use both devices connected to that router. One will fail.

edit: If you use a different mac and a different ip, there should be no problem. Just route to the new ip. The problem arises when you use the same ip with a different mac address.


Well... here is the result of my tests : it's better but not perfect.
After switching my box OFF and ON to force the cleaning of the router ARP table, I turned ON my Arduino and I was surprised : The gateway given by the card was not the good one. Very strange : in my sketch I didn't use the DHCP connection but I forced all the parameters !!! I reset the Arduino : same bad value for the Gateway ! (I didn't wrote the address, but it was something like in place of
I switched OFF and ON my Arduino again : all the parametters was good...

A new test to connect on the local network to the local @ and external @ : it's OK
Test from remote connection (from my mobile phone) : it's OK !!!!!  :)
New test from my PC through a VPN : no response. =(
Test with the php "file(url)" from an external web site : no response. =( (Of course I've already tested this file(url) on another url (www.google.com) and that works well with this url).

Conclusion : it's better because I perform to connect from my mobile phone, but it's not perfect. The goal is to perform to use the file() php feature from a remote web site.

But maybe the file(url) request use a specific protocol ? Maybe the Arduino answer must be different ? I don't know.


I haven't used the php file() routine yet, but it looks pretty easy. The protocol is determined by the URL parameter. FTP and HTTP are supported. See the caveat about the fopen wrappers on the php.net link below.

Code: [Select]
$lines = file("");



Yesterday night, I installed a sniffer on my PC to see the dialogue between my Arduino and the box (router).
At  a moment, after trying to connect from a remote browser (outside from my local network) I saw a request from the box (gateway @) : who is ?   And there was no answer !

I've rebooted the Arduino and checked carefully what parameters (IP, Gateway, Subnet and DNS) there was in the Arduino and I saw the Gateway was not the good one : in place of !!! What is the cause ?

So I have to improve my sketch in the setup() to check whether the inside parameters are identical to the parameters I gave in the Ethernet.begin(mac, ip, gateway, dns, subnet) request. I know how to do it for the ip, gateway, dns and subnet address, but I don't know how to do it for the mac@. I will search for this, but if someone has already done it thanks to help me  ;)


Are you using dhcp when this happens? Or are you setting the ip manually (static)?

So I have to improve my sketch in the setup() to check whether the inside parameters are identical to the parameters I gave in the Ethernet.begin(mac, ip, gateway, dns, subnet) request.

I hope that is a typo. Your dns and gateway ips are reversed. It should be:


Yes it was a typo ... sorry  :~

Now I've done good progress !  :)
Concerning the bad parameters used by the Arduino I've no idea. But now that works at the first shot. I control all parameters (including mac@  ;) to be sure.
I've a permanent dhcp @ in my box according to the mac@  so I can use Ethernet.begin(mac) or Ethernet.begin( --- all parameters---) : I get the same result.  :smiley-sweat:

After  a lot of tests, box configuration update, box reboot, and using a sniffer, I can say now :
- All works well with the port 80. So when I route my public IP:80 to the local IP:80 I can access the Arduino from everywhere, my work VPN included. Additionally the "file(URL)" works well on this address.
- With port 818x => OK from local test (inside my local network) but not from my work VPN (port probably blocked). File(url) is not working.
- With port 8080 => OK from local network and remote, work VPN included. file(url) is not working.

So I will stop my tests now. I've learn a lot !  :)
file(url) is not working when using a port number. It's strange. Maybe I'll investigate this point later. If yes I'll post a new thread... (for info, I tested it from a web site hosted at site40.net).

Thank you very much to all !

Go Up