Hornsea Radio Rally

When I was a lot (and I mean a lot younger) Radio Rallies were a big thing. Lots of fascinating components and bits and pieces for sale. You could watch the progress of half-finished projects as they moved from one person’s “Bring and Buy” stall to another over the years. This was in the days when talking to someone a long way a way (perhaps even abroad) was not a thing that anyone did because it was either too expensive or impossible.

Nowadays, with the internet and Skype making the planet a tiny, tiny, thing, the lure of long distance ham radio has diminished a bit. But there are still people doing it, and I bumped into a bunch of them at the Hornsea Amateur Radio Rally today. The event was held at the lovely Hornsea Floral Hall and things were pretty much as I remembered. There was stuff that people had brought out of their sheds to see if anyone was interested, along with a few component suppliers. And even a lot of valves.

It was great. I vowed only to spend cash and keep all my bank cards safely tucked away in number one wife’s handbag. So I only spent fifteen quid. I got a programmable led badge that I think I can connect to a Raspberry Pi, some tools, a UV torch for playing with fluorescent printed objects and a few other bits and bobs. Great fun.

Creating 3D Printed Text Masks

I’ve been refining my light printing technology, based on the “Do it for Josh” light (which is still available by the way). The first version used a printed mask and transparent letter inserts that were stuck inside it. It worked OK but it was a pain to assemble and the letter inserts kept falling out.

So I’ve designed a new version in which the letters and the masks are all printed in one. The clever (I think) bit is that I print the first few layers using transparent filament and then switch to solid during the print. I quite like the effect, and it means that I don’t have to assemble anything.

If you’ve got a 3D printer you might like to experiment with changing filament during the printing process, most printer firmwares have an option to do this and you can get some quite nice effects.

This blog post is not about cucumbers

I keep getting these emails from people expressing their admiration of some of my blog posts. Which is rather nice. However, these uplifting messages are invariably accompanied by a request to put a paid piece on my blog about some service that they are offering.

Today things just got silly. A while back I did a blog post about a visit from Phil and Stuart who worked for the BBC and did a lovely session about how they transcode all the video content for the iPlayer video on demand service. In the post I described how they used a language called “Cucumber” to manage requirements and testing.

And this week I got an email from “Emily Bean” who apparently really enjoyed my post and would like to suggest that I include a link to her resource on growing cucumbers from seeds… It’s a nice enough resource, but I’ve not added the link because I’m not totally sure that Emily did really read my post. It’s almost as if someone (or some robot) is just trawling the interwebs looking for particular words (in this case cucumber) and then sending unsolicited emails to people hosting the sites.

Ugh. And to make matters worse, I’ll probably get another email from “Emily” in a week or so saying how much she liked this post….

Four hours of sheep rustling

A while ago I write a review of the Wallace and Gromit Fleeced game. In it I mentioned that some people were complaining that the game could go on forever with no winners because everyone just spent all their time rustling sheep from each rather than trying to win.

Well, that’s what we did last night. For four and a half hours.

Great fun though, and we did get a winner in the end….

Hull Fair

Hull Fair is huge. They say it’s the biggest fair travelling fair in Europe. It’s when all the travelling fairs from all over the country get together to have one last bash before winter. People come from all over to see it and go on the massive rides that they have.

Me, I just go on the Ferris wheel and try to take some pictures. In the olden days the wheel used to tower over the fairground. Nowadays it looks a bit lost in the corner, surrounded by a whole bunch of huge machines.

We went on Tuesday and arrived just as the sun was setting. It was a beautiful evening and I’m not sure that my pictures do it justice, but it was fun taking them.

If you’re in Hull you would be crackers not to go along and take a look.

Starting with the Azure IoT DevKit

Today I thought I’d have a proper play with the Azure IoT Devkit. There’s a ton of content out there about getting started. It’s actually quite simple to follow. In it’s simplest form you just follow the instructions here, but since the device has a proper security chip I though I’d veer off and see about using the Azure IOT device provisioning service and an X-500 certificate to create a very secure device. It’s another of the built-in examples that are provisioned when you add the Azure IoT Workbench to Visual Studio Code.

Rather pleasingly, I got it working. I’m now looking at making the device into an air quality sensor, just as soon as I can figure out how to get the serial port on the IoT board working.

There’s also an example where you can speak to the board in english and have it display the translation in a language of your choice. Great fun.

Programming books for kids

I was in the lovely Little Bookshop in Leeds today and I noticed that they had a display filled with books about engineering and coding for kids. Lovely stuff. I’ve bought a couple of books from the shop, and I thought I’d mention them in ye olde blogge.

I’ve put these in the blog post as Amazon items because I’m lazy and its easy to do (which is, in a nutshell why I use Amazon) but what I really want to you to do is go to Leeds, visit the bookshop and buy them there. There’s something really nice about browsing through interesting books in a pleasant environment (and they do great coffee and their Rocky Road cake is fantastic).

This is a beautifully presented book and makes lots of really good points about the what software development really is.

For my money it would have benefited slightly from a bit more detail about some of the topics covered, and a bit more programming context for each, but is a very pleasant read and as useful for grown-ups as it is for kids.

 

This is another beautifully presented book, but in this one the focus is on writing code. The text uses the tried and trusted technique of creating interesting applications and learning about code as you do that.

It’s done very well, there’s great use of colour and layout to explain what the various code elements do.

The programs as presented are great fun and could be the basis of even more interesting bits of code. It would be great to see a follow on text that built on what was described here.

 

Both of these books complement each other well and are pocket money priced (at least I think they are). They would make great additions to the bookshelf of any kid (or adult) that wanted to dip their toes into coding or at least know a bit about what it is that computers actually do.

Slave to Fitness

It turns out that I really want my watch to have a high opinion of me. I’m slave to a piece of program code somewhere deep in side the software that goes:

if(exercise_value>30)
printf(“Well done Rob”);

It’s reached the point that when I do a job where I can’t really wear the watch (for example painting a summerhouse with horrible, gloopy paint that goes everywhere) I get rather resentful of the way that that this piece of code moans at me:

if(exercise_value<10)
printf(“Try harder next time”);

Oh well.

Stocktaking

At the hardware group on Thursday, when we were talking about hardware for new members. We have a kit of parts that we make available for those who want to have a play with Arduinos and I realised that I had absolutely no idea how many devices I had in stock. So on Friday I spent a while going through all my little boxes from China and counting devices.

I then thought it might be a good idea to label some boxes for all the various bits and pieces. I thought I could use a whiteboard maker to write the stock levels on the printed labels. When I use something I can then just rub off the number and write another one. You can trace the evolution of the labelling process above through:

  • Using these printed labels with big letters is fun

  • I’d better switch to smaller text, running out of labelling tape

  • Ah. No labelling tape left. Let’s just write letters on insulating tape…….

Windows 10 October Update

I installed the latest Windows 10 update over Wednesday night on two machines at the same time. I was quite amused to see my lowly Surface Go upgrade in around same time as my proper desktop. The Surface Go is really growing on me.

The installation just worked. On Thursday morning I had the new system running. I’ve not noticed much different to be honest. The biggest change for me so far is that the Snipping Tool is being phased out. This has been a mainstay of my workflow for a very long time. One of the first things I used to do after installing Windows was put a shortcut to the Snipping Tool on the task bar. It was very good at capturing the entire contents of windows. It did have its foibles though. One of the most annoying was that when you drew with a white pen on a white background the pen disappeared. I’ve wondered for a long time why this has not been fixed.

I’m talking about the Snipping Tool in the past tense because I’ve switched to the new replacement, the Snip & Sketch tool. It seems to do all the things that the Snipping Tool does. I even used it to capture the image at the top of this post. It also sets the cursor colour correctly when drawing, which is a step forwards.

I’ve not noticed any huge changes in Windows 10 so far. But I’m looking forward to doing some more exploring.

Connexin Live

I can’t help thinking that HullOS has a much better ring to it…

A couple of weeks ago I was at the Hull Arena marvelling at how Hull could put on such a fantastic digital awards ceremony. Today I’m at the same place marvelling at how Hull can host a splendid technical event. One of of the first thing the delegates were told about Connexin was that they are a Hull company. Born and bred. And proud to be here.

Connexin are a local company with global plans and big hitting partners in the form of Cisco. A Cisco person had even flown all the way from San Francisco to speak at the event. The theme was something very dear to my heart; Smart Cities. We heard from Hull City Council and Hull University about their ideas for the future and from folks from Newcastle about what they had been up to.

These are challenging and exciting times for local government. Challenging because budgets are being squeezed as never before, and exciting because technology is showing real potential for improving the lives of the people that the councils serve.

It was great to hear all these inspiring plans being laid in Hull. I couldn’t stay to the end unfortunately, I had to go and see how the Hardware Group at c4di was getting on. The answer, by the way, is very well. We’ve got three new members who’ve turned up and want to have a go with the Arduino. I’m putting together some kits for them for the next meeting. You can come along and have a go too if you like. The next meeting is on the 11th of October at c4di, starting at 6:00 pm.

Hot Fingers

I’ve been doing a lot of 3D printing lately. What with josh lights and everything. Today I thought I’d replace the print nozzle on Una, my 3D printer. Turned out that hardest part of the process was finding the replacements that I’d rather sensibly bought a while back. I looked where they should have been and didn’t find them. This triggered a huge hunt all over the house, loft and garage. All to no avail. So in the end I resorted to going tack to where they should have been and used the ancient old trick of looking properly. And of course they were there, tucked in the bottom of the drawer. Idiot me. But, on the bright side I now know where lots of things are that aren’t 3D printer nozzles.

Replacing the nozzle on a 3D printer is made much more exciting that it might be by the way that you have to do it when the print head has been heated to 200 degrees centigrade. Fortunately I’ve done this before, and consequently no longer have any nerves in my fingers so, in no time at all, the old head was off and the new head on. I think the prints look better, which is a good thing.

MQTT topic management conundrums

Well, this sounds like a gripping title for a post eh?

But actually for me it’s a thing. I’m getting my head around MQTT as a way of sending data from our air quality sensors to the systems that want to work on the data. MQTT is a “publish and subscribe” transport. An MQTT node can send messages to a particular address managed by sn MQTT broker process running on a machine somewhere. Other processes can subscribe to that address on the broker and, when the mode sends a packet of data (string of bytes) to the that address the broker will then send that message to everyone who has subscribed to that address.

Make sense? OK, think of it as a mailing list for a pop star, perhaps David Essex. Anyone interested in what David is up to can subscribe to the mailing list, which has a particular name. David’s publicist, who produces the content describing the amazing life that I’m sure David has, (other pop stars are available for this exercise) connects to the mailing list as a publisher, and sends messages which are then sent out to all the subscribers. So MQTT Is basically a fan mail management system.

The address expressing the a particular endpoint is called a topic. Topics are hierarchical. So, an air quality sensor could send a messages to the following topics with the respective data items from that sensor:

Sensor01/temp
Sensor01/pressure
Sensor01/humidity

Alternatively, an air quality sensor could send a single message containing all three values, encoded as a lump of JSON (JavaScript Object Notation) to a single endpoint:

Sensor01/data

Which is better? I’m not sure. Object Oriented Rob says that having all the related items in a single cohesive object which can also contain things like timestamp and location information will make it much easier to process. Free Wheeling Rob says that having individual data on separate topics makes it possible to handle data produced at different rates by different sensors, and also makes it easier for something only interested in temperature (a fan perhaps) to just subscribe to that data item. And both Robs need to remember that the broker is just that, a broker. It doesn’t have any bearing on what will happen to the values that are passed through it from a device to a process that is doing something with it.

As usual, when faced with a problem like this, I’ve gone a bit meta. To me the important thing is probably not which particular way the values are configured for a given application, but that it should be easy to change this configuration during the lifetime of a node. To this end I’m working on a little protocol which will let a node advertise the readings that it has available and then be told which readings to be sent where. Once a node has been told where to send its data it will do that until told otherwise. This means that we can change how we use the sensors so that we could use either of the above approaches.

The good news is that this will be wonderful. The bad news is that I’ve got to do it. Oh well. Today I got a Python program talking to MQTT. The next step is to get JSON working on the Arduino so our systems can start exchanging configuration information.

Talking MQTT

Ha! Today has been a good day. I’ve got my Air Quality sensor talking MQTT to the Connected Humber server and sending messages. This has been a bit of an adventure, mainly because I had to mess around with the libraries for the Heltec device that I’m using.

Anyhoo, I’m now sending messages over both LoRa and MQTT at the same time. Go me. Now I just need to add some configuration options and I think we might actually have a product here.

Incidentally, I’m using a Windows app called MQTTBox to view the messages on the server and post test messages to my sensor. Works rather nicely. And free.

Pointers to Functions in C# and Python

After the description of pointers to functions in C it occurred to me that you might like to know how to do function pointers in other languages. Then again you might not, in which case just look at the picture above that I took in Singapore a while back.

Pointers to methods in C#

If you want to make a reference to a function in C# you need to create a delegate type which contains the reference. Instances of the delegate type can then be made to refer to methods. It’s a bit more long-winded than the C way of doing things, but delegates can also be used as the basis of some quite powerful publish and subscribe mechanisms which I might mention later.

class Program
{
delegate void SimpleDelegate();
static void aMethod()
{
Console.WriteLine("Hello from a method");
}
static void Main(string[] args)
{
SimpleDelegate myDelegateInstance = aMethod;
myDelegateInstance();
}
}

This is a tiny example of a program that uses a delegate to make a reference to a method. The delegate type that I’ve created is called SimpleDelegate. Variables of this type (I made one called myDelegateInstance) can be made to refer to a a method and then called.

If you compare this with the C syntax, it’s not that different. The good news is that before the program runs the compiler can make sure a program will never call a method incorrectly using a delegate. Because SimpleDelegate is declared as returning void (i.e. nothing) and accepting no parameters it is impossible to make instances of SimpleDelegate refer to a method that returns a different type or has a different set of parameters. If you worry about these kind of things, this is a good thing.

Pointers to Functions in Python

If you want to make a pointer to a function in Python you just do it:

def a_function():
print("Hello from a function")

function_ref = a_function
function_ref()

The variable function_ref is made to refer to the function a_function and the function_ref variable can then be called as a function. Later in the program function_ref might store an integer, or string, or a reference to an object of type Cheese. That’s how Python is. This means that a Python program can fail in ways that a C# program won’t, because the errors that cause the Python program to fail would be picked up by the C# compiler.

This nicely encapsulates the difference between the cultures of C# and Python. C# is great because it forces you to invest effort to make sure that the objects in your programs can only ever be fitted together correctly. Python takes everything on trust. It lets the programmer just get on with expressing the actions to be performed and assumes that things will turn out OK. If they don’t the program will fail at runtime.

I love the way that C# forces me to think about my code, and I love the way that Python just lets me get on with writing, without me having to worry about adding lots of extra syntax to express what I know I want. You should know about both ways of working.

Crazy Rich Asians

Now, don’t spread this around, but I quite like a good Romantic Comedy every now and then. If you all you go to is superhero films you get a bit tired of great slabs of exposition about “Shifting into the Quantum Space and causing the end of the universe” in between huge, choreographed fight sequences. And occasionally it’s nice to see a film in which the none of the laws of physics are broken.

Crazy Rich Asians is about a bunch of people, most of whom are crazy rich. It has all the required rom-com ingredients and it mixes them together really well. For me the biggest star is Singapore, which looks awesome. I was lucky enough to go there a few years back and now I want to go all over again.

If you like a good comedy which is well played and (not really a plot spoiler) a nicely realised happy ending then it is well worth the trip. The exuberance of the cast and the flair of the production are really uplifting. Great fun.

Pointers to Functions in C

I’m re-writing my neopixel animation software for the new light. I’m using a C feature that is sometimes very useful. I’m using pointers to functions.

Note that this is quite strong magic. If you don’t use it properly your program will just stop with no errors or warnings. But then again, that’s pretty much how it is when you write Arduino code anyway, so feel free to have a go. You won’t break any hardware.

The reason why I’m using function pointers is that I want to make the program to select between different animations to control the lights. The update behaviour for each animation is a different function. For example, I’ve got two different displays, one which walks colours around the lights and one which just displays the text in a particular colour. That means I’ve got two update functions:

void update_coloured_message()
{
// update the coloured message
}

void update_text_message()
{
// update the text message
}

Each of these is a function that accepts no parameters and does not return a result. I can create a C variable that can refer to these methods as follows

void (*animation_update) ();

This rather convoluted syntax creates a variable called animation_update that can refer to methods that accept no parameters and don’t return a value. I can make this variable refer to one of my update methods by using a simple assignment:

animation_update = update_text_message;

Note that normally when you want to create a reference to a value in C or C++ you need to put an ampersand (&) in front of the thing you are getting a pointer to. In the case of function references you can leave this out. This is either a neat trick to make C programming easier or a nasty trick to make C programming more confusing. I’ll let you decide.

Anyhoo, once I’ve set animation_update to refer to a function I can call the pointer just as I would the function:

animation_update();

I’ve actually gone one more, in that I’m using function pointers in a structure. Go me. I’ve got a structure that describes an animation in terms of the function that sets up the animation, the function that updates the animation and the number of frames it should run for:

struct Animation_item
{
void(*animation_setup) ();
void(*animation_update)();
int duration;
};

I then create an array of these items that contain all the animations that I want to move between:

struct Animation_item animations[] = {
{ setup_coloured_message, update_coloured_message, 600 },
{setup_walking_colours, update_walking_colours, 600} };

Then just need to count around the array to move between animations.

animations[animation_number].animation_update();

This statement calls the animation update method for the animation that is selected by the value in animation_number. If I add more animations to the array my program just picks them up automatically with no need to change anything else.