LoRa, IoT and mobile app development: my graduation assignment

Maurice Markvoort

Maurice presenting graduation assignment

My five-month internship at XABLU has just come to an end so I’d like to share my experience with other students to give them an idea of what they can expect if they choose to carry out their graduation assignment here.

Maurice presenting graduation assignment
Presenting my graduation assignment to the team

I’m currently in the last year of a four-year applied computer science degree at the Saxion University of Applied Science, and hoping to graduate at the end of this month. As part of the final year of my programme, I needed to complete a graduation assignment, which is like an internship with a research component, at a company. I immediately noticed that finding a company to host me wasn’t that difficult, with companies even writing to me with offers after I updated my LinkedIn status to: “Searching for a graduation assignment”.

Choosing a company

I had already had some meetings with other companies and was almost sure that I would carry out my internship at one of them, when XABLU contacted me to come for a talk. I thought it would be a good idea to go, as I find it is really helpful to enlarge your network of connections. My first impression after the meeting was very good and at home, I told everybody about the pleasant working atmosphere. It was really only a chat because they didn’t have an assignment for me at that point, but they said they would think of one. I was really enthusiastic about them, so I wasn’t sure which company to choose. After a few more meetings at XABLU, they had created an assignment for me and convinced me to carry out my internship there. The great work environment and the fun and challenging assignment seemed perfect for me, so in February 2017 I joined the team.

Learning new skills through a challenging assignment

The aim of the assignment was to “Create an open source weather station that sends data over the LoRa network which can be read in an application” (you can read more on my assignment below). XABLU wanted to gain more experience with IoT and especially LoRa, a long range, low power wireless platform used for building IoT networks, because they occasionally get questions from clients about using it with Xamarin development. I discovered through the assignment that LoRa, IoT and mobile app development make a good combination, particularly for the agricultural and industrial sectors. I also had the chance to learn many new skills and become familiar with new tools:

  • Better programming in Python
  • Different kinds of hardware
  • LoRa
  • MQTT
  • .NET Core and ASP.NET Core
  • Creating an API
  • Swagger
  • Xamarin development

A great place to do an internship

My initial impression of the pleasant working atmosphere at XABLU proved true. My colleagues are very helpful and nice to work with. When you ask them something they will immediately help you. As a intern I was free to do what I wanted. Because the topic of the assignment was very broad, I could go in many directions. Every week I had a meeting with my company coach, where we discussed my progress and what I should be doing the next week. This meeting helped me a lot because I could discuss my own ideas with the coach.

Overall I had an amazing time carrying out my graduation assignment at XABLU and learned a lot, so I can highly recommend the company to other students as a great place to be an intern. After presenting my assignment to the team I was also surprised with a job offer, which I immediately accepted!

Accepting the job at XABLU
Accepting the job at XABLU

Visit the XABLU Careers page for info on applying

Learn more about my graduation assignment below:

“Create an open source weather station that sends data over the LoRa network which can be read in an application”

A little summary of the assignment: The context is that a user buys a weather station and builds it. After it is built, the weather station will read data every hour: temperature, pressure and humidity. The data will be sent over the LoRa network into data storage that is hosted by a cloud service. The user can read the data using an application. Data in the application will be retrieved by an API that has to be created. Because the project will be open source, other people can help with the project and a community can be built around it.

The main focus of the assignment is LoRa, which stands for Long range, Low power. It is a commonly used wireless network for IoT (Internet of Things, a collective name for all devices that communicate over the internet), that can be used for long range data transfer. The range can go up to 10 kilometers and very little power is required. The use case for LoRa is when a very small amount of data has to be sent over a long time frame, such as every hour or every day, such as smart homes or smart cities. At the beginning, LoRa could only be used when using a provider (like KPN). You had to pay the provider for using the network. In 2015 a community called The Things Network was created to make it possible to use the LoRa network for free. This network was used for the LoRa part of the assignment.

The assignment can be divided into five steps: Hardware, LoRa, Data storage, API and Application.

Step 1: Hardware

hardwareIn step one, I researched the best hardware to read and send data over the LoRa network. Two kinds of hardware were needed, a microcontroller that can send data over the LoRa network and a sensor that can read temperature, pressure and humidity. The result: the Pycom LoPy as microcontroller and the BME280 as sensor would be best. After this research, I implemented a program that reads the data and sends it to The Things Network. The program was uploaded to GitHub and can be found here: BME280-LoPy-TTN.

Step 2: LoRa

Step two was also based on finding the answer to a question: “What is the best way to send as few bytes as possible over the LoRa network to The Things Network?” Because the LoRa network offered by The Things Network is a free and open network that can be used by everyone, there are some restrictions. A fair access policy is used to determine how many bytes of data may be sent, to ensure the network is not overloaded. Therefore I researched how I could reduce the amount of data I needed to send. I did this by transforming the data into binary data. For example: the temperature value is 22.65 which is a float and has a size of 4 bytes. When multiplying the data with 100 you get a rounded number, so 22.65 will become 2265 which is a short and has a size of 2 bytes. By doing this to the other data I managed to reduce to data from 11 bytes to 6 bytes, which is much less than the policy requests.

Step 3: Data Storage

Step three was about getting the data out of The Things Network to save it in a database. Once the data arrives at The Things Network it is available for a short amount of time, using MQTT. MQTT (Message Queue Telemetry Transport) is a widely used data protocol within the Internet of Things branch. With this protocol you have a service, in this case The Things Network. A program can subscribe to this service. Every time a message is sent to The Things Network, the service will send it to the subscribed programs.

I implemented a .NET Core application that subscribes to the MQTT service of The Things Network. When a message is sent, the program receives it from the service. Once received, the program will decode the data and put it back into readable data, so 2265 will become 22.65 again. After the data is decoded it is stored in an InfluxDB time-series database. By uploading data to the database a timestamp will be saved. The use of InfluxDB makes it a lot easier to request historical data. The program managing all of this has been uploaded to GitHub and can be found here: TTN-MQTT-InfluxDB

Step 4: API

devicesStep four was about creating an API. An API (Application Programming Interface) is a program that communicates with other programs/hardware. An example of this is a computer that prints a document. The computer doesn’t know anything of the printer and what it does internally. By calling the API of the printer by telling it to print, the API will talk with the printer and print the document. Within this assignment, I created an API for getting data out of the database. The program is an ASP.NET Core program. Some requests that can be called: “{url}/api/v1/devices” to return a list of devices, and “{url}/api/v1/devices/{deviceid}” to return info about the requested device. The API is documented following the Swagger standard. Swagger is a documentation tool that can be used to document your API. After generating Swagger documentation a page is created, where you can see all requests and can learn what the calls are for. By clicking on the call you can even test it.


Step 5: Application

map viewLastly, step five was focused on displaying the data collected. To display the data, I created a Xamarin forms application. XABLU is specialized in Xamarin development, and cross platform mobile applications, for Android, iOS and Windows, can be made using Xamarin Forms.

Within this application a map of the Netherlands is shown, displaying all available devices. By clicking on one of the devices, a new window will pop up with the measured values, retrieved using the API. This application was uploaded to GitHub and can be found here: LoRa Weather app

Curious how Xablu can help your organization ?