Introducing the Webduino web server library

On Saturday, I taught a class at NYC Resistor on a new library I've developed that I'm calling Webduino. It's an extensible web server library for the Arduino using the Wiznet-based Ethernet shields. I've setup a Google Code project for it at http://webduino.googlecode.com/, and it's released under the MIT license allowing all sorts of reuse. I've also put my not-quite-complete presentation up for viewing at http://tr.im/WebduinoPressy .

I've got a few examples up right now -- the Buzz example interfaces with Zach's Danger Shield allowing you to remotely start and stop the speaker. We had a room full of students pinging my Arduino board on Saturday, buzzing me while I was lecturing. It was fun. The big Demo example shows how to setup an HTML form running on the device where you can read and write pins.

You use the code like a library; you install the header in the libraries folder, pull in the code using a #include, and setup the relative URLs that you want your server to handle. You can do different things for GETs and POSTs, making it easy to create forms that will give you the page with all the controls, then process the submission.

I hope to add a few more examples in the next few weeks, including a web-enabled fridge sign using a serial LCD and how to serve things other than just HTML text from the device. I also need to work on more documentation and finishing up my slides, but I think it's a great base for other people to experiment.

Hi,

You might want to take a look at some of the entries dated March onward on this page: Flashduino

It uses what (from a quick glance at your work) seems to be a similar approach to what you have implemented--except yours seems a bit tidier at the moment. :slight_smile:

--Phil.

Cool... I'll take a look at the Flashduino project. My objective was to have a framework that the students could easily build on. Originally, it was going to be more adhoc, but a few days before the class I realized that I could turn the server code into a class that could be extended, making the interface for changing it a lot easier for people to comprehend.

That project also pointed me at Ethernet2 which looks like a nice refinement. I'll probably add a #define check in the 1.1 version to let people use that version of the library if they want.

interface for changing it a lot easier for people to comprehend.

Ditto. :slight_smile:

That project also pointed me at Ethernet2 which looks like a nice refinement. I'll probably add a #define check in the 1.1 version to let people use that version of the library if they want.

In theory it should be a drop-in replacement, unless someone wants it to coexist with the original.

--Phil.

I had been #including Ethernet.h from the WebServer.h file, but I think I'll just change it so the user needs to #include that header first, which means the web server code wouldn't care which one was used.

I have a problem with webduino ...
"Web_helloworld " ok
but with "Web_Buzzer" and "Web_Demo" exemple, browser wrote : EPIC FAIL ! :o

You need to go to http://your.ip/buzz or /demo depending on the setting of PREFIX in the example sketches.

Ach! understood! I try tonight! ... I was very superficial! :-[
thank you very much! :wink:

I've just updated the library to version 1.1. This mainly does some code cleanup, adds a robot.txt "don't go here" response, and makes it easier to reply with custom headers. There's also additional example sketches, including one using jquery to do dynamic speaker control.

Thanks for webduino, Ben: marvellous module. I've used it for this monitor.

I'm glad it works well for you. I've heard a report of there being connection problems with Safari, but I've not tried that yet. If you have suggestions of changes, please let me know.

I am a Arduini newbie and thanks to Webduino, got a customized web application running in a couple pf days!

I'd appreciate it if you could point me to an example of reading parameters from an http GET to control a digital pin for example by sending h t t p://myip/test?d1=1&d2=0

I tried different codes and commands but always end up getting "EPIC FAIL".

Thanks!

Mat

If you're getting EPIC FAIL, look for the PREFIX setting early in the example source code. That's what you need to add to the front of the URL to access the site. Define it as "" to remove the prefix entirely.

Thanks! The EPIC FAIL is not the real problem. I am able to access the web pages without any trouble. I get the EPIC FAIL only when I am trying some examples to parse the parameters out of a GET query; ie only when I add the ?d1=1 part to the root URL. I can get to the root URL without any issues.

I am looking for a way to grab the URL query parameters from a GET query to process it further and asking for ny help here.

That's a feature request, alas. Right now, the GET handler in the Webduino library isn't setup to look for the '?' character and use that as a delimiter for reading parameters. Because of the way that processing works, this is a bit difficult because we really want to process arguments after we've read the whole incoming header. POST supports this by putting the arguments in the payload that comes after the header.

This can be done... it just requires some smarter processing and some new code.

I've added this feature request at the Google Code site to track this: Google Code Archive - Long-term storage for Google Code Project Hosting.

Thanks! I mistakenly thought this was already a feature may be because somewhere in the comments for the server I thought I read something about reading parameters from GET also. I was looking for this because I wanted to send some control commands through a shell script from my router and the router doesn't support cURL to be able to send the POST request.

Thanks again for a the great piece of code and I am good to go for now. Trying to mess with some Ajax/JSON stuff.

Curl does POST great -- we used it in my class. Try the -d / --data option to specify the payload to post to a URL.

Yes, cURL works fine from other Linux machines but the router doesn't have cURL. Will look around to see if it's possible to get this installed on it though. Thanks a lot for all the suggestions!

If it has wget, it may have a --post-file or --post-string option, although the busybox version of wget doesn't have the options.

I will try to look at supporting GET with parameters, I just don't know when.

I've made a modified version of Ben's code that supports adding parameters to URLs.

If you'd like to beta test it, drop me a private message with your email address, and I'll send you a copy.

Ran