LG202: IoT Cloud Server -
A busmans holiday of sorts

My first module, ‘LG201: IoT Prototype Development’, I think went well. I scraped a distinction and I learned a great deal, much of which in areas that are brand new to me. I got some constructive feedback and I’m excited by where these new skills will lead me.

Whilst the previous module concentrated on the ‘Things’ aspect of IoT this one is all about the ‘Internet’. I spend a great deal of my time writing secure distributed cloud-based systems, hence the ‘Busman’s Holiday’ comment, but virtually none explaining them to anyone.

The challenges here will be explaining the what and the why of it, whilst dealing with duplex communication channels rather than the more usual Request-Response model.

Every second 127 new IoT devices are connected to the web, [1] and by the end of 2020, it’s estimated that there will be 35 billion devices. To perform millions of different functions and send billions of commands, these devices need to communicate with the internet, they need to be online.

Servers, therefore, play a huge part in IoT, building on the starting point from the last module that simply echoed data to all connected devices, we will develop a server that securely collects data and allows devices to communicate.

Let’s consider my current requirements and future requirements for the projects I’ll work on for the remainder of this course. Recently, I’ve been finding user stories a useful way of looking at requirements, they often highlight nuances you may have otherwise missed.

How very agile of me… here’s a story to get us started:

“Jon spends a lot of time playing about with devices… he has loads of micro-controllers and computers automating various functions around his flat. He also likes to gather data from public API’s and send commands and data to his devices and interact with them using voice interfaces.

He is using various technologies on various cloud services to accomplish this and his monthly Google Cloud, Amazon Web Services and Microsoft Azure spends are getting out of hand.

There is huge duplication in code and functionality, he is on a journey of discovery. The modules planned out for the remainder of his MSc will add more projects, more requirements and much more data. It is time to normalise his approach to IoT data delivery and storage.

He needs to turn some services off so he can afford to take his girlfriend to dinner, he needs to develop a secure, flexible solution that is easy to configure for all his current and future IoT requirements.”

Not so nuanced… I’m writing too much code and spending too much money! I know this doesn’t follow the “As a, I want, for this ” format that has been widely adopted for user stories, which is explained brilliantly in this article from the Interaction Design Foundation, but I like to add a little more background to mine, you know, really build the scene... User Novellas?

But why roll your own?

A good question… Azure has IoT Hub, it’s infinitely scalable and offers us device onboarding and several protocols including MQTT which is fast becoming a default choice. MQTT has a broker with a Publish-Subscribe model which would work, but does it give me the flexibility around distribution and security that I require...?

Anyway, I’m rolling my own… I have an idea… maybe it’s foolish, it flies in the face of current fears around data sharing for sure, but hear me out… let’s add another story to explain it…

“Sally is researching the link between relative humidity and coffee sales in the UK, she has a network of 100 coffee grinders in coffee shops, which send her details of the amount of coffee ground and the temperature and humidity. She plans to automate the supply chain and improve requirement estimation accuracy.

Jimmy is a bit weird, Jimmy is researching the link between barometric pressure and incidents of seagull food theft from restaurants, to be honest, he’s going to struggle to convince owners to install his devices, just so he can say “I told you so” to his Twitter feed, but Jimmy has been told about Sally’s coffee grinders.

Sally doesn’t know Jimmy and she’s worried he’s a bit shifty… there’s no way she’s giving him access to all her coffee machines, she’s been working on this research for two years now… but she’ll happily send him barometric pressure data that her breakout boards also records, she’ll happily share that with anyone.

She wishes her IoT Server would enable her to just change a setting to make her Barometric Pressure data available to other users, so she doesn’t have to speak to Jimmy again.”

The two stories above, enable me to make the design decisions, and also, immediately illustrate the need to securely manage the users, projects, devices, and the relationships between them… we need a relational database, which is where I start 90% of the time.

As I mentioned in my last module, I employ a degree of automation in my RADish approach to development. A SQL database is the starting point for this automation and will help me to generate much of the code I’ll need to build this application.

Architecture

Architecture wise, we need a WebApp to run the .Net Core application on, some Blob Storage for graphics, logs and reports, a SQL Database and somewhere to store the sensor data… Microsoft Azure enables us to set-up this environment very easily and gives us total flexibility to add or amend the architecture as and when required.

A Sustainable Future

The second story also highlights my belief, all be it in a slightly light-hearted way, that we should be sharing device output. As new companies seek funding, there is no shortage of articles about how they are using IoT to cut carbon use. But let’s also consider the carbon footprint of adding 127 devices a second, and with them 127 more internet connections…

Let’s imagine they’re lightbulbs, as the Netflix Documentary, ‘Connections’ recently did… duplication of functionality suddenly looks more wasteful when you consider 127 more light bulbs a second?

We only need one lightbulb to light a room, regardless of how many people need to see. We only need one car to get 4 people to a destination… instead of worrying about how secure the Barometric Pressure data is for our house, maybe we should think of the approach I’m suggesting as like Car Pooling for IoT data.

I’m approaching the project management of this module slightly differently, using Azure DevOps instead of Trello. It has all the features of Trello plus a Git Repo linked to my development environment in Visual Studio. This enables me to link work tasks directly to files in the repository.

I’ll write website articles on https://sayers.cloud that explain the processes and decisions at a high level, and then point you towards some annotated key files in the repo that explain how it all works in far more detail.

Ultimately by the time I’ve finished this module, you should be able to set-up an account, download a client… see it all working in real-time.

Let’s start with a specification overview.




1. Security Today, “The IoT Rundown For 2020: Stats, Risks, and Solution”, Retrieved from https://securitytoday.com/articles/2020/01/13/the-iot-rundown-for-2020.aspx.