Storing Json Configuration Information in devices

I’m a big fan of Json. It is a great way of expressing values in a meaningful way. I’m going to use it to store settings information in our Air Quality sensors. This will make it easy to understand, and extensible. It turns out that it is also very easy to do. I started with an online json editor at That helped me come up with this:

  "wifi": [
    {"ssid":"ssid", "password":"pass"},
    {"ssid":"", "password":""},
    {"ssid":"", "password":""},
    {"ssid":"", "password":""},
    {"ssid":"", "password":""}    

The json design provides all the information that a sensor needs, including the WiFi settings for 5 different networks. MQTT connection settings and the limits for my warning displays on the coloured pixel.

Next, I needed the C++ to convert the Json into settings that my code inside the device can use to load and store the values when the device runs. It turns out that the Arduino json library has an awesome web page where you can just paste your json and out drops C++ to read and write the values.

I just went to , dropped my Json design into the pate and out came the code. I’ve got to map the settings values onto the variables I’m using in the program, but that is much easier than writing everything from scratch.

This won’t work with the very small Arduino devices because they haven’t really got enough memory to run such large libraries. However, if you’re using an esp8266 or esp32 this really is an easy way to manage internal settings. I’m going to store the json itself using the internal filestore. I’ll post how to do this in a little while.

Test your hardware before you use it


Here’s a little pro-tip that I could have used yesterday:

Test your hardware before you solder it into your device.

I was using a brand new Wemos device that I just took out of the bag, soldered into place and then fired up. It didn’t work. Closer inspection shows that a wayward surface mount resistor has got underneath another component and as a result the board is useless.

I't’s not a huge loss, I’m only paying 2.50 for my Wemos devices at the moment, but it does mean that I have to un-solder the failed device and solder another in place, which is a bit of a pain. From now on I’m going to test my new device just hanging off a usb connector before actually fitting it. Something I used to do, but seem to have forgotten. Of course, the perfect way to do this would be to test all the devices as soon as they arrive from China, that way I might be able to send back faulty ones.

Oh, and the another thing to hold dear is:

Throw away broken devices. They are never worth keeping.

Once it had its moment of glory under my camera, the failed Wemos went straight into the bin. It looks pretty much perfect in every way, and I guess an expert in surface mount technology could do something with it, but I’m not that person, and I don’t want to confuse it with a working one.

Porchlight 2.0


Well, Porchlight 1.0 fell down sometime last night. But no damage done. I’ve switched to a stronger type of adhesive strip and also wedged the light strip into place. I’ve also made an internal version of the lights so that I can test my displays without having to deploy them on the front of the house, which seems like a good idea to me. Now that I’m a bit happier with the power supply I’ve changed to a version of the code that turns on a lot more lights at once, for extra brightness.

Porchlight 1.0

Porchlight 1.0 is up. I’ve discovered that 16mm cable trunking is perfect for holding lengths of Neopixel leds. So I’ve stuck the lights up over the porch using the adhesive foam on the back of the trunking and we’ll see how it goes. I’m using over the air updating so that I can send new programs into the lights without having to go near them. I’m surprised how well that works.

Fun at Hull Makerspace


I spent a very happy three hours at the Hull Makerspace today. I’d been invited to take a look and have a go with the machinery, so I did both.

They’ve got the two most important ingredients just right. Lots of tech and lovely people to help you use it. The tech includes a really nice laser cutter, complete with proper cooling and ventilation systems, which makes it a dream to operate. I took my Hull Pixelbot design files off Github and they were able to feed them straight into the laser cutter and make the robot chassis that you can see above. This of course prompted design work on another version which will be entirely laser cut, rather than needing some 3d printed components. Not that this is really a problem at the Makerspace, they have a couple of 3d printers to play with as well.

It’s that “being next to the machine” immediacy that makes the Makespace such a nice place to work. Knowing that I can turn round a design really quickly means that I’ll be able to experiment a bit. There are also things around the place I’ve never used before, including CNC machine, a lathe, a band saw and a vinyl cutter. Some of them scare me a bit (which is apparently a good mindset to go in with) but I’m really looking forward to finding out how to use them.

Membership will open in the new year. It will cost 10 pounds a month for students and the unemployed and 20 pounds for everyone else. If you want to use some of the more “expensive to feed” devices like the laser cutter there’ll be an extra charge depending on how much you use them, and you will also have to pay for consumables.

For years I’ve been saying “What Hull needs is a really good Makerspace”. Well, we’ve got one now, so it is up to us folks in the region to show just what we can do with it. You can keep track of what they are up to here.

Christmas Lights Taking Shape


Every year I have a plan to make some Christmas lights using Neopixel leds. This year I’ve actually got as far as buying he leds and a power supply unit. Today I spent a happy half hour wiring everything together and a less happy half hour finding out that if you put a series resistor in the data line to the leds (as you are advised to on the web) they don’t work reliably.

Today’s hard won lesson: it’s not always your software that’s at fault. Sometimes the hardware can go wrong too. Once I’ve got the lights working I’ll post a video on here and the code on GitHub. It’s turning out to be quite fun.

Dropmix Review


I usually buy a game at Christmas. This time I’ve bought Dropmix. I saw it on sale at a very attractive price and could'n’t resist it. For the amount you pay you get a lot. There is a handsome plastic console where you pay the game and a set of 70 cards, each of which contains an RFID tag that is read when you play the game and used to trigger the playback of a sample from a music track. The game runs as an app on your phone or tablet which talks to the console over Bluetooth.

You play the game by laying cards down to build up a song. The cards have a characteristic colour and volume level. Coloured cards must be played on the matching colour of the deck and have a louder or equal volume setting than the card they are being placed on top of. Get stuck and you can press a big button which selects a bunch of cards to be removed.

There is a very wide range of music on offer, including Ed Sheeran among others. You can buy themed packs of 15 to get more sounds but they are rather expensive. The cards are nicely made and have artwork that makes them nice things to have before you even play the game. There are also black and white cards that are played to modify the sound.

I was very impressed by how well the samples knit together to make interesting sounds. There are a variety of play modes, including a single player mode, or you can just put cards down to see what you can make. You can even save arrangements that you’re particularly pleased with.

The game is from Harmonix, the people that made a bunch of guitar games. They really know how to make the music fit together, and the gameplay turns out to be a lot of fun. Well worth a look.

Using the Surface Go for Presentations


I didn’t plan to use my Surface Go for my presentations at the Black Marble Architecture Forum. It’s just that my Azure Function demo worked on the Go, but not on the Surface Pro that I was intending to take to Leeds. Something to do with Visual Studio needing an upgrade. But of course I didn’t have time to do that. So, I headed out to the venue, hoping that someone would have a way to get video out of the single usb c port that the Surface Go is fitted with.

Turns out that they could connect me up. The device above, from Dell, worked wonderfully. I reckon it is a perfect companion to the Go. It gives you three different kinds of video, VGA, DisplayPort and HDMI, along with USB, wired networking and a usb c port pass through. The cable is coiled niftily inside too. I plugged it into the Surface Go, got a solid video signal out into the projector and I was away.

Everything just worked. I had PowerPoint, Visual Studio Community edition and a bunch of browsers I was hopping between. Running up the Azure Function demo in Visual Studio just worked, and at a reasonable speed too. I even managed to use my old Surface Pen to remotely change the slides (although the battery in this is a bit tired, so I had to stay close to the computer).

I’d taken along my venerable old Surface wireless display adaptor that I bought years ago. It also works a treat on the Go but I didn’t need it thanks to the lovely little Dell device.

If you’re thinking of using the Surface Go as your portable presentation machine, just do it.

Talking at the Black Marble Architecture Forum

What a great audience looks like…..

What a great audience looks like…..

Drove to Leeds today to give some sessions at the Black Marble Architecture Forum. All new material. Which is a bit scary to be honest.

Anyhoo, first up I did a session for the student track. This was great fun. I told the story of our work on Air Quality as part of the Connected Humber group. The main thrust of the talk was that you can really can make a difference just by doing stuff. I’ve made a screencast of my talk which you can find here.

The audience gathering before my next talk…

The audience gathering before my next talk…

The second talk was all about the Internet of Things, LoRa and Azure Functions (which are awesome). Another great audience, some great questions at the end. One chap asked about 3D printing and I said I’d put something in the blog about it. My advice, take a good hard look at the Anet Prusia A8. I’ve not got one - my six year old Ultimaker is still doing sterling service for me, but for a fairly low investment this looks like a good one to go for.

I’ve made a screencast about LoRa, I’ll do one about MQTT and another about Azure Functions.

Achievement Unlocked: Got a copy of "Map of the Floating City"


When I used have a Groove Music Pass on my PC (I call those the ‘Good Old Days’) I got very attached to the album “A Map of The Floating City” by Thomas Dolby. When that died (very sad) a while back I ended up switching to Apple Music. Which is actually pretty rubbish in many ways. One of them being that, for some reason, this album is not available. Neither is first track of “The Nightfly”, one of my favourite ever albums. And Apple Music seems incapable of playing tracks in the same order as they are on the record. And some music doesn’t show up in the car. And also…. But I’m starting to rant, so lets move to a new paragraph.

That’s better. Anyhoo, I tried to buy the CD and it is really quite hard to get hold of. I’ve ended up importing a copy from the ‘states. Well, it arrived today and it sounds as good as I remember.

Windows 10 Magic Disk Space

magic space.PNG

Windows 10 is magical. Or something. At the beginning of this week I was worried that I was running out of disk space on my main hard disk. Which can be a problem. Things were turning red. Never a good thing in my experience.

This morning I discovered that I suddenly had a lot more space. Around 30 G bytes had appeared from nowhere. Now, I might have done some “sleep deletion” last night, but I don’t think so. Windows 10 must have found the space for me.

Thanks for that.

Rob at Black Marble Architecture Forum


I’m doing a couple of sessions at the Black Marble Architecture Forum next week. However you can’t get to see both of them unless you are both a student and an industry professional.

Black Marble have this lovely policy of running a one day event for both students and developers, with twin tracks. For the first time they’ve let me loose on the professional track, so I’ll be talking about Azure IOT Hub for them and Air Quality Sensor building for the students. There’s actually a bit of cross over between the two - I’m going to use Azure to store the air quality data. It’s going to be quite fun.

The event is in Leeds on Wednesday next week. I’m not sure if you can still sign up but the event page is here.

Tesla Testing at c4di


Good reason to be part of c4di number 493: Sometimes you get to drive a Tesla

Today was rather exciting. Tesla came to see us. I’m rubbish with names, and I didn’t write them down, but both fellows who turned up from the company were excellent, both in the talk that they gave to set the scene for the day, and also at the moment when they just said “Get in and drive it”.

So I did. I’ve already got an electric car so the smoothness and silence weren’t that much of a novelty. But the fact that I was manoeuvring a three ton car so easily was very impressive, as was the dashboard display of the vehicles around us as I nervously headed towards the A63. You could see little rendered versions of the cars and lorries in real time. This is a spin off of the self-drive technology and gives you a lot more confidence in traffic.

Dee settles in for his turn at the wheel…

Dee settles in for his turn at the wheel…

This being close to rush hour, the road was busy, reducing the opportunities for any attempts to realise the 0 to 60 potential of the car, which is apparently only five seconds or so. Dee had a go after I did, and he was a bit more lead footed than me, making the car really leap forwards. He also remembered to have a go with the automatic driving (which I rather stupidly forgot). This was very impressive. It followed the line of the road and kept the car nicely placed in the queue of stop-start traffic that we encountered on the way back to c4di.

Tesla have only been making cars for a few short years, and they’ve had to invent a lot of the technology that they are using. They have a plan, which is to start off catering for the more expensive end of the market before moving into the mainstream. As a quality car, for me the Tesla does the business. The inside was appropriately posh, comfortable and toy laden. It’s a bit on the large side for me personally, I find that the BMW i3 is just perfect for my needs just now, and I don’t really have the spare cash to spend on a toy that big. But I still rather want one.

And I’m not alone. Apparently they are selling more Teslas in the USA than they do BMW or Mercedes cars. During the talk in the morning we were told that Tesla is really just keen to get people living in a sustainable way. If that means getting other car manufacturers to make their own electric cars to compete with Tesla, they say they are OK with that. Well, all I can say is that the competition has its work cut out.

Big thanks to Tesla and c4di for setting up the day. It was awesome.

Using Serial1 with the Azure IoT Devkit


A while back I posted about changes you could make to the Azure IoT DevKit library so that your programs can use the second serial port of the device to talk to things like GPS receivers and Air Quality sensors (a particular interest of mine).

At the time I suggested that this could be fixed by adding the creation of a second serial port to the SDK. I’ve just heard back from the team and this is not going to be done. Instead we can create a Serial instance when we need one, which saves resources.

If you want to use Serial1 with your Azure IoT device you can add the following statement to your program.

UARTClass Serial1(UART_1);

You can then use Serial1 in exactly the same way as you use Serial. I’ve put a sample program on GitHub that shows how this works.

Haynes Electronic Games Advent Calendar


I got in real trouble a couple of days ago when it was discovered that there still some days from last year’s chocolate advent calendar that I’d not got around eating.

What can I say? I forget stuff.

But this is something quite different and definitely not edible. It’s an advent calendar that starts with a simple circuit that lights a LED and ends up on Christmas Eve with a fully working version of the Simon memory game. Along the way there are some nice little side projects. It’s all made possible by a tiny pre-programmed PIC processor, a breadboard and a bunch of components that make the set not bad value for the price.

The implementation is pretty good, the instructions are fairly clear although I’d liked to have seen proper circuit diagrams as well as the Fritzing pictures that show you where to plug the wires. And, talking of wires, it would have been nice to have had a set of pre-made jumpers of appropriate sizes and colours rather than just a little coil of red wire that will have to be cut and stripped for every circuit. I can see that the effort of making the wires will put off all but the most determined experimenter, and probably also destroy the pair of scissors that are used for the job. At least there is no soldering.

It’s really nice to see things like this coming out though, and I’m going to work through all of the daily exercises while eating each chocolate from my other calendar…