Commercial, Gunnebo Business Solutions, Innovation, Microcontroller, Microsoft Azure, Reflections

Everyday Safe and IoT for the Consumer

The whole world have advanced into the digital age and as a lot of appliances, gadgets, and accessories now depend on internet for their operation. These devices are designed with state-of-the-art technology so they can communicate smoothly at any time, and have now become so popular that they outnumber the human population. There are approximately 7.62 billion people around the world but surprisingly, we have 20 billion IoT devices which are all connected to the internet.

New IoT devices emerge every day; we see home automation systems, smartwatches, smart gadgets, smart vehicles and a long list of other things that makes your life easier and more fun in today’s world.

Through my work in Innovation at Gunnebo Business Solutions, I get to work on quite a few cutting edge projects to bring Gunnebo into the connected future. The GBS team strives to develop a scalable collaboration platform that supports each business units digitalization and software offering. Our main focus is actually to lead Gunnebo’s business units into the digital future of Software Services and enable product as a service sales.

Global network background-1

I am currently working on a really exciting project with our Safe Storage Business Unit. We are working on a brand new smart-safe, which can easily be integrated into different parts of the home – kitchen, bedroom or bathroom – to store your valuables. The safe is designed to suit everyday needs and it can be used for storing valuables such as car keys, jewelry, credit card, visas, passports or any other thing important to you.

The safe is designed to be a simple and convenient solution that can be accessed by customers around the world. Anyone interested in getting the best security for their valuables would try out this option. Not only does the safe keep your valuables safe, but it’s also aesthetically appealing and made from the best technology which is only even more attractive.

As any smart device, this safe will of course be easily be connected to the owners mobile phone and send telemetry to the cloud. This is where I come in. I am working with our team in Markersdorf on merging classic and mechanical parts of a safe securely with modern IoT technlology.

IMG_5144

To make sure that our new IoT device deliver to its potential, it is developed with state-of-the-art technology, both physically and on the firmware and software side, that makes it reliable and easy to use.

To ensure the efficiency of our operations we work with agile partners like Microsoft, 3H, Polytech Software and others to help fusing entrepreneurial spirit with professional development of the product. Through their involvement, we have been able to achieve optimal results.

everyday safe

As mentioned earlier, the Internet of things (IoT) is a system of interrelated computing devices, mechanical and digital machines. This means that it can be just anything from your television to your wristwatch. Over time, the scope of IoT devices has changed from what it used to be due to the convergence of multiple technologies, real-time analytics, machine learning, commodity sensors, and embedded systems.

An IoT device exposes its users to a number of impressive benefits which include increased interaction between devices, allows great automation and control, easier to operate, saves time, saves money, increased efficiency and time saving and so on. But it still has a few drawbacks of its own such as may easily become highly complex, may be affected by privacy and security breach, reduced safety for users and so on.

The market for IoT devices is expanding every day and becoming more popular as its number of users also increases. This might be the first IoT device from Gunnebo, but it is definitely not the last.

If you want to know how Gunnebo works with IoT in the consumer market, feel free to contact me at bjorn.nostdahl@gunnebo.com

 

Microchip, Microcontroller, MQTT, PIC24, Protocols

MQTT for PIC Microcontrollers

The IoT (internet of things) world is bursting, in 2018 there were 23.14 billion connected devices, and it is projected to get to 30.73 billion by 2020 (from statista.com).

Embedded systems are at the center of this IoT drive, smart homes, smart cars, etc. all have embedded systems as their backbone.

Global network background-1

Microcontrollers are the drivers of embedded systems. They give devices the ability to collect data from the environment, send and receive these data and execute the needed instructions or carry out specified actions. Like turning on the heater when the temperature in the room goes below a specified level.

ARM and the PIC microcontrollers are the common microcontrollers used in embedded systems and IoT. When these devices send and receive information over a network (say the internet), they do so using transfer and transport protocols that control this transfer processes.

The hypertext transfer protocol (HTTP) is the most popular communication protocol used over the internet to send and receive data. In IoT communications this protocol is still used in most applications. A more efficient protocol is the messaging queue telemetry transport (MQTT) protocol that is optimized for low connectivity and low power requirement. The MQTT protocol finds immediate application in remote locations where batteries are used and need to be conserved.

The HTTP system transfers data via the request-response paradigm. This transfer protocol requires devices querying other devices directly for data. This leads to increase in bandwidth requirement and power consumption. Since devices have to respond to requests one after the other, multiple, asynchronous and simultaneous communication cannot be effected. This comes as a disadvantage for IoT applications where multiple devices communicate at the same time. HTTP does not allow for multiple simultaneous communication, being synchronous.

The MQTT protocol solves these.

What is the MQTT protocol?

I gave a detailed description of what MQTT is in a previous post. But for this post, I’ll reintroduce just the important points.

The MQTT is a lightweight broker-based publish/subscribe messaging protocol designed to be an open, simple, and easy to implement data transfer protocol, designed to optimize bandwidth and power consumption. It is a machine-to-machine (M2M) communication paradigm that allows devices to send and receive data faster and more reliably without being connected directly.

MQTT finds immediate need where the network is expensive, unreliable or of low bandwidth. As well as when the embedded devices are of limited processor or memory resources.

The MQTT (message queue telemetry transport) protocol works in direct contrast with the hypertext transfer protocol (HTTP) which is popularly used in sending data and communicating with devices over the internet.

MQTT provides for one-to-many communication and message distribution. It is unconcerned of the sender or the content of the message, and uses the TCP/IP to provide network connectivity. Has a small transport overhead (a message sent with this protocol can have a header of as small as 2 bytes), and with features that ensures lost connections or data can be accessed.

MQTT in microcontroller connectivity

Using the MQTT protocol in microcontrollers will improve the efficiency of data transfer, reduce the power and bandwidth requirements and introduce asynchronous communication among devices. All these come in handy with the limited memory capacity of microcontrollers, need for faster and more reliable data transfer among IoT devices and increase in IoT devices in circulation and mainstream adoption of the technology.

This protocol guarantees faster, more power efficient (than the HTTP), low latency and dependency communication among devices. This is because the MQTT protocol works on a publish-subscribe paradigm. With this model, there is no direct connection and communication between network devices, instead there is a middleman, called the broker.

To use the MQTT protocol for communication with your microcontroller, a broker is required to collect and dispatch data among devices. The broker (also known as the server) facilitates the publish-subscribe model, in a similar fashion as the client-server models. The clients (that is the connected devices) subscribe to virtual channels, known as topics. Other devices that want to send out information (known as a message) will publish the information on a specified topic to the broker. The broker then distributes the message to all the clients that subscribe to that topic topic.

Telecommunication concept with abstract network structure and server room background.png

The broker is the core part of the MQTT operation. The broker is the middleman in data transfer using this protocol. The broker/server stands at the center of M2M communication. It receives messages (on a particular topic) from devices connected using the protocol and aggregates them for transfer to other devices that subscribed to the topic.

This kind of communication provides for continuous availability and distribution of data among devices. The advantage that this kind of communication provides is lack of dependence on direct M2M connection (that besets the HTTP communication system). Devices practically work and run on their own independent of the presence or interruption of other devices. This type of connection provides real time data; this is because the broker constantly publishes the received messages to connected device. Messages that were not subscribed for are destroyed, and those that have subscribers are dispatched to the devices. With this, any interruption that occurs with the connection of one device does not affect the entire network, instead, all the messages sent while it was away are retained and push to its when it comes back on the network. The MQQT protocol is more data-centric that identity-centric.

The Programmable intelligent computer (PIC) is a Harvard architecture microcontroller that is regarded as the industry standard due to its robust features. It is a more sophisticated microcontroller than other microcontrollers like the Raspberry Pi microcontrollers, as it provides more functionalities and features than the other microcontrollers.

My previous article talked about the deployment of the MQTT protocol on the Raspberry Pi microcontroller, Gunnebo AB’s mikroPascal MQTT library puts the MQTT protocol on the PIC microcontroller.

SIU04

Our MQTT library for PIC Microcontroller brings faster and better connectivity for the PIC microcontroller. It enables PIC microcontrollers to communicate using the MQTT protocol. The MikroPascal library is built around MQTT protocol with QoS of 0, it is built on the existing TCP and IP stack based on the mikroPascal TCP/IP library, lib_enc600_v3_5, adding the MQTT layer on it.

The MQTT library is built as a wrapper around TCP/IP protocol with the purpose of providing features to publish and subscribe to text messages to specific topics, by the means of MQTT protocol.

The library carries out the following core functions:

  • Establishes TCP/IP sockets,
  • Formats MQTT packets and prepares them for transmission,
  • Extract contents from subscription messages arriving in MQTT packets,
  • Transmits MQTT packets over TCP/IP,
  • Provides test (ping) methods to test the health of connection,
  • Provides functions for subscribing to and publishing to topics as well as unsubscribing from topics.

The library reduces RAM memory requirements and provides better performance by supplying the library functions with input parameters that are pointers to arrays.

mp1

The basic work flow of the library on the PIC microcontroller is as follows. The microcontroller reserves the address for the message/information and provides pointers to this address. The MQTT library takes it from here and use the pointer to obtain or receive messages to the controller.

mp2

To communicate via the MQTT protocol on your PIC project, there are some prerequisites that your project must meet.

With the mikroPascal MQTT library, we implement this light weight protocol for the PIC microcontroller. The library can be downloaded here.

The library brings all the benefits of the MQTT protocol to PIC users enabling users to package and send data in their IoT project seamlessly, faster, with less memory requirement and wider connection with other devices.

The library can be downloaded here at the libstock repo, you can run a demo of the library to see how it works, and also check out our open source codes on github.

We welcome you to contribute to this library and please also fork it for other mictrocontrollers. If you have any questions, please reach out to me: bjorn.nostdahl@gunnebo.com