Simplifying Software Development of Embedded IoT Applications
February 11, 2021
Story
To succeed in the IoT market, OEMs need to be able to embrace innovation at a faster rate.
However, building robust products for the IoT edge is not an easy task. With more and more things connecting to the Internet in the world of IoT, there is a demand for networked devices that not only have the ability to connect to a cloud but can also handle complex computations at the edge.
OEMs are continually identifying new and more useful ways to harness the capabilities of sensors, monitor types of data, process the information, connect to cloud, and control the ecosystems of devices. The possible spectrum of IoT applications is endless, ranging from homes, cars, wearables, industries and out to smart cities.
MCUs and connectivity devices are at the core of these IoT-based products. To help IoT designers are design unique, efficient, secure, and aesthetically attractive devices, silicon manufacturers are integrating more features and peripherals while enhancing available processing power with advanced capabilities like machine learning and artificial intelligence. These embedded computing and wireless devices must work seamlessly together to reduce design complexity.
A key part of minimizing this complexity is made possible through modern software suites that hide or abstract complexity and provide an easy, secure and intuitive platform for IoT designers to develop their applications. These specially designed software environments handle configuration of hardware and allow easy connection across multiple devices, various platforms, and networks to create a web of communication to revolutionize the way we interact intelligently in this digital world.
This article will explore these challenges in detail and explain how an intuitive software environment compliments optimized IoT hardware to offer complete powerful secure platform for developing intelligent IoT solutions at a much faster rate. As an illustration, we will use a low-power IoT device as an example to securely connect to the cloud using the MQTT protocol.
Challenges of Designing an Embedded IoT System
Let us first understand the challenges in designing IoT applications, then explore how modern software helps IoT Designers overcome these challenges. Figure 1 shows the key challenges.
(Figure 1. Key Challenges of Designing IoT Applications)
Time to Market
The number of devices connecting to the Internet each year is growing at an exponential rate. In order to keep up with the competition, time to market is the key. However, software has a significant impact on development time and cost. Choosing the right software and tools can simply and speed development to cut production time significantly. With the plethora of protocols involved in building real-world IoT applications, the software also needs to handle the underlying complexities of the various protocols that help the application interact seamlessly in the world of IoT. To keep these protocols and constant change from becoming a drain on designer resources, software needs to isolate the application from hardware changes.
Ease of Use
To support the complex computation demand for IoT Applications, MCUs have become more complex to provide more processing power, security, and intelligent logic. They also have to supply many peripherals to support additional capabilities like audio, interfacing with external memory, motor control, etc. In addition to this, MCUs have an additional task of managing the wireless systems as well. Software tools that support both the embedded and wireless systems under one umbrella can save an invaluable amount of development time and enhance user-friendliness. The biggest challenge for these tools is to not just to hide hardware complexity but to also provide an easy-to-use, GUI-based development platform. To achieve this, development platforms often provide numerous GUI-based tools and configurators to perform most of the tasks involved in application development – project creation, importing libraries, configuring peripherals, etc. The underlying code for the GUI-based configurations is automatically generated and built along with the project so that designers can develop applications with minimal coding effort.
Development Platform
-
IoT Development Tools - A complete software development suite is required to build an IoT application. These software tools include Integrated Development Environment (IDE), Command Line Interface (CLI), Software Development Kits (SDK), and libraries or APIs that are tailor-made for IoT developers. These software development tools can be used on top of IoT development platforms or in conjunction with them. Easy and intuitive development platforms provide flexibility to IoT developers by giving the option to develop entirely using the vendor’s IDE and tools or develop applications on any other IDE of one’s choice like IAR Embedded Workbench, Arm Microcontroller Development Kit, and Microsoft Visual Studio Code in conjunction with the vendor-provided tools. The platforms also provide well-documented template applications to give developers a jumpstart on and accelerate application development.
-
Choice of OS - IoT encompasses devices ranging from small sensors to complex systems like robots. Choosing an operating environment for an IoT system is one of the crucial tasks that affect the firmware development approach. The important requirements of an IoT OS include optimized memory footprint, energy efficiency, integrated security, connectivity features, hardware agnostic operation, and real-time processing capabilities. IoT operating environments range from bare-metal to embedded OSes to full-featured OSes that cater to the different requirements of IoT applications. There are many choices of development platforms for embedded IoT applications, including Mbed OS and Amazon FreeRTOS, to name two. Apart from these platforms, embedded and connectivity device vendors sometimes provide additional libraries to support custom-made IoT features. These libraries/platforms complement the development OS to provide both embedded and wireless features within an intuitive IoT development environment. The seamless combination of the feature-rich libraries provided by the device vendors and the OS of choice based on the application provide IoT developers a comprehensive development platform for IoT solutions.
Ability to connect to cloud of your choice
With more embedded devices getting connected, there are many cloud services available. Anyone planning to develop real-world IoT applications can pick and choose a combination of cloud services for various tasks. Therefore, the embedded software must be highly flexible to support various cloud services (AWS, Azure, AliOS, etc.) and platforms. The software must let developers design the system their way rather than limiting them to certain options. A hardware-independent software architecture is key to addressing this problem, and the software ecosystems that provide this feature offer a great deal of flexibility to the users.
Security: A non-negotiable element
Once a device is connected, the possibility of being hacked is introduced. Thus, the security of IoT devices is a non-negotiable element, whether the device is a personal wearable device or a connected car. Data protection is needed at all levels, including storage, processing, and during communications to ensure system reliability. Hardware designed for IoT applications needs to have all the elements to develop secure and safe applications. In addition to hardware security, software needs to also complement these hardware secure elements. Security also needs to be integrated in a way that matches the processing and cost requirements of the application.
Tackling the Challenges in an Embedded IoT System
Let’s discuss the above concepts in more depth using a low-power MQTT-based embedded IoT application as an example. MQTT is a popular communication protocol used by embedded systems to connect with the IoT world. In a typical IoT system, embedded devices gather various sensor data, process them, and communicate the information to a remote cloud system using the MQTT protocol.
To build such an application you will need an ultra-low power microcontroller designed with IoT applications in mind (E.g. PSoC 6 MCU) and a low-power wireless connectivity device (E.g. CYW43012 Wi-Fi/BT combo device). For efficient development, a software platform that enables development and debugging of these embedded and wireless devices together is required, such as ModusToolbox. ModusToolbox is a complete development system for embedded and IoT applications. Figure 2 gives an overview of the ModusToolbox. It provides GUI-based tools, firmware, middleware, APIs and documentation for IoT developers. With Board Support Packages (BSPs), Middleware libraries, and Template Applications available in GitHub, developers can access the resource them need directly. In addition, a project created in ModusToolbox can be exported to other IDEs such as IAR Embedded Workbench, Arm Microcontroller Development Kit, and Microsoft Visual Studio Code. Further development can be continued in these environment along with building the project with the help of user preferred compiler toolchains like GCC, ARM, IAR as highlighted using the white boxes in Figure 2.
(Figure 2. ModusToolbox - A high-level overview)
ModusToolbox provides a collection of software libraries known as the AnyCloud solution for rapid development of Wi-Fi and Bluetooth applications (see Figure 3). Blocks in purple like USB and CapSense represent MCU libraries. Blocks in green such as MQTT and Low Power Assistant (LPA) are the connectivity libraries. These MCU and connectivity libraries seamlessly integrate to enable secure IoT application development.
(Figure 3. AnyCloud Software Stack)
For MQTT applications, AnyCloud provides a single software environment that hides various complexities such as Wi-Fi connection management that handles network connections, IP address changes, etc.; network socket creation; Transport Layer Security (TLS) and much more. It provides the flexibility to its users to develop their applications as per their own style. To develop the MQTT based IoT system, IoT designers can get started with an existing MQTT application which is available as a part of the template applications for the desired device in the Project Creator GUI tool (see Figure 4).
(Figure 4. IoT project creation using template applications)
IoT developers who have an existing project and need to add MQTT to their application can use the Library Manager to do so. Library Manager manages and import libraries used by the application, as well as takes care of the dependencies that a selected library has. It also recursively imports all libraries needed for a top-level application. For this low-power IoT project, the IoT designer would enable the “mqtt” library and the library manager automatically pulls-in all dependencies as illustrated in Figure 5 below.
(Figure 5. Adding MQTT functionality to an existing project)
Once the MQTT package is imported, the IoT designer can get more information to kickstart the application development using the very detailed README files provided with both the MQTT template application and the MQTT library. Figure 6 shows part of the individual README files that help IoT designers get started and run their application for the development flow they desire.
(Figure 6. Detailed READMEs for quick start on IoT software)
Once MQTT is implemented, the primary focus of an IoT developer is typically on low power consumption. A key feature in power efficient IoT systems is “offloads”. Host offloads enable the host PSoC 6 MCU to go into deepsleep for extended periods of time while the wireless device handles tasks on behalf of the MCU host such as ARP requests, TCP keepalives, etc. Host offloads play a key role in optimizing host power consumption. In addition, these offloads free the host CPU for other, more powerful tasks such as audio or sensor data processing. This in turn improves overall system efficiency and power. Configuring these offloads in a real world IoT system would be a complicated task. With a tool environment that integrates both MCU and wireless design, development time and effort is reduced.
For example, the “Low Power Assistant” (LPA) configurator tool which comes with ModusToolbox, enables developers to configure low power offloads by enabling checkboxes and choosing the necessary configurations as Figure 7 shows. The tool automatically generates the source code based on these configured settings for the application.
(Figure 7. Low Power Assistant (LPA) Tool)
In addition, a lot of code needs to be written in order to configure various pins, peripherals, and clocks for the MCU. Configurators provide an easy way to perform such tasks using a GUI, eliminating developer time to code these tasks manually. Configurators can also help with various MCU related settings like GPIO pin setup, peripheral configurations, analog routing, system setting, clock tree setup, and DMA routing. Figure 8 shows a few of these configurators: GPIO pin configurations, peripheral configurations, and clock settings. Tools like project creator, library manager, USB configurator, device firmware update host, Bluetooth configurator, and segment LCD configurator also significantly reduce the development time and effort of IoT developers.
(Figure 8. (a) Pin Configurator GUI Tool)
(Figure 8. (b) Peripherals Configurator GUI Tool)
(Figure 8. (c) System Clock Configurator GUI Tool)
Some applications will need more flexibility in development to customize settings. Configurations made by GUI tools can be overridden with manual coding when needed. Also, more flexible development platforms provide build systems that can be integrated with many third-party IDEs and advanced users can use CLI tools as well. Having such a powerful yet flexible development platform accelerates the time to production and greatly improves the efficiency.
With the availability of many cloud services and platforms, OEMs need to be flexible and able to quickly adapt to innovation. A key element of flexibility is designing with development tools that can adapt to various IoT platforms and supports a wide ecosystem. In this article, we looked at the most important challenges of designing an IoT system and how software tools can simplify design complexity by hiding the underlying complexities that an IoT architecture demands. These SW platforms also provide the flexibility to the advanced developers to customize most of the design aspects of an IoT system. This is achieved through an active and seamless integration of embedded and connectivity devices both in hardware and software stacks. This integration of MCU and wireless devices is the foundation of a compact, ultra-low power and powerful system that caters to the needs of the booming/growing IoT market.