Greetings to all, my name is Rainier, currently in my second year of Telematics Engineering (A nice mix between Electronics Eng, Computer Science and IT networks), new to Arduino and discovering lots of stuff with it! (I'LL NEVER USE AN IC AGAIN).
I've got a question: Is it possible to control, let's say a LED, via a Web Page? I've seen videos in youtube doing it but the creators of the video never specify if they are working in a LAN or over the internet.
What I basically want to do is to control 3 different devices (let's say 3 light bulbs to make it easier) in my dorm, but while I'm at college. It doesn't matter if a PC has to be attached to the arduino in order for the system to work.
I heard PHP is the way to go, but let's say I program a web page using PHP, linking some functions to send data thru the serial port of Computer X, and then I go to the page I designed in Computer Y and ''click'' in the function, will Computer X still send the data thru the Arduino or it would be computer Y instead?
In simpler words, independtly where I log on, the computer in which the Arduino is attached will always be the one to send the data to the arduino? Or I need some extra code to NOT let that happen?
So I would be able to send the data even If I upload the PHP page to the web. Any good tutorials that you would recommend? @AWOL: I was thinking of using my own pc as a web server, instead of the Ethernet Shield.
Rainier9:
Greetings to all, my name is Rainier, currently in my second year of Telematics Engineering (A nice mix between Electronics Eng, Computer Science and IT networks), new to Arduino and discovering lots of stuff with it! (I'LL NEVER USE AN IC AGAIN).
I've got a question: Is it possible to control, let's say a LED, via a Web Page? I've seen videos in youtube doing it but the creators of the video never specify if they are working in a LAN or over the internet.
What I basically want to do is to control 3 different devices (let's say 3 light bulbs to make it easier) in my dorm, but while I'm at college. It doesn't matter if a PC has to be attached to the arduino in order for the system to work.
I heard PHP is the way to go, but let's say I program a web page using PHP, linking some functions to send data thru the serial port of Computer X, and then I go to the page I designed in Computer Y and ''click'' in the function, will Computer X still send the data thru the Arduino or it would be computer Y instead?
In simpler words, independtly where I log on, the computer in which the Arduino is attached will always be the one to send the data to the arduino? Or I need some extra code to NOT let that happen?
i hope i got this right, so here goes,
if you develop a php page on computer x you will need to plug the arduino into that PC as well so that when the PHP page sends it serial commands they goto the arduino as long as the page on computer x is available on the internet you can simply browse to computer x's web page from any internet device and control the arduino from it (so can the rest of the world if its a public page mind you).
if you upload the PHP page to a webserver or hosting company it wont work as you wont be able to plug the arduino into that server (and the hosting company has proberbly blocked PHP from giving serial commands anyway), you can however setup the ethernet shield on the arduino get a page setup on there that does the work and then just plug the arduino and ethernet shield into your router (configure router to allow access to the shield from the internet) and your away.
Buy a ethernet shild to your Arduino then connect it to Internet and do what ever you like from a webserver anywhere to access your device.
To use a external webserver: I would advice you put Arduino behind a NAT firewall and use portforward in your firewall to forward only from that external webservers static IP address towards your arduino device.
Still you can do as you say, letting your computer running a web-server that talk directly to your arduino over seriel/USB. Linux or windows.
What I did for web, which works very well for my robot, was install dd-wrt to a wrt54gl router, and then add a serial port using a logic level converter to go between 5V of the arduino serial, and 3.3V of the router.
Then, you can use ser2net installed on the router to basically link a TCP port on the router to the serial connection.
So talking with the arduino becomes as easy as writing a TCP client and connecting to that port, and sending/receiving data.
Check out my blog for more information on how I did this:
Also, as a note, if you want to put this robot on the web, you can actually bridge your wrt54g router connected to the arduino to your home wireless, to link everything together. (Then through simple port forwarding and dyndns, you are on the web).
if you develop a php page on computer x you will need to plug the arduino into that PC as well so that when the PHP page sends it serial commands they goto the arduino as long as the page on computer x is available on the internet you can simply browse to computer x's web page from any internet device and control the arduino from it (so can the rest of the world if its a public page mind you).
if you upload the PHP page to a webserver or hosting company it wont work as you wont be able to plug the arduino into that server (and the hosting company has proberbly blocked PHP from giving serial commands anyway), you can however setup the ethernet shield on the arduino get a page setup on there that does the work and then just plug the arduino and ethernet shield into your router (configure router to allow access to the shield from the internet) and your away.
hope i got this right from what you say.
This.
Can you (or anyone else) explain me how the Ethernet Shield works? I want exactly what you said: Control the arduino from the internet, not in a LAN but from anywhere I am. (as for security, I could request a password to enter the website devoloped in PHP).
You can do something similar to below (control servos, etc) with your arduino by running apache on a windows machine with the arduino attached, or use an ethernet shield with the arduino instead of the pc. If you get an ethernet shield, get the W5100 version for simplicity.
You can buy an ethernet shield plug it over arduino and (using webduino library) this is your server.
The client it's a web page hosted on a mobile device. To make cross site calls you can use the jsonp javascript library.
The client call looks like this:
function SendOnOffCommand(field){
var url = "http://" + connectionIp + "/SetOnOff.json?switchId="+document.getElementById(field.id).getAttribute('switchId')+"&state="+document.getElementById(field.id).getAttribute('state')+"&secId=" + secId;// + "&callback=?";
$.jsonp({ url: url,
context: document.body,
error: function(xOptions, textStatus){
if (textStatus!='error'){
alert(textStatus);
this.checked=false;
}
}
});
}
Im having trouble connecting the Apache server to the internet (in LAN it works perfectly though)....
Anyone with experience in the subject here?
I've tried everything, port forwarding, setting static IP,enabling firewall...I don't know what else to do.
Yep, I think that might be the issue here. After google'ing some pages, I discovered that port configuration varies from the router you have.
I'm using a Wireless router (I don't get the internet from a street cable but from an antenna), and in wireless routers the ISPs block most of the ports.
So I had to call them and tell them that I want port 80 open for gaming, and they told me that in 48 hours they will do so. Hopefully, that'll solve the problem.
Hi all, I've decided using an Arduino Ethernet Shield after all.
I have some questions though, questions that if answered, will make me able to comprehend how the Ethernet Shiled + Arduino combo works.
1.- I've read the the Ethernet Shield is capable of creating a web server and connecting it to the internet. How? I mean, whats the configuration you need to do to make that possible? the Arduino would need at least an IP address.
2.- If connected to the internet, to what IP address or domain name will the clients go to in their browsers? Let's say I develop a web page capable of monitoring some offices in a building, and the page is capable of turning off and on the lights in said offices. If I'm the floor administrator, to what page I must go to in my browser?
3.- If it is indeed possible to make a web server to host a page, can I design that page in PHP/HTML?
1.- I've read the the Ethernet Shield is capable of creating a web server and connecting it to the internet. How? I mean, whats the configuration you need to do to make that possible? the Arduino would need at least an IP address.
The shield needs an IP address, a MAC address, and possibly a subnet mask. The IP address is how other devices find the Arduino with shield. The MAC address must be unique on the network. Newer Ethernet shields come with a MAC address that you should use.
2.- If connected to the internet, to what IP address or domain name will the clients go to in their browsers? Let's say I develop a web page capable of monitoring some offices in a building, and the page is capable of turning off and on the lights in said offices. If I'm the floor administrator, to what page I must go to in my browser?
Can I for example, download and edit a template, then save it to the Shield?
You can't save anything to the shield. It's hardware with read-only memory that comes pre-programmed. What kind of template are you thinking about? Typically, web pages served by the Arduino are very small, since the Arduino doesn't have a lot of memory.