Reasons to Select FreeRTOS for IOT

Similar looking FreeRTOS logo image reproduced.
If Real Time Operating System is not used for embedded system programming for IOT products then what are the options available. The one option, which is used by most low-cost microcontrollers for non-IOT applications such as micro wave oven, Air Conditioner etc, is bare metal programming or infinite loop programming or back-ground/foreground programming.

Infinite Loop Programming Demerits for Complex Application

For simple applications such as temperature control of a room, power consumption monitoring of a device etc, infinite loop programming is absolutely good in this scenario. But if infinite loop programming is used in a more complex applications where multiple tasks/events occurs and each have different level of priority then the use of infinite loop programming fail tremendously. Although interrupts can be utilized to cater the asynchronous events but this does not solve the problem to a greater extent because it will lead Interrupt Service Routine to run longer which would block the infinite loop execution.
The polling in the bare metal programming leads to wastage of processing cycles. The processor waits for a flag or events to trigger by polling or checking the bit continuously in that duration processor is doing nothing productive but wasting its resources. However it is uncertainly possible that in that particular instant an interrupt occurs and processor then executes that events/tasks.
For IOT products in which microcontrollers have to establish connection to the internet and transfers the data and status of the machine or process to the user or client via internet and receives the instructions or commands from the client or user via internet to execute those commands to produce the desirable output. Further the nodes have to communicate with each other to maintain the desirable output of the process. This is quite complex application and different protocols are to be implemented and executed to achieve the functionality of IOT products. Therefore infinite loop programming is not suitable for embedded system programming for IOT products.

Real Time Operating System to Cater IOT Programming Complexity

Real Time Kernel, in simple words, is a software which performs resource management, inter-task communication, synchronization etc. It usually come as a set of libraries that can be used to program the embedded system. It basically divides the application code into number of tasks or threads can be performed on a priority based in a timely fashion. Although single processor can perform only one task at a time but it creates an illusion of multi-tasking or multi threading with the help scheduler. It basically schedules or switches the CPU between different tasks so that it appears the CPU is performing multitasks. Other than that it provides modularity, readability, maintainability, code efficiency, easier testing to your application.

Reasons for Selection of FreeRTOS for IOT

There are many Real Time Operating Systems available in the market, then what makes FreeRTOS so different to be chosen for internet of things. Lets discuss it comprehensively,
Nowadays many IOT products and solutions are being launched by many startups and big giant companies as well. If you opt for commercial RTOS other than FreeRTOS for your product then you will have to pay for its license which would increase the product cost. On the other hand, FreeRTOS is an open source RTOS which can be used in your product without paying any penny for its license and you can commercialize your product as well. Thus, the cost of your final product will get reduced that make your product more competitive in the growing market of IOT.
The nodes in IOT are constrained devices which have low processing power, ROM, RAM etc. One problem that arises is Real Time Operating System needs to use constrained devices' resources for its storage and processing which leads to an overhead for these devices. To solve this issue FreeRTOS uses as minimum resources as possible to cause lower storage and processing overhead. Usually 6 Kilo Bytes to 12 Kilo Bytes are utilized for RTOS kernel.
Despite being an open source software, FreeRTOS provides all such standard features as provided by in the commercial RTOS. This includes multitasking, flexible task priority assignment, task notification, queues, semaphores, mutexes, event groups, and much more. All these features make your coding efficient and manageable. It provides a good control to achieve your targeted functions in your product easily. 
For beginners who want to learn Internet of Things and has a burning desire to develop an IOT products or to provide IOT solutions to start their career in the internet of things, FreeRTOS is ideal for them. It provides you with learning support and strong community. A well written article to describe every skill in an incredible and comprehensive way, which you need to master FreeRTOS. You can read that article from here.

Steps to master IOT for Beginners

IOT (Internet Of Things) is an emerging technology which is causing change in which human interact with machines or the way machines interact with human and would reshape the world and the way human live and interact in an incredible way which had never happened in the world history.

To learn or master IOT, one should have knowledge about different areas or field as follows;
  1. Embedded system designing, interfacing and programming.
  2. Networking and communication protocols.
  3. Web Development for IOT
Lets have a look at each field one by one.

Embedded System For IOT

Embedded system is the core for IOT as it provides the data to the server for monitoring and the actions performed remotely to close the door, turn on the light, etc are implemented by embedded system. These are the nodes in IOT terminology. These are microcontrollers which are programmed to do to the certain tasks based upon the input given to them, they process it and according produce the output.
Embedded system itself a huge field. To master this you need electronics and programming.

Electronics and Embedded System Interfacing

To learn about electronics you need to know about the basics first. Try to understand the purpose of resistors, transistors, diode, capacitors, inductors, mosfets etc. You can search on Google  and YouTube to have basic understanding of these passive and active components. After having good foundation on basic electronics look at different ICs and then have some basic understanding of Arduino Uno which is a basic trainer kit of microcontroller to learn the embedded system. 
Don't stick to the Arduino Uno, its just a first step to understand the embedded system. After learning or understanding Arduino, look at some microcontroller such as AT-Mega 16 or 32 or PIC microcontroller. Try to understand the architecture and different peripherals which are embedded in the microcontroller such ADC (Analog to Digital Converter), PWM (Pulse Width Modulatio), timers/counters, USART, I2C, SPI etc.

Embedded System Programming

Embedded system programming is quite different from programming used for Software development for Desktop computers. After having some experience with Arduino Uno programming try bare metal programming of the microcontrollers such as AT-Mega 16 or PIC microcontroller for having basic understanding of Embedded system programming. There are some tutorials available related to programming these 8 bit microcontrollers. Program the built-in peripherals of the microcontroller to get better at programming. Learn register's bits manipulation techniques such as how to set, reset or toggle a bit.
Try to have good proficiency at using IDE (Integrated Development Environment) for programming the microcontrollers. Modern IDEs have many features such as auto-completion, etc which made programming easy. 
After having bare metal programming concepts, we shall start learning FreeRtos which is a Real Time Operating System for Embedded systems. This is an open source RTOS by Amazon for IOT applications. There are many microcontrollers that support FreeRtos, but here ESP32 will be used for learning IOT as it is cheap and readily available in every corner the world.

Networking and Communication Protocols For IOT

To connect the end devices or nodes to each other and to the server some kind medium is required and for error free, secure and successful transmission some protocols are required. WiFi, Bluetooth, LoRa, GSM, etc are used to communicate far away for sending the status or data of the devices and to receive commands for execution. 
To connect to the internet usually WiFi is used as it is readily available, cheap, good range, secure etc. Bluetooth is used to communicate within short area. 

Protocols

There are many protocols to be used for successful communications. TCP/IP protocols is usually used for sending data to the other networks. But for IOT applications, light weight version of TCP/IP is used which is lwip (light weight internet protocol) as it can be implemented on constrained devices such as microcontrollers which has low processing power and memory. 
HTTP (Hyper Text Transfer Protocol) or HTTPS (Hyper Text Transfer Protocol Secure) is usually used in websites to communicate to servers. But it is not ideal for constrained devices although they can use it, due to its overhead. The ideal or best suited protocol is MQTT (Message Queuing Telemetry Transport) as it does not have such overhead which exist in HTTP. It can be used for device to device communication and machine to human communication as well. It will be discussed in great detail in the upcoming articles/tutorials. 

Web Development For IOT

In IOT the data produced by the node devices is sent to the cloud or web server where data analytics is applied and the meaningful information is sent to the client so that client can be aware of the status if the device/machine and can take actions to be executed remotely.
Web development is consisted of front-end and back-end web development. Server side is called back-end web development and the client side where the website appears and how the information appears is front-end web development. 

Back-End Web Development

For back-end web development there are some programming languages used among them are PHP, Python, JavaScript etc. Python with its extensive library support and framework is growing and adopting very at an incredible rate. It has Django framework for back-end web development and is suitable for data science and machine learning algorithms applied on the data produced by the node devices. NodeJS which is an run time environment for JavaScript is also becoming very popular and can handle requests in an unblocking and asynchronous mode.
Data bases need to be built where data can be stored. MySQL, MangoDB etc can be used for this purpose. 

Front-End Web Development

For front-end web development the basic language to learn is HTML (Hyper Text Markup Language), CSS and JavaScript. HTML provides the structure to your web. CSS helps to add beauty to your web actually it deals with the appearance of the web, how the elements look or appear on the web. JavaScript is the programming language for the web. It adds decision making to the website. There are frameworks available which provides advance functionality to your web such as Angular 2, React JS etc.

These were the basic road map or steps needed to master the IOT. An extensive series of tutorials which would cover topics from FreeRtos with ESP32, would be uploaded quite soon. In those tutorials FreeRtos will be explained in a comprehensive way for beginners. Peripherals of ESP32 will be explored alongwith their programming. Different networking and communication protocols will be implemented in ESP32 with extensive explanation. So stay tuned for upcoming articles/tutorials.