Getting started with Node.js and Web Sockets on Ubuntu 10.04

Having spent the past few hours taking my first steps into the glorious unknown world of web sockets I’ve drawn a few conclusions about web sockets:

  • The principals are very easy
  • It is an area of great interest and development
  • There are seeming 101 different implementations many of which are out of date and broken

Screenshot of Node.js running Web Socket Server on Ubuntu

So this post I want to document a simple demonstration of the use of web sockets with node.js  which works now (August 2010) to serve as simple demonstration to those wanting to dip their toe in the water before going further. Many examples and demos were outdated and failed to run for a variety of reasons, mainly due to node.js being updated and the examples not being changed to reflect this. I did all this on ubuntu but there is no reason why it shouldn’t work on any other Linux system.

Read more ▼

Sheevaplug – Why Globalscale suck

In my previous post Sheevaplug – An ideal home server I described why I loved the sheevaplug, now in this post I’m going to discuss why I now have fallen out of love with it. The main reason is shown in the following photo:

Inside the Sheevaplug Power Supply

For the past six months I’ve been using the unit for 24/7 IRC using irssi, running an MQTT server and broadcasting to pachube, along with allowing me to ssh tunnel into a secure internet connection when using public wifi. So far so good. However during the middle of last week I noticed my pachube feeds had frozen, I tried to ssh into the device and that failed so being at work at the time I was miffed and couldn’t wait to go home to find out what was wrong.

Read more ▼

Testing Ubuntu Unity on my eeepc 901 (with screenshots)

At the Ubuntu Developers Summit this week one of the major announcements so far is Ubuntu Unity, a new lightweight GUI. The aim being to take the best features from instant on type Linux systems while still providing a fully featured system, this type of system being ideal for netbooks and appliance type computing. This GUI will form the basis of a currently OEM only distro; ubuntu light designed for instant boot appliance or netbook computers.

Ubuntu Unity on eeepc

Despite only being in its infancy there is already a ppa available to install unity on ubuntu 10.04 so I decided to try it on my eeepc 901 on which I currently use vanilla ubuntu 10.04 as I don’t get on with the current Ubuntu Netbook Remix interface. One of the things that I’ve never quite got right is fitting everything on my 9″ netbook screen so I had high hopes that this new interface with vertical dock might do better in this respect.

In this post I’ll quickly detail how to install it and then quickly look at it’s features and shortcomings, I won’t repeat everything which has already been written regarding what plans are for the future.

Read more ▼

MQTT, Arduino, Old Ammeters and Bandwidth Monitoring

Thanks to some help from @knolleary the arduino pubsub library now works with mosquitto. I have now completed my bandwidth monitor project which I want to document in this post.

I have mentioned in previous posts that I use various scripts and sensors to feed data into the open source MQTT broker mosquitto. Currently all data is posted to pachube, rather than everything being online I decided I wanted some physical feedback. Having made an impulse buy of two vintage Ferranti ammeters using these to display some of my data seemed like obvious answer! The code on the arduino basically just displays a number passed by MQTT on the meter and therefore could be applied to any measurement one cared to choose.

The basic idea of this system is to monitor the current internet speed usage and display it on the ammeter. The system is based around an arduino with ethernet shield which acts as an MQTT client, this subscribes to the downstream bandwidth topic on my MQTT broker, receives the messages and changes the level of a PWM output pin on the arduino which causes the meter to show the appropriate level. The meter displays the current through a resistor which is varied by the PWM signal from the arduino. The reading on the meter corresponds to the current internet speed usage as a percentage of the overall theoretical available bandwidth.

Read more ▼

MQTT, Mosquitto and PHP

As mentioned in my previous post I use a sheevaplug as a LAMP server and also run the MQTT server Mosquitto. In this post I shall not detail the finer points of MQTT and pub sub messaging, they are well described in this presentation by @andysc if you’re not familiar. I intend to cover the more obscure topic of using PHP to write a simple MQTT client which can both publish and subscribe, getting input from an arduino into PHP and subsequently publishing it to Pachube. Currently I use MQTT to monitor temperature, bandwidth usage and cpu usage however this is set to expand in the future.

PHP and MQTT

Currently the majority of MQTT users seem to use clients written in Perl, which is fine for those over a certain age where Perl is common knowledge, but when standing next to some more recent scripting languages like PHP and python it’s a bit archaic! Conveniently IBM have provided the SAM PHP library which includes the capabilities to send and receive MQTT messages and is quite simple to use both from the CLI or as part of a web application. However it includes support for other IBM protocols which isn’t required for basic MQTT communication so the complicated compilation and installation is not really required here, just the php files, thus the folder can be placed in the same folder as the project using it and included with a standard php include:

require('<PHP-SAM folder name>/php_sam.php');

Read more ▼

Sheevaplug – An ideal home server

The sheevaplug, a marvel development platform based on a 1.2GHz has risen out of obscurity in recent times as a silent, very low power computer. It’s uses have been stretched way beyond the intended use into cars and even as a full on desktop computer, despite it’s lack of connectivity.

The basic hardware consists of:

  • Marvell Kirkwood 6281 CPU at 1.2 GHz with 256 KB L2 cache
  • 512 MB RAM
  • 512 MB flash
  • Gigabit Ethernet
  • 1x USB and 1x SD
  • mini-USB with serial console and JTAG

The system is fanless and there are no moving parts, so it is silent apart from a strange extremely high pitched ringing sound which is on the edge of being audible.

In this post I’m going to describe what made me choose the sheevaplug, what I have added to default system and why I love the sheevaplug.

Read more ▼

Receiving TI ez430 Chronos Button Presses in Processing (and Python)

Another currently badly documented feature of the chronos is the facility to get button presses from the watch when in Powerpoint (PPT) mode, so again after a code example from Sean Brewer (available below) I’ve produced a processing version.

The process of acquiring the data, the same request string is sent however in PPT mode the return is different, the third byte determining which button has been pressed in the case of my watch the buttons return the values below:
Read more ▼

Graphing ti ez430 Chronos watch data in Processing

Thanks to a helpful comment on my previous post Graphing ti ez430 Chronos watch data in Linux Sean Brewer posted the help I’d been looking for to get the chronos working with processing.

Following on from the sample code posted by Sean (pastebin or my mirror) I have made the code into a more conventional processing style and added simple graphing functionality in processing to allow the simultaneous graphing of xyz data and my updated code can be found below.
Read more ▼

Graphing ti ez430 Chronos watch data in Linux

Recently my Texas Instruments ez430 Chronos watch arrived, I preordered it the day I read about it on engadget back in November 2009, so it was nice to receive it after all this time. As a dedicated Linux user I found it disappointing that there was little in the way of Linux support provided by TI, however this was not unexpected and a linux application is currently being developed, although progress seems to be somewhat slow. However in the last week breakthroughs have been made, uguryildiz in a post on the TI forum revealed the protocol used to request data from the acceleration sensors and also for setting of the time allowing custom applications to be built using this data on Linux or any other operating system able to use usb serial.

Read more ▼

Using a webcam with OpenCV to display video on an LED Matrix controlled by arduino

Recently I’ve been looking for new things to do with my LED Matrix shield I made for arduino and as I have some experience with writing video caputure systems I thought I’d have a go at trying to capture webcam video frames and processing them and  then displaying them in real time on an 8×8 LED Matrix. Previously as part of my masters thesis I had worked with OpenCV which, amongst many other image processing and computer vision features, provides simple, cross platform video capture capability so this formed the starting point of my experiments.

In this post I will describe a method for the capture of video frames from a webcam using OpenCV, the subsequent processing required to convert to an 8×8 monochrome image and the process of sending the data via serial to arduino using libserial which is linux specific. Example source code is included at the end.

Having previously used a Logitech Quickcam Fusion with windows and OpenCV I started out on this project assuming it would work in linux, however the camera isn’t fully supported by Linux due to the specific chipset used so I replaced my webcam and found the Microsoft Lifecam Cinema Webcam to be fully linux compatible and the highest quality webcam currently available at a sensible price (currently ~£45 on Amazon) and has proved to work very well in all respects producing very high quality images (for a webcam).


Read more ▼