Pages: [1]   Go Down
Author Topic: Best way to control arduino via network?  (Read 2254 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,

Im at a cross roads... I would like to be able to control my arduino via my network.
One way I would like to do this is via some kind of webpage that can connect to the arduino.
The data that needs to be transfered is minimal (ASCII Character '2' and '3' need to be sent)

What would be the best way for me to interface with the arduino via a webpage?
I have looked at using python but it seems a lot of CGI programming is needed for such a small task.

Does anyone have any other ideas?

Thanks
Mathew
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 239
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://ladyada.net/forums/viewtopic.php?t=6736
Logged

Tønsberg, Norway
Offline Offline
Full Member
***
Karma: 0
Posts: 148
Arduino rocks hard!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No problem, man! Here's the simplest possible solution:

Step 1:
Download serproxy
http://www.lspace.nildram.co.uk/freeware.html
You'll probably have to modify the serproxy.cfg but you'll figure it out. Most importantly the serial settings have to match those of your Arduino, and you have to know which port number the php script will connect to. The following line in serproxy.cfg will tell you the portnumber:
net_port1=theportnumber

Step 2:
Do you have any experience using php? If not, then start learning! Got a webserver with php? If not, download and use PortableWebAp http://portablewebap.com/portablewebap.php This is a very simple, tough rather complete webserver. You'll figure it out. smiley-wink


Step 3:
Build the website! I'll give you a very basic script to send data to your Arduino through serproxy.

Code:
<?php
if(!empty($_GET['do']))
{
      
//open a connection to your computer running serproxy, on the port you found in serproxy.cfg
      
$fp fsockopen('localhost'5331$errno$errstr) or die('Error('.$errno.'): '.$errstr);
      
      if(
$_GET['do'] == 1)
      {
            
//send character code 2. Can be replaced with whatever you want
            
fputs($fpchr(2));
      }
      elseif(
$_GET['do'] == 2)
      {
            
fputs($fpchr(3));
      }
      
      
//close the connection
      
fclose($fp);
}
?>

<a href="?do=1">On</a><br />
<a href="?do=2">Off</a><br />

There you go, that should be it! Don't hesitate to ask further if you need more help. smiley

Oh, don't forget to replace 5331 in the script with whatever portnumber you have in your serproxy.cfg!
« Last Edit: August 19, 2008, 03:46:06 am by PlastBox » Logged

Dreaming of extra senses through sensory substitution/agumentation since.. well, for ever.. =P
Going to automate my home, just gotta find the perfect DIY solution first!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome smiley Ill try that today, thank you very much for your help smiley
Logged

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

use the serproxy provided on the arduino software page , it has a few improvements

massimo
Logged

Tønsberg, Norway
Offline Offline
Full Member
***
Karma: 0
Posts: 148
Arduino rocks hard!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So.. have you got any progress for us yet? smiley-grin
Logged

Dreaming of extra senses through sensory substitution/agumentation since.. well, for ever.. =P
Going to automate my home, just gotta find the perfect DIY solution first!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lol,  actually ive not looked at this bit yet, still doing my research.
the ultimate goal with this project is I want to be able to use multiple arduino's to control various aspects of my house using an internal apache server.

So a unit to open the garage doors + a thermometer so I can see how cold it is outside + in the garage + open and close the garage doors via a http interface.

I want to have my TV hidden in a cabnet / in a recess behind a mirror - so an electronic interface is needed to move some servos, then the TV is one of those with an RS232 control interfaces so i can say when the TV comes on and goes off (great for dealing with the kids)

Then i have to make all the system totally invisible to a stupid person because my wife doesnt want to have to deal with a complex set of buttons just to turn on the tv. - so quite the challenge but im sure the pay off will be worth it.

Logged

Tønsberg, Norway
Offline Offline
Full Member
***
Karma: 0
Posts: 148
Arduino rocks hard!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Aaaahahaha, ballsy man! You just called your wife, and I quote: "..a stupid person.."! ;D But alás, I know your situation. Been lusting for the chance to build a home automation system for years now but first of all I'm only renting an apartment for now and second, my girlfriend (who I share the apartment with) wouldn't like anything fancy like that. Besides, I'd not like to have to pull out my cellphone every time I needed to switch a light or chance channels on the tv. I'd like to retain the physical light switches and such but also be able to control everything from a central comuter (and from there, a webinterface, a tiny webinterface for cellphones with GPRS, perhaps bluetooth, etc), and also keep the traditional tv/dvd/etc. remotes but at the same time have an IR interface on a computer to control it. Or perhaps just have a mediacenter pc that I stream music, tv, dvd/video and other media through so I can control it over the network without the need for the IR interface.

Anyways, hook something up to the net and set a webcam on it! Even if it's just a few leds beeing controlled from your website, I'm sure people would love to play around with it. ^-^
Logged

Dreaming of extra senses through sensory substitution/agumentation since.. well, for ever.. =P
Going to automate my home, just gotta find the perfect DIY solution first!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok very poor use of words their..  ;D - thank goodness she doesn't read this forum.

When i mean stupid people, I refer to the state of 'Im not interested in how fancy you make it, Im just interested in watching TV and getting on with my life'. Basically it needs to look  simple to people who are only interested in the simple 'TV turn on' type thing and then for anyone that wants complex that lies under the skin...  

This whole project stated because we only have 2 garage door remotes and I dont want to buy another one id rather engineer a solution so that I can connect via my iphone to the house network enter a password and access the garage door mechanism when im 50 yards out. The thermometer is just an added idea and then so became the house network too - but i figured in for a penny in for a pound so I might as well go as far as i can, esp as Ive just bought a totally depilated house and will have to strip it back to frame I might as well put some extras in their too.

I have seen somewhere a light-switch that is X10 ready  so you can physically switch on the light at the switch but also control it via X10.
Logged

Tønsberg, Norway
Offline Offline
Full Member
***
Karma: 0
Posts: 148
Arduino rocks hard!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Man, I hate people with mindsets like that.. Which, unfourtenately, leaves me hating a scary number of people. I mean, I NEED to know how stuff works! Even if I might never use the knowledge for anything usefull I still love just knowing and the more one knows, the easier it gets to understand something new. Imagine where we as a species would be if everyone had that kind of mindset...

If that is your goal, go freaggin' do it! Your garage door probably has an open/close button on the inside. Hook up a transistor, relay, opto-isolator, whatever you like (or rather, need) to that. Add a switch that gets pressed when the door is closed and 2 thermistors. The ones they have at Sparkfun seem good, and Sparkfun showing you how to convert the readings into degrees is an added bonus.

So part count for something really cool this far:
- Arduino
- wires
- transistor (and relay, if the voltage is above something a transistor can handle)
- 2xthermistor
- button

What are you waiting for, man? Any tinker with some self respect has a switch and some wire lying around. Go out and hook it up to your garage door and make a password protected webinterface for it! (I can help with the web-stuff if you need it smiley)


Yeah, I know about X10. There is even an Arduino library for controlling X10 devices, though I don't know what kind of hardware I'd need to send signals from the Arduino to the devices. Would be a pretty smooth solution if a bit pricey. There are even dimmers, and every device comes in versions that can tell the central control unit their state. But then, why not just buy a starter pack that contains the "computer signal to mains wireing signal"-device and use that instead of the Arduino? =P
Logged

Dreaming of extra senses through sensory substitution/agumentation since.. well, for ever.. =P
Going to automate my home, just gotta find the perfect DIY solution first!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with you, I have to know how it works. Ive spent countless hours taking things apart to reach the 'Ohhh so thats how they did it' stage in my life.

I think ill have to setup a website to report the progress of this project. Thank your offer of help. Ill no doubt be asking for it.
1st plans are to make the building structurally sound again. Bring on the concrete.. smiley-grin
Ive already had help with the garage door opening software:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1217775372/

then next plan is to design a cool mechanism to hide / reveal the TV. I want it hidden behind a mirror. Simple users can press the power button on the TV and it moves the mirror and brings the TV forward. Clever users... Im thinking the 'clapper' just for that added effect. Really clever users: can access via web server. but this is all just fantasy at the moment. Ive got a lot of work to do before I can get to that point in the project.

Logged

Pages: [1]   Go Up
Jump to: