How to build an IoT project with Mongoose OS

How to build an IoT project with Mongoose OS

An intro to microcontrollers, and how to build an IoT project with Mongoose OS.

How to build an IoT project with Mongoose OS
Image by :

IoT (Internet of Things) is about connecting physical objects ("things") to the Internet. Technically, this is done by attaching a computer to a "thing." A computer is attached in a way that it can read data from the thing and report to the Internet, and also it can receive commands and control the thing's state. 

Usually, the COMPUTER is directly wired to the THING, and the COMPUTER <=> INTERNET connection could be either wired (e.g., Ethernet), or wireless (e.g., Bluetooth, Wi-Fi).

What could the computer be?

Internet of Things

It could be your laptop or desktop computer—both expensive, power hungry, and large. You can hardly use your laptop with your fitness tracker while running.

It could be a small single-board computer like the Raspberry Pi, which costs around US $30, BeagleBone for approximately US $60, Intel Edison for US $70, or other similar devices. These computers usually run Linux. These are suitable for some tasks, like being a gateway device, but again they are quite large, very power hungry, and too expensive to run on things like sensors, wearables, and small appliances.

It could be a microcontroller (also called MCU or micro). The microcontrollers on the market are extremely diverse and designed for various needs. For the IoT, you have available to you a wide range of inexpensive, low-powered, tiny microcontrollers.

The microcontroller

A microcontroller is a small computer on a single silicon chip. To put it simply, it is a small black box with a bunch of wires (pins) sticking out from it. There are pins for powering the microcontroller and pins for attaching external things, such as sensors, actuators, buttons, etc. These pins are called IO (input/output) pins. For example, to create a Wi-Fi Internet button, you need to get a Wi-Fi-enabled microcontroller, get a button, attach the button to the IO pins, and program the microcontroller to send messages to the cloud backend when the button is pressed, as shown:

Wi-Fi-enabled microcontroller

During development, people do not work directly with MCUs because it's hard to wire them. Instead, they use modules and development boards. Those modules make it easy to power the MCU and attach peripherals. I've provided an example of the NodeMCU ESP8266 board, which you can plug it to your laptop easily:

NodeMCU ESP8266

Programming microcontrollers

Microcontrollers do not have much memory and processing power, which is why they are so inexpensive. For example, the Nordic Semiconductor's nRF52 has 64K RAM and 512K flash. A popular ESP8266 has about 40K available RAM, which means you can't run software like Windows, Linux, or Node.js on them. Because these small computers have such limited resources, programming them can't be done with conventional tools and frameworks.

There are many approaches to tackle the MCU development, but generally speaking, it is not easy for a new person to start. One needs to know C/C++ and spend time (sometimes a significant amount) on setting up the programming environment, but tools for simplifying the process are available. One such tool is Mongoose OS, which is an operating system for microcontrollers that makes programming them easy for both newbies and professional developers. With Mongoose OS, the time it takes to set up the programming environment is reduced to a minute or less, thanks to the features it provides, including:

How to build an IoT project with Mongoose OS

First, get one of the supported boards, like the ESP8266 NodeMCU, which you can buy on AliExpress, connect it to your computer, then follow these steps:

Installation of Mongoose OS

  • When the installation is complete, click on "Start prototyping" to switch to the file manager:

Prototyping wizard

  • Click on init.js file, change the message Tick to Hello! and press the "Save and reboot device" button. You'll see a new message in the device log.

This simple flow demonstrates how easy it is to start with the microcontroller development and Mongoose OS.

This two-minute installation how-to video from Mongoose OS covers all these steps.

Find other projects that use Mongoose OS here.

Also, check out how easy it is to build your prototype with the Mongoose OS, the ESP8266, and Seeed Studio Grove sensors.

For a more in-depth introduction, see the Mongoose OS documentation and video tutorials.

Have a question? Ask on our developer forum or send us a message.

About the author

Sergey Lyubka, Cesanta Co-Founder & CTO
Sergey Lyubka - Sergey Lyubka is CTO and Co-Founder of Cesanta. Together with his team, he aims to bring all products online by developing innovative Internet of Things technologies. He believes that if we want to get to 20 billion+ connected devices by 2020, then IoT connectivity needs to be made simple, secure and scalable. Through Mongoose OS he realises this vision.