December 08, 2010

Arduino Tiny Web Server - part 3


Update (September 3rd, 2011): The code is on Github:

A zip file of the latest version of Arduino TinyWebServer can be found here

What is it?

Arduino TinyWebServer is a library implementation of a small web server running on an Arduino Duemilanove or Uno using the new Ethernet Shield released at the end of September 2010. The new Ethernet Shield adds a microSD card right on the board, in addition to fixing a number of hardware bugs from the previous iteration.

The library is meant to provide a Web interface to your Arduino project. It is not meant to be a full Web server implementation, just the minimum amount to let you get started quickly.

To save precious memory space on your Arduino, TinyWebServer encourages you to develop your web applications as AJAX applications. This means that you should delegate the page generation and complex UI interactions to the Web browser, instead of trying to handle it on the Arduino side of your project. The only thing the Arduino should implement is retrieving and displaying the internal state, as well as modifying it using HTTP POST requests.

Changes from the previous release

As you're probably aware, a new Ethernet Shield for Arduino was released at the end September 2010. I bought one and I'm pleased to report that it fixes an annoying hardware bug present in the old shield. In addition it has a new microSD slot that is actually accessible through a dedicated SPI SS pin. This means that you can use an Arduino Duemilanove or Uno with the Ethernet Shield with no modifications whatsoever.

I finally had some time to update the Arduino TinyWebServer library to make it work with the new shield. As you can see in the picture above, the setup is much easier than with the old Ethernet Shield and the data logging shield. The new library version drops support for this kludgy setup.

  • Compared to the previous release, the new Arduino TinyWebServer release removes the dependency on the EthernetDHCP library. As a result you need to configure the IP address of the Ethernet shield manually inside the examples to match your network. Of course you can still add EthernetDHCP support to your own sketches if you wish.
  • The library now uses the SdFat library instead of the Fat16. This allows the use of microSD cards larger than 2GB, formatted with FAT32, not only cards less than 2GB formatted with FAT16.
  • The new release no longer uses a modified Ethernet library. It instead uses the existing Ethernet library that comes with the Arduino IDE.
  • The code was updated to work with the latest Arduino IDE, version 021.
  • I fixed a bug related to memory allocation and how the Ethernet Client objects were returned through the API.

In the new release I've added a new example that shows how you can control an LED from a regular Web browser. The video below demonstrates how it works.


Arduino TinyWebServer is a library and as such requires you to write code customized for your own application. Some almost ready-to-go examples can be found inside the distribution in the examples/ directory. Follow the instructions in the README.txt files for each of the examples.

An explanation of the library's API can be found in this older post. Some things like the EthernetDHCP code no longer apply, so please look at the new examples for the updated code. Still most of the code is still applicable.

Posted by ovidiu at December 08, 2010 10:36 PM |

May you also share a code for mobile app for a example?

Posted by: Tynis on January 8, 2011 01:34 PM

Tynis, the mobile application is nothing else than the phone's web browser pointed to the Arduino web server. If you want a custom Android application with its own icon, you can easily build a WebView-based application. You can probably do the same thing on an iPhone, but I'm not familiar with it.

Posted by: Ovidiu Predescu on January 11, 2011 05:13 PM
Post a comment

Email Address:



Remember info?

Copyright © 2002-2016 Ovidiu Predescu.