Go Down

Topic: plss help about ethernet shield (Read 1 time) previous topic - next topic

what i did is i connect the ethernet to a router.. i was able to make a simple browser to turn on and off a led, now my problem is i could only control it using pcs connected to the same network(internet router).. what i want is to control it anywhere around the world.. can i ask if there are any network settings or anything i needed to do to be able to control it anywhere as long as you are connected to internet? what i only specify is mac,lan ip, port(80 for default not sure if its the right port but its working). will i include gateway or subnet? thank you for a reply

PaulS

Quote
my problem is i could only control it using pcs connected to the same network(internet router).

How is that router configured? Does it do port-forwarding? Which ports? To where?

You'd need to use the router's public IP address (assigned by the ISP) and the port that gets forwarded to the Arduino to access the Arduino from outside the local network that the router creates.

zoomkat

For outside access a dynamic IP address service like www.no-ip.com or www.dyndns.com  is used for the wan IP address tracking, along with port fowarding on the lan router. Below is a link to get your current wan IP address.

http://checkip.dyndns.com/
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.


For outside access a dynamic IP address service like www.no-ip.com or www.dyndns.com  is used for the wan IP address tracking, along with port fowarding on the lan router. Below is a link to get your current wan IP address.

http://checkip.dyndns.com/



thank you for the reply sir... can you not like just enter the gateway of you ISP in your code for the shield to be able to connect to it?.. and another question sir. i am now using the ENC28J60 ethernet, i guess there is no wiznet chip with this can i still use it to control via internet ryt?..


Quote
my problem is i could only control it using pcs connected to the same network(internet router).

How is that router configured? Does it do port-forwarding? Which ports? To where?

You'd need to use the router's public IP address (assigned by the ISP) and the port that gets forwarded to the Arduino to access the Arduino from outside the local network that the router creates.


thank you for your reply sir.. uhmm i am still noob with router configuration.. how will i know if its port forwarding and which ports?.. can i get my router's public ip address with cmd prompt right?? thank you for a soon reply..

PeterH


thank you for your reply sir.. uhmm i am still noob with router configuration.. how will i know if its port forwarding and which ports?.. can i get my router's public ip address with cmd prompt right?? thank you for a soon reply..


Google 'router port forwarding' to find what port forwarding is. Look for instructions to configure it for your router type.

Google 'what is my IP' to find what the publicly-facing IP address of your router is.
I only provide help via the forum - please do not contact me for private consultancy.



thank you for your reply sir.. uhmm i am still noob with router configuration.. how will i know if its port forwarding and which ports?.. can i get my router's public ip address with cmd prompt right?? thank you for a soon reply..


Google 'router port forwarding' to find what port forwarding is. Look for instructions to configure it for your router type.

Google 'what is my IP' to find what the publicly-facing IP address of your router is.


thank you for the reply sir.. sir last question. does this method only apply to W5100 based ethernet shields? cause actually i am usning the old ENC28J60 shield.. thank you

zoomkat

Quote
thank you for the reply sir.. sir last question. does this method only apply to W5100 based ethernet shields? cause actually i am usning the old ENC28J60 shield.. thank you


The W5100 based ethernet shields are available on ebay now for $10 shipped, so i'd suggest getting one of those.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Arrch


thank you for the reply sir.. sir last question. does this method only apply to W5100 based ethernet shields? cause actually i am usning the old ENC28J60 shield.. thank you


This would apply to a Potato if you could manage to get the TCP/IP stack on it. The device that is connected to the network is irrelevant in this situation; It is also about your router.

#9
Jan 15, 2013, 08:44 am Last Edit: Jan 15, 2013, 08:53 am by Coding Badly Reason: 1



This would apply to a Potato if you could manage to get the TCP/IP stack on it. The device that is connected to the network is irrelevant in this situation; It is also about your router.


sir what do you mean with Potato?.. and which device did you mean that is irrelevant??....
below is the code i have tried for my old version of the shield. is there anyway i could make this to be controlled outside my network?

Code: [Select]

// A simple web server that turn an LED on or off"

#include "etherShield.h"
#include "ETHER_28J60.h"

int outputPin = 6;

static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24};   // this just needs to be unique for your network,
                                                         
static uint8_t ip[4] = {192, 168, 1, 15}; // IP address for the webserver

static uint16_t port = 80; // Use port 80 - the standard for HTTP

ETHER_28J60 e;

void setup()
{
 e.setup(mac, ip, port);
 pinMode(outputPin, OUTPUT);
}

void loop()
{
 char* params;
 if (params = e.serviceRequest())
 {
   e.print("<h1><a href='/?led=off'>Arduino Web Remote</a></h1>");
   if (strcmp(params, "?led=on") == 0)
   {
     digitalWrite(outputPin, HIGH);
     e.print("<a href='?led=off'><button style='border: 1px solid #ff0000; border-left: 10px solid #ff0000' type='button'>LED IS ON</button></a>");
   }
   else if (strcmp(params, "?led=off") == 0)
   {
     digitalWrite(outputPin, LOW);
     e.print("<a href='?led=on'><button style='border: 1px solid #000; border-left: 10px solid #000' type='button'>LED IS OFF</button></a>");
   }
   e.respond();
 }
}



Moderator edit: [code] [/code] tags added.

PaulS

The type of ethernet shield you are using to connect to your router is irrelevant when it comes to understanding how your router is connected to the internet. You could be using a potato (well, probably not really) as a shield, and the stuff you need to do to enable external (internet) access to the Arduino with (potato) shield would be exactly the same.


The type of ethernet shield you are using to connect to your router is irrelevant when it comes to understanding how your router is connected to the internet. You could be using a potato (well, probably not really) as a shield, and the stuff you need to do to enable external (internet) access to the Arduino with (potato) shield would be exactly the same.


thank you for the reply sir.. so do you mean its ok i use this type of ethernet shield(EJ2680) as long as i am correct with my router settings to have external access on my arduino?(through internet)

Arrch

#12
Jan 15, 2013, 05:20 pm Last Edit: Jan 15, 2013, 06:01 pm by Arrch Reason: 1

sir what do you mean with Potato?

Cut the "sir" crap.

This is what I mean by a potato:




Quote
and which device did you mean that is irrelevant??....


What ever is acting as a server, like a computer, Arduino Ethernet or the aforementioned potato.

Quote

thank you for the reply sir.. so do you mean its ok i use this type of ethernet shield(EJ2680) as long as i am correct with my router settings to have external access on my arduino?(through internet)


Yes.

another question... if i control the arduino with a web browser, could it also receive data from the arduino to update it? like for example i turned on a led using the webrowser, thus it display ledon.. now i turned it off using a pushbutton manually, is there a way the browser will automatically say ledoff?

PaulS

Quote
if i control the arduino with a web browser, could it also receive data from the arduino to update it?

That sentence really needs a bunch of nouns, rather than all those pronouns. I have no idea what each of those its refers to.

Quote
like for example i turned on a led using the webrowser, thus it display ledon.. now i turned it off using a pushbutton manually, is there a way the browser will automatically say ledoff?

Yes, and no. There is NO way for a server to push information to a client. The client/server relationship is stateless. Once the server sends data to the client, it forgets that the client ever existed.

The server can embed meta tags in the page that it serves that tell the client that it needs to refetch the page every n seconds. It is up to the client software to see those tags, and to act on them.

The server, though, has no idea that a client request is a result of the user loading the page initially or the client refreshing the page.

Go Up