December 2011

You are currently browsing the monthly archive for December 2011.

As reported earlier I had been given an Arduino Uno. I subsequently received my Ethernet Shield to hook the board up to the network. I’m clearly heading towards the Internet of things… Although I am still not 100% certain about what I’m going to do with the board (or how many additional ones I am going to have to buy) one things is pretty clear: It will have to be controllable and/or configurable over a web interface.

I found the Webserver example that ships with the Arduino IDE to be rather dull and unflexible. It wasn’t long before I stumbled upon Webduino, a very flexible generic Web Server library originally written by Ben Combee. The Webduino project homepage on Google Project Hosting points to this GitHub page. I downloaded the version adapted to Arduino 1.0 and started hacking away. Let me say this now: Webduino does meet my expectations.

However after a short while I ran into problems. None of them were to blame on the library, but rather on myself, but that’s actually not the point of this post… When I ran Wireshark to look at the data going over the network I noticed that for every page loaded Firefox also tries to download favicon.ico from the web server. Since Webduino sends a 400 error back on any requests for resources that have not been defined Firefox just keeps retrying forever.

At around the same time I discovered that, to avoid excess traffic from robots, there is a default robots.txt built into Webduino. So I decided to add a default favicon.ico, based on the icon used in the “Web_Image” example that ships with Webduino. Now when the first page is requested, Firefox loads the icon file, which actually eats more resources than one 400 error, but it pays off down the road when Firefox caches the icon and does not request it again, saving the Arduino from having to generate many 400 errors…

Webduino "Hello World!" page with favicon.ico

Webduino "Hello World!" page with favicon.ico; this is the default favicon.ico in my version of Webduino

And since I see projects hosted on GitHub as an open invitation to fork I ended up with my own Webduino project on GitHub. Feel free to look at the code, to fork, clone, whatever (MIT license), and to let me know what you think! (Oh, and I gave the readme some TLC and also added a keywords.txt file for syntax highlighting.)

Update: I started to write a “beautiful” API documentation

I found an Arduino Uno under the X-mas tree:

Arduino Uno

I’m still waiting for my Ethernet Shield to ship. In the meantime I wanted to get started with some of the “simple” stuff like controlling single LEDs, triggering events using pushbuttons etc. It came in handy I still had my 1980’s “Kosmos electronic X3000” workshop kit around, which I used to experiment with when I was a teenage nerd:

Kosmos electronic X3000 workshop

I guess I’m still a nerd: My heart jumped a bit when I found out they seem to still sell these things.

Here’s what they look like in combination:

Arduino Uno with Kosmos "breadboard"

You and I know that talking about new ideas prematurely is the best way to kill them. Anyhow you should expect some Arduino related posts over the next year or so…

Some of my clients are using their WordPress installs with pages only, i.e. without any posts, and with comments turned off completely. This is often referred to as “WordPress as a CMS”. To free the screen from clutter I like to remove the comments link from the new/revised WordPress 3.3 Admin Bar. I also usually change the “+ New” link to default to creating a new page instead of creating a new post.

To accomplish this you can drop the following lines into your theme’s functions.php file:

<?php
function my_admin_bar_menu( $wp_admin_bar )
{
  $wp_admin_bar->remove_node( 'comments' );
  $newpage = $wp_admin_bar->get_node( 'new-page' );
  $wp_admin_bar->add_node( array( 'id' => 'new-content', 'href' => $newpage->href, ) );
}
add_action( 'admin_bar_menu', 'my_admin_bar_menu', 100 );

To find out more about the Admin Bar API you should check out this post by Andrew Nacin on the official WordPress Development Blog.