Go Down

Topic: Controlling Arduino via Web (Read 3590 times) previous topic - next topic

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?
Keep it simple.

AWOL

Quote
(I'LL NEVER USE AN IC AGAIN).

:smiley-eek:

Did you look over at the playgound at examples of web servers and web clients using the Ethernet shield?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

frank26080115

PHP is server side, the serial port being used has to be on which ever computer is the server, in your case "computer X"
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Rainier9

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.
Keep it simple.

Kris


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.


hope i got this right from what you say.

fableman

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.

I don't se why that should be a problem.






jthawkins2001

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:
http://mowstation.blogspot.com/2011/08/wires-we-dont-need-no-stinkin-wires.html

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

Rainier9



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.


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).
Keep it simple.

zoomkat

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.

http://web.comporium.net/~shb/wc2000-PT-script.htm
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

adis

Hi,

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;
}
}
});
}

Hope it helps

Rainier9

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. :/
Keep it simple.

daveg360

What port are you using?  I've heard that some ISPs try to stop you hosting from home.
If your system involves lethal voltages/life critical/flamable elements - you probably shouldn't need to ask.
The Arduino != PC.

Rainier9

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.
Keep it simple.

zoomkat

Quote
Im having trouble connecting the Apache server to the internet (in LAN it works perfectly though)....


Unless you have a static IP address assigned to you, you will need to use a dynamic IP service like dyndns or no-ip to use with your web page.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Rainier9


Quote
Im having trouble connecting the Apache server to the internet (in LAN it works perfectly though)....


Unless you have a static IP address assigned to you, you will need to use a dynamic IP service like dyndns or no-ip to use with your web page.


I set up a Static IP.
Keep it simple.

Go Up