Single Channel Lora

I'm learning more about the Lora network. Lora links tiny, low powered, devices to an application. The devices talk to a Lora "gateway". The idea is that any device can talk to any gateway. Lora networks use different radio channels to pass data, and the node can select any data channel to send any particular message. Nodes usually cycle through the available channels.

A "proper" Lora gateway will listen on 8 channels at the same time. However, my tiny (and cheap) |Lora gateway from Dragino only listens on one channel.  This means that under normal circumstances I only receive one message in 8 on my gateway. Which is a bit of a limitation. 

Fortunately for me there is a way you can restrict a node to only using one channel. I found a forum post here which tells you how to do it. This is not something I'd advise anyone to do, because it is not in the spirit of the way that Lora works by spreading messages round different channels. However, I've made a script (called naughty) which does this, and it works fine. 

The really good news for us is that Hull centre is now served by a proper Lora gateway so if I use my Lora nodes in Hull they just work. 

Achievement Unlocked - got a mini SNES

Last year Nintendo released a miniature version of a game console with a bunch of built in games. And I failed to get one. This year they did the same thing, only this time the console was the awesome Super Nintendo or SNES. And I failed to get one. 

Until now. While I was in Leeds on Saturday I found one at a much smaller price than I was expecting to have to pay, and today I hooked it up to the TV.

It works a treat. There are 20 very solid games inside the tiny box, the picture quality is very good and it really takes me back. If you can get one, it's well worth tracking down. The only downside that I've noticed is that the device doesn't come with a mains power supply, just a micro usb cable that you have to plug into a supply you already have. I used one that is supposed to power a Raspberry Pi and it worked a treat. There are two controllers in the box, which means that you've got two player action right from the start. 

The SNES was based on a fairly low powered 8 bit processor, but it had a really fancy graphics chip (for the time) which had a magical "mode 7" that allowed it to take a flat texture and draw it with perspective. This was great for game playfields and was used  to good effect for the tracks in Super Mariokart. It's interesting to discover that the games are still very playable today. The handling in Mariokart is beautifully balanced and gives you a real feeling of control. 

If you manage to track one of these down I'd strongly advise you to go for it, whether you remember the games or not.

Star Trek Discovery is really, really good

I've liked Star Trek ever since I saw the very first episode on a cranky black and white telly when I was a kid way back in the sixties. For the last few years there's been a "Star Trek" shaped hole in my life that buying the boxed sets hasn't really satisfied. 

I was a bit worried when I heard about the latest incarnation of the franchise, as there were rumours of it being stuck in "development hell" and deadlines for release came and went. 

It turns out they were just working really hard to get things absolutely right. And they have. It is very, very good. A bit darker, with some real moral compromises at its heart, but brilliantly produced and acted, with some cracking story lines.  The first few episodes are mostly OK, with a bunch of Klingon subtitles I could well do without, but by episode 4 it really gets into its stride.

In the UK it's on Netflix, but in the 'states I you have to sign up to a particular CBS streaming service to get to see it. I'm not sure why I'm telling folks this, as if you're into Star Trek you've probably already watched a few episodes and drawn your own conclusions, but if you're late to the party then it's well worth seeking out and seeing. 

Students at c4di

On Wednesday this week we had a bunch of 30 Computer Science students from the University of Hull drop round to have a look at c4di. It was rather nice to see a few familiar faces and to chat about this and that. I was showing off my Pixelbots and one visitor made a rather interesting observation along the lines of "They've not come along much since last year". This is true, mainly because of Begin to Code with Python, which has sucked all the time out of my life for the last few months. 

But, I'm back playing with other things again now, and so expect the Pixelbot pace to pick up in the next few weeks. We've got another "Build a Robot in a Day" planned for December and the laser cut designs are coming along. There are also a few interesting options if we start putting Lora devices on robots. 

It was great see the level of interest that the students were showing. And I think they were rather impressed by the building and the surroundings. What I really want is some form of "Hull based" trajectory for graduates who love the city (who wouldn't) and want to stay in Hull to build a career. I reckon the c4di could play a big part in this.

Quite a few people wanted to find out more about the hardware group. If you fancy coming along you can find out more here

Writing DXF files from Python

I spent a bit of today creating design files for the latest version of the Hull Pixelbot. This version is going to be laser cut from perspex. This should make it much easier to produce large numbers of robots. Of course I'm not using a CAD package to produce the designs. It's a matter of personal pride that the Hull Pixelbot is entirely a software creation, and the designs are actually built by a Python program. 

The 3D printable version of the designs is created by a program running inside the FreeCad drawing program, but for the laser cut version I'm trying something different. I've discovered the ezdxf library that enables you to create dxf files (the ones that can be used to tell the laser cutter what to cut) directly from Python. 

So, after a bit of fiddling around I've got the start of the designs for the top and bottom of the robot.

Properly Broken Device

Last week I wrote about "The Broken Device Dilemma", when something you hardly use breaks. Do you try and fix it, or do you throw it away? Of course, if you're me you try and fix it. It's all about the journey. Right?

Anyhoo, my lovely little Sony audio player failed. The battery refused to accept any charge.  It was as if the cable was broken. Of course, being Sony, it's a special cable, not a standard usb one. The good news is that replacements are very cheap, so I got one. 

It didn't work. 

However, playing with the device left me thinking that the battery was broken. This happens with Lithium Ion batteries. So, it was onto eBay to source a battery. I managed to find one, ordered it and it arrived today. Fitting it was great fun. Number one son found the service manual and I had a happy half hour this evening undoing sticky fixers and soldering the replacement battery in. 

It worked. Yay!

The player woke up and played some music at me. Great stuff. But it did seem to get very warm. And then the WiFi stopped working. And then the battery failed. And now it behaves just like it did at the start of this story. Oh well. It looks like something in the player has failed and is taking so much power that that the charging circuit can't keep up. So I think it is properly broken. 

Oh well. Now I have to ask myself the question "If a device you hardly use breaks, to you replace it?....."

Frogman

Last wee we went to see "Frogman" by Curious Directive. It's an intriguing story told by a combination of theatre and virtual reality. We really wanted to see what the VR stuff looked like, and how it was slotted into the narrative. So off we went.

The answer is that the VR looks pretty good and adds a lot to the experience. The production cleverly avoids the audience having to spend great chunks of time wearing the headsets, and manages the transitions between scenes very well. The one actor in the show does an astonishing job. Tessa Parr plays the part of a scientist studying the Great Barrier Reef who's past comes back to haunt her. And she does it really well.   

I think that one measure of a good story is the amount of discussion it generates on "what was really going on". On that score I reckon that Frogman is a great story. If you get the chance you should go and see this. Absolutely. 

Things Network Frame Counter

I'm getting the hang of Lora networks. And by that I mean "Spending quite a lot of time figuring out why things don't work when they really should".

Today I found out about Frame Counter Checks. Each Lora packet contains a frame counter value. This is set by the node when the packet is sent into the network. The Things Network likes it if the frame counters in packets always get bigger. This makes it slightly more difficult for someone to spoof messages into the network. 

Trouble is, if you're using a very simple node you'll find that the frame counter is reset to zero by the software each time you start the device. Which means that The Things Network will reject packets from the device until it seems a frame counter bigger than the one it's seen so far. 

Unless you know this, you'll spend ages trying to figure out why something that worked yesterday has suddenly failed. 

There's an option for the device settings for your application in the Things Network which turns off Frame Counter checks, which you can see above.

In a proper application you'd either save the frame counter in eeprom each time you've used it, or do something clever with the date and time to generate a frame counter value which is always bigger than the last one. 

Fireworks

We don't usually have fireworks on November the fifth. But this year we did. In the old days we used to buy a box of "Standard" fireworks that contained one dud (which varied from year to year) and a taper thing to light the fireworks that you couldn't actually get lit yourself. The family would spend forty five minutes standing in the garden freezing to death while I tried to light the blue touch paper on a succession of cardboard tubes that I'd stuck in the lawn. Sometimes it would rain.

All the fireworks had different names like "Golden fountain", or "Emerald Shower" but when one eventually lit we'd just just get a shower of sparks followed by nothing. Things were slightly enlivened if the Catherine wheel set fire to fence. And we'd force the kids to hold sparklers which would also fail to light.

Anyhoo, today we didn't do any of that. Instead we bought three little boxes that each contained a bunch of fireworks that were wired together using some cunning fuse technology. We just lit one corner which fizzed merrily and then the box generated a ten second display of quite impressive proportions. I even managed to get some pictures. 

The whole thing was over in about ten minutes and we retired to the warm indoors and had hotdogs. 

Three Thing Game Fun

These are the winners of Three Thing Game November 2017. If you study the picture carefully you'll notice that not one of the people in the picture is me. Oh well.

But quite a few of these folks are First Year students from Hull, which bodes very well for the future of Three Thing Game (and game development in general). They made a lovely sequence of mini-games that chronicled important milestones in the development of Hull. It looked fun to play and had some splendid graphical touches. 

As always, I really enjoyed taking part. My team, as frequently happens,  was probably a bit more ambitious than we should have been, trying to create a networked multi-player game in around six hours. However, we got darned close.

The three things we were asked to base the game around were "Hull", "Culture" and "Change". Our game used the medium of Venn Diagrams (which were invented by John Venn, a mathematician from Hull) to explore Hull Culture. I'm most proud of the moment when the judges asked "Where's the change in your game?" and I replied "It costs fifteen pence to play". 

After that, the discovery that we hadn't won was a real surprise.....

Three Thing Game. Like Old Times

Staying up late. Writing programs to impossible deadlines. Such fun. 

I'm back at Three Thing Game as part of the Spooky Elephant Collective. The organisation is great and the pizza delicious. I managed to stay sentient until around 11:00 pm, which is actually quite impressive for me. The game that we are making celebrates the great things about Hull through the medium of Venn Diagrams. 

Wish us luck. 

Begin to Code with Python goes to print today

I spent a big chunk of yesterday going through the final drafts of "Begin to Code with Python". And today the files will be going off to the printers.

I started work on the book in March, and we now have a 630 page book with over 170 example programs. Thanks to everyone at Pearson and Microsoft Press for letting me write it and being so helpful during the process..

The book will be in the shops at the start of December. The perfect Christmas present. 

Arduino vs One Drive

Some things you just have to learn the hard way. For a while I've been frustrated by the way that my Arduino projects would build fine for a while, and then fail after I had saved them. 

Eventually I worked out that if you're working on a folder which is being shared by One Drive (or DropBox and probably Google Drive) this causes the Adruino SDK to get upset when it tries to build a solution. This must be due to the file sync process causing files to be locked when they shouldn't be.  Move the files to your desktop and the program builds perfectly. 

Of course, the proper way to share a development project between a bunch of machines is to use GitHub, and that's what I'll be doing in the future....

Lora Node Live

Well, I've sent and received my first Lora packet sent from a node into a gateway. It turned out to be quite easy to set up. First you create an application, then you create a device, then you take the key data of the device web page and paste it into your node program. Then it works. 

Now I need to work out how to take the data off the server at the things network and do something with it. 

Great fun.

Super Mario Odyssey. Buy it.

I read a review of Super Mario Odyssey which ended with the phrase "If you've got a Switch, you must buy this game. If you've not got a Switch, buy one and then buy this game".

I agree. It really is that good. Not that I'm anywhere near through it, but I'm enjoying every minute. Everything is polished to perfection. The game runs well on portable and on TV. The idea of having something this good that you can play on the train is really nice. 

When I bought this game I did something I don't usually do with full price games like this. I bought the download version. It meant I could get started without a trip to the shops or waiting for a parcel, and it also means that the game is always present on my device. I've got a micro SD card in my Switch and the game takes up around 5.3G, which is not a huge amount of space by today's standards.  

I'm starting to wish that I'd bought all my other games this way, it would remove the need to carry round cartridges. Perhaps a video game shop could over a scheme where they take your game media back and swap it for a download code.  I'd go for that. 

Learning about Lora

I don't know much about Lora networks. But I know more now that I did this time last week. Which is a good trajectory I suppose. Here are some things I know now.

  1. Lora is low-power, long-range. But very low data rates (just hundreds of bytes a second, if that). 
  2. Lora works. As I write this I've got a tiny Lora node sending lumps of data across Cottingham, where they are being received.
  3. You can get Lora devices for very low prices. I'm paying around 12 pounds for a node with a rather fancy OLED display, but you can get the interface chips for a round a third of that. 
  4. Frequency is important. In the EU you should get devices that work on 868Mhz, in the US go for 915MHz. There's another frequency, 433Mhz that you can use in the EU, but it might not work as well because this frequency is also used by radio amateurs and whatnot. 
  5. If you want to just use Lora to link a few devices that are a long way apart (up to a KM or so) then you can buy devices like mine and just use them. 
  6. Lora nodes in a proper Lora network talk to a gateway device that takes their messages, assembles them into lumps of JSON and sends them over the internet to a central server which makes them available to your application. You can buy gateways, or you can make tiny ones of your own. (That's what I'm trying to do at the moment)
  7. Lora uses a range of radio channels which are grouped around the working frequency of the particular node. A proper gateway implements a bunch of channels (usually 8) and cost at least 150 pounds, but you don't need one of these to start with. A single channel gateway will work fine for up to 50 or so nodes.
  8. You can register your gateway on the things network. This acts as the server in my description and allows other people can find and use it, and also lets your cloud service capture data and send commands to nodes. Commands are sent to nodes after the node has sent a message to the gateway. This saves power (and makes the networking easier) but it does mean that you can't just tell a node something, you have to wait until it reports in and then send a message. The node will listen for a while after it has sent a message. There are versions of Lora that allow messages to be sent to the node at any time, or in designated time slots, but these aren't in common use yet.  
  9. You create applications on the things network. An application is associated with one or more Lora powered nodes which use keys to authenticate their messages. You can bake the key into the node and use activation by personalisation (ABP)  or use over the air authentication (OTAA). OTAA is more secure, but not many devices (and certainly not simple gateways) do this. 
  10. Anyone can hear your Lora transmissions. The Lora standard offers proper end to end encryption but this doesn't seem to be available in devices just yet. 
  11. Andreas Spiess (aka 'The Guy with the Swiss Accent') has made some splendid videos that describe the technology. Great to watch during the lunch hour. 
  12. Lora is a great solution but I'm not completely sure what the problem is. But I'm still going to play with it.