Pages: [1]   Go Down
Author Topic: Generic Ethernet (Web) Server  (Read 1104 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to control/access to Arduino with Ethernet shield with an external program running on a PC-server in the LAN.
Therefore I think I need a protocoll like HTTP.
For example:

* the server makes a GET request to the Arduino asking for the state of digital Pin 2. http://<ip_arduino>/digitalRead/2
* Arduino responds with the state of the pin with JSON or text:  {'digitalPin2':1}

Is there already a library that implements this with the core functions available on the Arduino? (read/write Digital / Analog, read 1-Wire temperature etc.)

I've found a WebServer Library [1] that allows to attach request handler functions to URL's.
What has to be done is writing such request handlers for all the arduino functions.
Has this been done somewhere already?
If not, is there a community interest for such a thing?

Is there another way to control Arduino by LAN easily?

--
Greg

[1] http://www.webweavertech.com/ovidiu/weblog/archives/000477.html
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49307
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the server makes a GET request
Servers don't make requests. Clients do. Servers respond to requests.

Quote
Is there already a library that implements this with the core functions available on the Arduino? (read/write Digital / Analog, read 1-Wire temperature etc.)
All the libraries are available. What you need to do, if the Arduino is to be a server, is parse the GET request, and serve up the requested page, calling other library functions, as needed, to get the data required to service the request.

Quote
I've found a WebServer Library [1] that allows to attach request handler functions to URL's.
What has to be done is writing such request handlers for all the arduino functions.
What is to be connected to the Arduino? It does no good to serve up a page that shows temperature if there is no temperature sensor connected to the Arduino.

In general, the WebServer library is overkill, since the Arduino is already serving some purpose for which you want the data to be available from the internet. Possibly, you want to control some stuff from the internet, too.

Get more specific about the Arduino you have, what is connected to it, what you want to expose to the world, and what you want the client to be able to do, if you need help doing something.
Logged

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


Quote
Servers don't make requests. Clients do. Servers respond to requests.

This is a server in a sense that it is a server that I already have. It will serve the arduino data to other clients.
In the protocoll it is maybe a client but that is a irrelevant detail in regard to my questions.

Quote
All the libraries are available. What you need to do, if the Arduino is to be a server, is parse the GET request, and serve up the requested page, calling other library functions, as needed, to get the data required to service the request.

Yes I already know that libraries exist that can act as a webserver ( Instead of you I even posted a URL).
What I've asked for is if there is a webserver that implements the core arduino functions.
In not answering this question I have to assume that you don't know or such a thing does not exist.

Quote
In general, the WebServer library is overkill, since the Arduino is already serving some purpose for which you want the data to be available from the internet. Possibly, you want to control some stuff from the internet, too.

Get more specific about the Arduino you have, what is connected to it, what you want to expose to the world, and what you want the client to be able to do, if you need help doing something.


No, I did not mention the Internet. I want a library that can call the core arduino functions (digitalRead, digitalWrite, etc) by LAN.

At the moment I have an old computer with a python program that controls my heating with the parallel PC Interface.
This computer is defective because of dirt and heat in the heating room. I therefore want to replace this computer with an arduino acting as low level interface to the heating and the seperated server which controls the arduino by LAN.
I don't want to reimplement this software for the arduino. Instead this program should run on the server and only the parallel interface part should be replaced by the LAN protocoll to the arduino.

--
Greg
« Last Edit: December 04, 2011, 10:38:58 am by horli » Logged

0
Offline Offline
Tesla Member
***
Karma: 143
Posts: 9586
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't want to reimplement this software for the arduino. Instead this program should run on the server and only the parallel interface part should be replaced by the LAN protocoll to the arduino.

You can have an ethernet shield (W5100 based prefered) connected to your arduino. With server code running on the arduino, and with the ethernet shield attached to your LAN, the arduino can receive request to do certain things and provide data back to the requesting client. Http protocol is fairly simple to implement (telnet night be another option). It will be up to you to develop the applications for the pc that will be the connecting client to the arduino server. IE and other browsers can be used as a shell application if human control at the browser is not used.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49307
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I've asked for is if there is a webserver that implements the core arduino functions.
I did not post a URL to such a library because none exists. Primarily for the reason that none is needed. A "generic web server" is a useless concept. Web servers exist to provide specific data, and to perform specific actions.

Quote
I want a library that can call the core arduino functions (digitalRead, digitalWrite, etc) by LAN.
So create one.

Quote
and the seperated server which controls the arduino by LAN.
You are still mixing client and server. The Arduino can be a client. It will, once or periodically, request data from a server. "Is it time to turn on the heat?" seems like a silly thing to ask a server, though.

The Arduino should be a server. A client can then ask it "How warm is it in there?" or "Can you turn the heat on?" or "Can you turn the heat off when it gets to be 68 degrees?".

From your description, it appears that you have a specific need for the Arduino-as-server. The relationship between this specific need and the "generic ethernet (web) server" is not at all clear.

Finally, I used the term internet in it's most generic sense - the transfer of data between two networked devices. Whether that network is connected to the world wide web, or not, is irrelevant. Though, most people that do put an ethernet shield on an Arduino as server do want to be able to access the server from anywhere, which requires a connection to the web at some point.
Logged

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

Removing all the unnecessary noise it seems that the short answer to my question is:

 NO

there is at the moment no ready to go library that implements a LAN interface to core arduino functions (digitalRead, digitalWrite etc.).

So I will have to program such a generic interface.

If I do I will public it as free software, because I think there are perfectly valid use cases for such a thing.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49307
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Removing all the unnecessary noise...
So, if the first reply you got was a simple, terse "NO", you would have been happy?

I doubt it.
Logged

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

Quote
Removing all the unnecessary noise...
So, if the first reply you got was a simple, terse "NO", you would have been happy?

Yes, because I am not interested in a nitpicking conversation if it is a client or a server protocoll wise, nor if you think such a thing is overkill, nor in your opinion if it is generic.

--
Greg

Logged

Tacoma, WA
Offline Offline
Full Member
***
Karma: 4
Posts: 192
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I had to do something similar with my Arduino controlling my Christmas lights. I suggest making the commands you send to the Arduino single character. This makes things not just simpler, but saves on memory consumption.. So like digitalWrite could be W, analogWrite could be w, analogRead could be R.. etc etc., really easier to work with a single character anyways.  I have my webserver relay to the Arduino server commands like m=5, s=6, then you've got something like:
if incomingRequest[1] == 'm' then mode = convertCharToInt(incomingRequest[3]);  // (simplified code..)
I don't have mine setup to reply, but that'd be pretty easy to implement, I actually yanked all the reply routines out of mine because they were pointless in my application..
You can see my code here: http://pastebin.com/WpzCzLur  I'm not using the W5100, I'm using the cheaper alternative, but it's a memory hog, so the W5100 is what I recommend as well.
Logged

Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

0
Offline Offline
Tesla Member
***
Karma: 143
Posts: 9586
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
there is at the moment no ready to go library that implements a LAN interface to core arduino functions (digitalRead, digitalWrite etc.).

The problem is that you are tossing around well known technical terms in such a jumbled up way that I doubt most people can figure out just what you are talking about. The above is an example.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

london
Offline Offline
Full Member
***
Karma: 0
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think firmata does something like what you are asking for - you can control and configure the board from a host computer. There are various implementations for using it over ethernet around, but I think they are all fairly old, so may not work with the most current version.
Logged

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

I think firmata does something like what you are asking for - you can control and configure the board from a host computer. There are various implementations for using it over ethernet around, but I think they are all fairly old, so may not work with the most current version.

Thank you for your constructive input.
This looks indeed very promising http://tinkerit.googlecode.com/files/eth_Firmata_v1.pde

--
Greg
 
Logged

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

Quote
I had to do something similar with my Arduino controlling my Christmas lights. I suggest making the commands you send to the Arduino single

Great, thank you! Looks a lot like the thing I was thinking of...

--
Greg

Logged

Pages: [1]   Go Up
Jump to: