April 28, 2015
by Thijs Elenbaas
0 comments

Arduino to PC messaging – AutoConnect, Bluetooth, Visual Basic and more

Introduction

Biggest news first: The CmdMessenger development was joined by Valeriy Kucherenko. He has really improved development speed of the library and many of the changes and additions in this version CmdMessenger came from him.

Downloading and installation

The package can still be downloaded as a zipped package, but I’ve also made it available through the Arduino and PlatformIO package management system, which will make it easier to get up and running. Although, honestly, my feeling is that neither solution is ideal yet:

PlatformIO
Pro

  • Supports dependency management
  • Rich package format (such as inclusion & exclusion of  files).Con

Con

  • Not for Arduino beginners: There is no GUI,  installation involves getting a Python installation , setting up the environment, etc.
  • Package versions are not taken into account in dependency  management, which is really important to make sure that packages don’t break

Arduino Library Management
Pro

  • Integrated in Arduino UI, very easy for the end user
  • Rich package format (such as inclusion & exclusion of  files).Con

Con

  • No dependency management. At all.  I think this is a really bad idea. Without dependency management it is impossible to build upon existing libraries.
  • Package submission is a fully manual process, and there is no way to check if the library package is composed correctly.

The different ways of how to install the library can be found here

Code improvements

Probably the least exciting improvement, but also one of the most important is the extend to which CmdMessenger has been refactored. We have made huge improvements on the .NET CmdMessenger library. The previous version of the .NET library relied on polling for new data to be available, which resulted in a trade-off between system load and responsiveness, that was never really satisfying. This update uses inter-thread signalling which is faster,  less resource hungry and is much more elegant. A range of other  improvements where made as well: improved thread safety, separation of concerns and more.  Fun fact: The code has been running 24/7 on a test system without issues. In fact,  this system was a Linux + Mono setup. This brings us to the next point:

Linux compatibility

While we stated in the previous releases that the .NET library was MONO compatible and therefore *SHOULD* run on Linux, this  had not been tested. Now Valeriy did! One thing to note is that under Mono on Linux GetPortNames() will never show Arduino ports, so we added our own implementation.

Visual Basic samples

It was always possible to use the CmdMessenger library in Visual Basic. However, being no Visual Basic user myself (and, honestly, not a very big fan of the language), I’ve never  added examples.  However, I have been asked a lot of question on how to use CmdMessenger in Visual Basic, so on a rainy evening I decided to bite the bullet and translate all examples to Visual Basic. So, after combining the result of 2 automatic C#-to-VB  translators, following ReSharper suggestions and some of manual refactoring,  we now have VB versions of all samples:

 

AutoConnect & Watchdog

The Library now comes with an connection manager that you could use: It will scan all serial ports present (in the case of a serial connection), and try them at different speeds. If a serial port responds with the correct answer, the connection is confirmed.

Once the connection is confirmed, a watchdog can be started to monitor the connection. If the connection is silent for too long, the watchdog will ask the connected device for a sign of life. If no response comes, the connection manager will eventually take over and start scanning again. All This makes it very easy to set up and maintain connections.

Bluetooth

We have added a transport layer for Bluetooth, and tested expensively with the commonly used HC-05 and HC-06 breakout boards. The already existing serial interface will also work with these boards: if you set them up correctly (bind, enable virtual serial port), you can use the serial port to communicate.

We have gone a step further, though. By using the underlying RFCOM layer, the Bluetooth layer will not need an virtual serial connection and will immediately run on the correct speed, without overhead. Also, it allows for much nicer auto-connect behavior:  Your Bluetooth device needs only be in range. The auto-connect code with search for both paired and unpaired devices. If unpaired, it will try the most commonly PIN codes to pair, and subsequently to connect.

The only thing you would have to do is connect your Arduino correctly to the HC-05/06 device, and make sure that the serial speed set in your script is the same as the speed set in your Bluetooth device (by default 9600, but this can be changed through the AT commands).

Arduino HC 05 connection Arduino to PC messaging    AutoConnect, Bluetooth, Visual Basic and more image

Arduino HC-05 connection

If you want, you can do more: have a look at this instructables manual and this very helpful guide . If you want to go in depth, have a look at the full AT command set here

Bluetooth Auto connect is very similar to the serial connection auto-connect functionality:

New and updated samples

This version comes with some new & improved samples:

SimpleWatchdog
This example shows how to automatically find the correct serial-port and -speed, and monitor is the connection remains up.

SimpleBluetooth
This example shows all about discovering Bluetooth devices, pairing and connecting to them, as well as the watchdog functionality. Unfortunately this sample does not work with Bluetooth 4.0 (BLE) or under Linux.

Temperature control
The most extensive sample that came with the library was only usable for a limited number of users: only users with a relay switched heater, a thermocouple and a heatable basin where able to use it. We now added a simulated heater, which behaves as a real basin including heater and temperature measuring device. This is very nice  if you like to play around with a remote controllable, PID regulated, heating solution without the hardware.

Serial messaging between Arduino and PC

May 17, 2014
by Thijs Elenbaas
4 Comments

Arduino to PC messaging – improved speed, compatibility and testing

Introduction

In my ongoing quest to make CmdMessenger the best PC to Arduino communication library, I have released a new version with some significant updates. This article will give an overview of these changes: the speed optimization for the fast ARM based boards, better compatibility in data formats between the PC and Arduino, and a unit testing framework.

Continue Reading →

January 30, 2014
by Thijs Elenbaas
0 comments

Webvidcoder – making video work in every browser and on every device

Introduction

Like me, when you’re browsing the internet, you must have seen that showing movies on the internet is commonplace. That are very few internet users that have not stumbled upon Youtube. You will also notice many smaller sites and blogs that embedded movies in their webpages.

One of the reason for this ubiquity is the HTML5 standard. Before HTML5, there was no standard manner in which to show movies in your webpages. You could embed a third-party player such as QuickTime, RealPlayer, or a player made in Flash. But while this works nicely for the browsers that support these plugins, there where many just as many browsers that would not show your movie. Then came HTML5.

Continue Reading →

November 28, 2013
by Thijs Elenbaas
29 Comments

Arduino to PC messaging – More devices, protocols, speeds

Introduction

A few months ago I made a BIG update to the existing CmdMessenger library. My aim was to make it into a full-featured communication library as well as adding a PC based C# counterpart. I got a lot of positive reactions and mails. In fact, a few of these mails came from a start-up that is considering to use it in a product. So thank you all!

I also got a lot of questions about existing and non-existing functionality. Looking back, the theme seems to be: more devices, more communication protocols (USB, WiFi, Bluetooth, ZigBee), etc) and more speeds.

Continue Reading →

Serial messaging between Arduino and PC

September 7, 2013
by Thijs Elenbaas
63 Comments

Arduino-to-PC messaging

Introduction

In our office, drinking espresso has become something of a science. We have tried many kinds of beans, mills, and even de-mineralized  and custom re-mineralized water. The obvious next step is to modify our  Gaggia Classic espresso machine for better temperature control. As a start I first want to measure and control the temperature of a water cooker using a thermocouple, and log the temperature to my PC. The next step would be to use this nice PID library (the articles describing it are extremely good, and even interesting if you just want to learn about PID control in general).

Since the serial-over-USB connection is the de-facto connection to the Arduino, I had expected to find a messaging protocol over the serial port without any issue. This turned out to be more difficult than I had expected. On the Interfacing with software page on the Arduino Playground,  I found two mature, open and well maintained libraries, Bitlash and Firmata, which seemed to be promising at first. However, they turned out to be not quite what I was looking for: both libraries are designed to place all Arduino control at the PC side and make the Arduino into a IO component. All processing would then happen on the PC side (for example in the Processing environment), instead of on the Arduino processor. In our case the end goal is that the Arduino works stand-alone to control the temperature, without needing an outside connection.

Continue Reading →

April 9, 2013
by Thijs Elenbaas
0 comments

Analyzing and optimizing performance of a WordPress website

Some time ago I noticed that this blog loaded very slowly. the problem is clearly not the huge number of visitors, so I decided to contact my hosting provider, Versio. They promptly responded responded that the server would be upgraded in the next week, which would ensure much better performance.

Let’s have a look… Continue Reading →

March 17, 2013
by Thijs Elenbaas
54 Comments

Installing an Eye-fi server on a Synology NAS

Introduction

For a long time I have not had much interest in taking photos, until we had two kid,  who by strange coincidence turned out to be  the most photogenic children ever. The great thing about digital photos is that it is incredibly easy to make them. The bad thing is that is almost just as easy to lose them. A crashed hard disk, a 8 Gbyte, 1000+ photos containing SD card getting lost, etc.. Meanwhile, my analog physical photos are still somewhere down in the closet, perhaps getting a little bit more yellow (instagrammed) with time.

It seems that that long term survival for analog photos is an analog state (gradual degradation ), whereas survival for digital photos is a digital state. either they are bit perfect or they are corrupted. Off course, the degradation of the storage material is gradual, but at some point, the number of read errors will beyond the error-correcting capabilities of the DVD. When it comes to optical discs, there are not many on the market that can be trusted for long-term storage. In a thorough long-term stress test by the well regarded German c’t magazine (c’t 16/2008, pages 116-123), only one DVD type was found that would survive for 20 years and longer. According to the test, the Verbatim Gold Archival DVD-R had a minimum durability of 18 years and an average durability of 32 to 127 years (at 25C, 50% humidity). No other disc came anywhere close to these values, the second best DVD-R had a minimum durability of only 5 years. Of course, the test did not take 18 years. Instead, the DVDs where subjected to extreme conditions, and from these real lifetimes where extrapolated.

DVDlivetime Installing an Eye fi server on a Synology NAS image

Lifetime DVD-r under humid and hot conditions

However, keeping lots of data backed up on DVDs requires a lot of work. In order to preserve our family photos, as well as our free time we have acquired a NAS, a Synology DiskStation412+. The Synology DiskStation comes with a lot of cool extensions to begin with, for example the Photo Station+. It is a photo server, that comes with clients for IOS and Android. We use these to automatically upload all new photos directly to the NAS.

But there is so much more we can do…

Continue Reading →

headerXBMC

February 20, 2013
by Thijs Elenbaas
0 comments

Improved XBMC remote control

Like many others, I have set up a home cinema configuration that uses a NAS for storage and XBMC as a front-end. I am quite partial to XBMC. If you are not using XBMC, you might like to give it a try!

XBMC is running on all kinds of hardware, from PC’s to rooted Ipads and Iphones to the 35 dollar Raspberry PI. I’m running it on a Mac mini. This work quite OK but, as always, there are few loose ends.

Continue Reading →

July 22, 2012
by Thijs Elenbaas
90 Comments

Extended EEPROM library for Arduino

For my ongoing clock project, I want to persistently store some data. That is, store data that is retained after turning off the Arduino. The processor on the Arduino board comes with on-board EEPROM. In the case of the Arduino Uno, the processor is the Atmega328, equipped with 1 glorious KByte of EEPROM memory.

The AVR libraries that come with the ATmega implements a relatively broad set of functions for reading, writing and management of the EEPROM (for a description see the AVR user manual). However, the Arduino standard EEPROM library exposes only functionality for reading and writing a single byte, as described here.
Continue Reading →