Pages: 1 [2]   Go Down
Author Topic: Get Arduino data from external web site [SOLVED]  (Read 2765 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5851
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5851
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!  smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5851
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 06, 2012, 10:01:50 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 192.160.1.254 in place of 192.168.1.254).
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 !!!!!  smiley
BUT :
New test from my PC through a VPN : no response. smiley-cry
Test with the php "file(url)" from an external web site : no response. smiley-cry (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.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5851
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
$lines = file("http://1.2.3.4:8888");

http://php.net/manual/en/function.file.php
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 192.168.1.140 ?   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 : 192.160.1.224 in place of 192.168.1.154 !!! 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  smiley-wink
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5851
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
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:
Ethernet.begin(mac,ip,dns,gateway,subnet);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes it was a typo ... sorry  smiley-confuse

Now I've done good progress !  smiley
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@  smiley-wink 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 !  smiley
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 !
Logged

Pages: 1 [2]   Go Up
Jump to: