Monthly Archives: February 2016

Dragino-chipKIT-Yun Yum Yum…

Due to WordPress’s abysmal handling of code blocks this blog post is now hosted at

My latest acquisition, the Dragino Yun Shield is actually quite a nice bit of kit. It’s the Linux portion of an Arduino Yun placed on a shield, so you can attach it to any board of your choosing.

It provides both a UART and an SPI connection to whatever it is plugged in to. And that includes chipKIT boards.

For those of you not familiar with the Arduino Yun, it’s a combination MIPS SoC (Atheros) like you get in most home WiFi routers coupled with an Atmel microcontroller (32U4). Personally I always felt it was such a shame that a board as cool as the Yun should be crippled with a piece of Atmel like that. But hey ho. And then the Dragino arrived and all was forgiven. Gone is the Atmel, and in its place is the lovely PIC32MX695F512L on a chipKIT WF32. Or any other chipKIT board of your choice that you should happen to be drooling over at the time. Continue reading


Fixing the Dragino Yun Board

Due to WordPress’s abysmal handling of code blocks this blog post is now hosted at

… and maybe the real Yun too.

So there’s the Arduino Yun. That’s quite a nice concept – an embedded Linux computer (MIPS based, YAY!) and microcontroller combined on one board.  Just such a shame it’s an Atmel microcontroller and not a PIC32.

But then there is the Dragino Yun shield. Just the Linux portion on a shield that you can plug in to your favourite board and make a Frankensteinian monster. Perfect. Coupled with a nice meaty PIC32 it’s the ideal combination.  However, programming the PIC32 is then nigh on impossible, since the serial port gets blocked up.  So you want to program it from the Yun shield if you can. But that means porting pic32prog to Linino, and that has proved to be a bit of a trial.  More on that some other time though.

This is all about what happened whilst I have been attempting to do that porting.

I bricked the Dragino somehow. Continue reading

The Evils of Arduino Strings

Due to WordPress’s abysmal handling of code blocks this blog post is now hosted at

Everyone, when they’re starting out on the Arduino and similar boards, learns to use the String object for working with text. Or they think they do.

Well, you should forget all you think you have learned about using Strings on the Arduino, because it is all wrong.

Strings are a bit of a tricky area on the Arduino. The String object was created to make working with blocks of text easier for people that don’t really know what they are doing when it comes to low level C++ programming. However, if you don’t know what you’re doing when it comes to low level C++ programming then it is very easy to abuse the String object in such a way that it makes everything about your sketch fragile and unstable.

So I’m here to tell you firstly why you shouldn’t use String objects, and secondly, if you really must use them, how you go about using them properly. Continue reading

Making accurate ADC readings on the Arduino

Due to WordPress’s abysmal handling of code blocks this blog post is now hosted at

There are many sensors out there which output a voltage as a function of the supply voltage as their sensed value. Temperature sensors, light sensors, all sorts.

Measuring that voltage, and converting it in to real figures for whatever is being sensed is not actually as simple as you might at first think. Continue reading

The Finite State Machine

Due to WordPress’s abysmal handling of code blocks this blog post is now hosted at

Many of the programming questions on the Arduino forum can be answered with one simple response:

Implement a “Finite State Machine.”

But what actually is a “Finite State Machine”?

Put simply, a Finite State Machine (I’m bored with typing that now, let’s call it an FSM – not to be confused with the Flying Spaghetti Monster, of course) is a computer program that, at any point in time, can be in one of a pre-determined number of states. A state is a specific action, such as “Waiting for button 3 to be pressed”, or “Moving the servo to 69°”, for example.

An FSM can replace most of your while, for and similar loops, as well as annoying functions such as delay which get in the way if you want to do more than one thing at a time. Continue reading

Reading Serial on the Arduino

Due to WordPress’s abysmal handling of code blocks this blog post is now hosted at

I see many many questions on the Arduino forums from people trying to read data from a serial connection and not fully understanding how it works – and hence failing.

So, how should you read from serial?

Well, what a lot of new users don’t realise is that serial data arrives one character at a time, and you have little or no control over just when that data arrives.

The Arduino has a handy function: Serial.available(), which tells you how many characters are in the serial device’s receive buffer. If you know beforehand how many characters you are going to be receiving this can be a very handy and simple way of managing your receiving. However, it has to be done right. Continue reading

New Blog Site

I have decided to ditch the old, ropey, incredibly slow Drupal based blog that I used to have and am now running a WordPress site free of charge thanks to good old WordPress themselves.

Unfortunately it seems I may have inadvertently managed to lose the old site down the back of the sofa.  Still, that means I now get to re-write the good articles that are worth re-writing, and get to completely ignore all the old rubbish that no one wants to read.

So wish me luck with trying to remember just what it was I had been writing in the past…