Things Network Version 3 now works!

V3 network.jpg

We had a great Hardware Meetup last night. We were celebrating success with our The Things Network Version 3 devices. Brian and I were in a baffled place, but last week Adam had a go and managed to make it work. It turns out that what you had to do was change the gateway name slightly and off it went. You can read the full story on this forum post here. This is splendid news. Now we can plan a way forward for our various networks and devices.

Debugging a Things Network Kickstarter Lora Gateway

gateway serial connection.jpg

Not sure if anyone reading this blog really needs to know this one, but I need to keep a record of it somewhere and it it is what I’m doing today. If you (or even I) ever want to debug a Things Network Kickstarter gateway you can do this by connecting a seral cable to the jumper inside. I’m using a Raspberry Pi serial connector and with that you connect the white wire (which is the input to the computer running the terminal program) to the RX connection on the pins in the top right hand corner. The black cable goes onto the ground connection. I actually used my SimpleTerrm browser terminal to view the output from the gateway:

gateway debug output.jpg

We’re trying to convert our gateways to Things Network version 3.0, which is proving an interesting experience at the moment.

Buying random numbers

The Connected Humber CIC company has just made a substantial (for the company) investment in meaningless numbers. We’ve bought 150 tiny little memory chips, each of which comes loaded with a unique 32 bit number. We’re going to use the numbers the chips contain as IDs for devices we want to connect to the LoRa network.

The rules are changing in version 3.0 of the Lora wide area network, so that if you want to give your devices unique numbers they are not made for you, you have to get your own. And not just any old unique numbers, they want ones with some provenance. This is fair enough. It is rather important that we don’t have several devices sharing the same ID. When the chips arrive we’ll have to read the numbers out of them for us to use in our devices. Alternatively we could wire the chips in and have the hardware read them.

If we have any left over we can always sell them on to the highest bidder. There seems to be quite a market for meaningless unique numbers at the moment.

LMIC Frame Counter Problem

This is a fairly exotic post, in that I doubt that many readers will be concerned how they can maintain the frame count of LoRa packets sent using the LMIC library when a device goes into deep sleep. However, I’m putting it here so that in six months time, when I probably need to do this again, I can just search the internets and find this article.

A LoRa application maintains a frame count for each connected device. This is a security measure. Any frames that that the application receives with a frame count that is lower than the highest frame count seen so far will be rejected by the application. You can turn off this frame count checking for a device, but it is not advised because it makes things a bit less secure. I’ve turned it off for my devices for now, which meant that the frame count just increases when the device is running and goes back to 0 if the device is reset.

This is kind of OK by me. I’m not overly concerned with security issues at this level. However, when I started using deep sleep mode I found that every frame that was sent had a frame counter of 0, and I really didn’t like that. The problem is caused by the way that the device is completely restarted between each transmission. This restarts the LMIC library each time, setting the frame count to 0 for every frame.

It turns out that a program can reset the LMIC frame count value by accessing a member of the LMIC object. All my program needs to do is create a variable in the RTC memory to hold the current frame count:

RTC_DATA_ATTR u4_t lmicSeqNumber = 0;

The program can then store the frame count in this variable after each LoRa message has been transmitted:

lmicSeqNumber = LMIC.seqnoUp;

Now, during the reset process after a deep sleep I can put the frame count back:

LMIC.seqnoUp = lmicSeqNumber;

I’ve tested this and it seems to work fine. The frame counter is retained when the device goes to sleep. Of course if I turn the device off the frame counter resets back to 0. I could fix this by storing the frame count in EEPROM storage but I’m not too keen on doing this because I’d have to update the value after each LoRa message and might lead to lots of writes which might “wear out” the EEPROM storage.

Using TTN Mapper to show LoRa coverage

I’ve been playing with TTN Mapper. It’s great. There’s an app you can get for your phone (Android or IoS). You configure it with the details of your Things Network application and then you can wander round with a portable LoRa device and help to build a map of coverage.

You don’t have to actually connect your LoRa device to your phone, you just have to enable the mapper program on your phone to connect to your application and then it will detect LoRa packets from the device in that application and use the gateway metadata to help build the coverage map.

I’ve configured one of my Pax counter devices so that I can use it for mapping. Note that you need to be careful to put the sensor name in exactly as it is configured in the application. My iphone keyboard “helpfully” converted one of the characters in the device name to upper case and broke the mapping.

Some of the strings you have to enter are quite long. I opened up the Things Network site on my phone and then copied them out of the browser into the setup page of the application.

You can use a wildcard for the device name but this might get confusing if the mapper starts thinking that messages from distant sensors are actually with you and your iphone. But this would be a good way to work if you make a network with a single LoRa device that you are going to use just for mapping.

I’m going to try and get into the habit of taking the phone and a LoRa device with me whenever I go for a walk.

A Lora Gateway of my own

I’ve been playing with LoRa for a while, and I’ve even got a tiny single channel gateway at my house that mostly works.

But last week Adam loaned me a proper The Things Network LoRa gateway to play with.

It’s awesome.

For a start it has a proper 8 channel receiver. This means that it can receive all the messages. For another thing, it has a proper antenna. The result has been that over the air authentication (which used to be hit or miss) works first time. And I can reliably send messages back to the LoRa device when it checks in.

Suddenly all my sensors are reporting results with rock solid quality of service.

I really hope Adam doesn’t ask for it back in a hurry…

Reviving a Dragino LoRa Gateway

I’m a sucker for “upgrades”. Maybe it’s because I like watching progress bars. I find them rather relaxing, and a great way to avoid doing work.

But upgrades are not always your friend. Take my little LoRa gateway for example. It’s not a “proper” gateway, in that it only has a single channel, but it is fine for testing devices (as long as you are happy for only one in eight packets to get through).

Anyhoo, a while back it broke. So today I tried to fix it. It turns out that I’d actually broken it by upgrading it. The first time it failed I’d done what I thought was a sensible thing and upgraded the firmware, thinking that this might fix it.

Actually, it broke it even more.

Turns out that if you upgrade the gateway to version 1.4 this breaks all the stored settings. There’s a useful description of the problem and how to solve it here.

Now I’m back on the map, which is rather nice.

LoRa Seminar Recording

Since I had the slide deck lying around I thought I’d record a screencast of the content for anyone who missed the seminar yesterday. I’ve not made any screencasts for a while. I learned a few things doing this one:

  • All the foam has dropped off the earpieces on my microphone headset and turned into a rather horrible powder….

  • The microphone on the headset seems to be past it’s prime too.

  • It’s very annoying when the phone rings and you’re in the middle of a recording (if you listen you’ll hear the smooth and professional way that I deal with this)

I’ve ordered a better headset with a proper microphone. At the emf camp earlier this year a chap was talking about podcasting and saying everyone should do it. Once the new headphones arrive I’ll have one less excuse for not having a go. So expect to hear more of my dulcet tones in the future.

Talking LoRa at Hull University

As you can see, there was a lot of publicity for the seminar….

Today I did my LoRa talk at the university. It was great fun, and the audience were lovely. I was in a lecture theatre I know very well from many hours of teaching there in the past. Good to see a few familiar faces and a few new ones. I hope you found the material useful/interesting.

Talking LoRa and Air Quality Sensors at Hull University on 28th November

Air Quality sensors inside and outside the box

I’m presenting a session at Hull University about low powered radio networks and air quality sensors in a couple of weeks. I’ve just written the description:

"LoRa is a low powered, long range radio networking technology with the potential to open up new embedded applications. It makes it easy and cheap to create connected devices. Rob Miles will explain how LoRa works, what makes it particularly interesting and why you should start working with it. He will show how the Connected Humber group are using LoRa to move Air Quality data from sensor to server, and how you can create your own LoRa devices very easily."

It sounds rather interesting. I’m definitely going to go along.

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.

Build another LoRa Node in a Day

Everyone looking happy at the start

In July we held a “Build a LoRa node” workshop at c4di. It was great fun for us, and those who took part. Today we did it again. I turned up, fresh from my media appearance and helped Robin set things up. As before, the aim was to get attendees to build a working LoRa node and finish up with a device sending environmental data to the cloud.

Everybody succeeded. It was great to watch them all convert a “bag of bits” into a working sensor node and then watch as they saw their readings appearing in their browsers.

We run the events when we get eight or nine people together who want to have a go. They are hosted in the lovely environment of the c4di and we only charge you for the parts that you take away. If you want to come along to our next one, just send me an email or a direct message on twitter and I’ll add you to the list.

Connecting a ZPH01 Dust Sensor to Python

I've just noticed that one of the wires came of the connector while I was taking the photograph. Oh well.

Anyhoo, some time back I got a dust particle sensor to play with. Air quality is a big thing, but one that we don't have much information about at the moment. An air quality measurement device is also a perfect application for LoRa. Sensors can gather data and then send summaries over the network. As part of ConnectedHumber initiative (of which much more later) we're designing an air quality sensor with the intention of deploying some city wide.

As a start I've connected the sensor to my PC and written a little Python script that gets the readings from it. You can find the script on GitHub here, in the unlikely event that you've got a sensor just like mine.

To connect the sensor to my PC I just used a standard USB to serial adaptor, the kind of thing you use to program Arduino Pro-Mini devices. I connected all the signal pins, and also took the mode pin to ground, so that the sensor will output serial data rather than pulses. 

The sensor works fine, although I've no real idea what any of the numbers mean at the moment. The next step is to get one into a case with a Wemos or LoRa device connected to it. 

LoRa Build a Node Workshop at c4di

We've just had a bunch of folks around to build some LoRa nodes. Robin had put together some kits and we came up with a set of instructions. By the end of the day we expected our attendees to have their LoRa nodes sampling temperature, air pressure and humidity and maybe even be viewing the values on The Things Network website. 

Well, we got that and more. One person had the information going into Microsoft Power BI and was using Machine Learning to predict future room temperatures. Another used If This Then That to tweet temperature readings to his phone. Others left with plans to install LoRa gateways and sprinkle LoRa powered sensors all over their properties.

Very successful, in spite of the fact that we were soldering surface mount components and some folks hadn't soldered since they were 14, or even at all. Thanks for coming folks and being so determined. At some points during workshop you could have heard a pin (or other tiny component) drop. 

We're doing another one in September, ping me an email if you want to get your name on the list. You can find our notes and sample programs here.

If you want to play with LoRa (and anything else that takes your fancy) take a look at the Humber Health Care Challenge. We'll make sure we've got some LoRa kits available there for people to have a go with this technology. 

Mightier Than sword or pen?

LoRa at Humber Street Gallery

Today finds us at Humber Street Gallery. We're looking for locations for a LoRa gateway for the area. They've got a lovely rooftop bar which looks perfect, and has some amazing views. Of course, I happened to have my camera with me. 

We were telling the folks at the gallery about LoRa and we're going to go back and find out a bit more about the possibility of LoRa enabled artworks. Could lead to some interesting discussions. 

Tell LoRa I love her.

Gotta love the post title. But I do quite like LoRa. We're doing some exciting things with LoRa nodes over the next few weeks and so I thought I'd build a node of my own. I used a kit that Robin put together and had a node on the air within a couple of hours. The node just sends temperature, atmospheric pressure and humidity up to a Things Network server, but it does do that. And I can get the data into a Python program (other programming languages are available) amongst other places. And it was genuinely fun and easy to do. 

To celebrate I've designed and printed a box to hold the node. It's far too big at the moment. I used to have a thing where I'd make the boxes exactly the same size as the components and then find I had no way to actually get the components in, and put them together. This box won't win any prizes for compactness, but it will let me carry the node around and see just how many places pick up the signal. When I've got a bit more experience with the technology I'll post some How-Tos and other stuff. This really is great fun. 

Kickstarting Hull's Smart City

Paul Foster taking networks. 

Well, that was fun. And exhausting. We did two Smart City events in one day. The morning event was all about getting people together to build a network, and the afternoon was all about the tech of LoRa. 

Both events had awesome attendance, lots of sensible discussion, and we even managed to fit in a bit of planning. As far as I'm concerned, the outcomes are:

  • We are going to get Lora gateways to cover the area as a first step towards building the Smart City infrastructure. There are already some commercial/proprietary LoRa gateways opening up in the region which would be a fantastic platform for industry strength applications, but from a community perspective an open one based on The Things Network would make a very good start. If you're not sure what LoRa is, read the attached slide deck....
  • We are going to start up a community effort building LoRa network devices. Lots of people seem quite keen on this. Once we've got the bits together we'll set up a happy afternoon where we'll build some network endpoints and get them going. Then we can start looking at using the devices to solve problems. 
  • We are going to set up a "Smart City Steering Group" to get all the interested parties together, share what we are all doing and try to put together a strategy that will start with LoRa and move on to consider other technologies including how to make some of the data gathered into open data. 

If you want to see my slides, which tell you all about LoRa, you can find them here.

I'm really excited about this. I think it could be the start of something not small. If you didn't make the events, but you want to get involved, feel free to contact me directly (put a comment on this post or message me via Twitter or email me or stand on a corner and shout loudly).