mongoose-os
Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
Top Related Projects
Espressif IoT Development Framework. Official development framework for Espressif SoCs.
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Your Gateway to Embedded Software Development Excellence :alien:
Device OS (Firmware) for Particle Devices
Ultra-lightweight JavaScript engine for the Internet of Things.
Quick Overview
Mongoose OS is an open-source operating system for microcontrollers and Internet of Things (IoT) devices. It provides a robust framework for developing firmware with built-in networking capabilities, over-the-air (OTA) updates, and cloud integrations. Mongoose OS supports various hardware platforms and offers a simplified approach to IoT development.
Pros
- Easy-to-use development environment with a web-based UI and command-line tools
- Built-in support for popular cloud platforms like AWS IoT, Google IoT Core, and Azure IoT Hub
- Extensive library of drivers and services for common IoT peripherals and protocols
- Strong focus on security with features like secure boot and encrypted OTA updates
Cons
- Limited community support compared to more mainstream embedded development platforms
- Learning curve for developers not familiar with the Mongoose OS ecosystem
- Some advanced features may require a commercial license
Code Examples
- Blinking an LED:
#include "mgos.h"
static void timer_cb(void *arg) {
mgos_gpio_toggle(LED_PIN);
(void) arg;
}
enum mgos_app_init_result mgos_app_init(void) {
mgos_set_timer(1000, MGOS_TIMER_REPEAT, timer_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}
- Reading a DHT22 sensor:
#include "mgos.h"
#include "mgos_dht.h"
static void dht_timer_cb(void *arg) {
struct mgos_dht *dht = (struct mgos_dht *) arg;
float temp = mgos_dht_get_temp(dht);
float humidity = mgos_dht_get_humidity(dht);
LOG(LL_INFO, ("Temp: %.2f, Humidity: %.2f", temp, humidity));
}
enum mgos_app_init_result mgos_app_init(void) {
struct mgos_dht *dht = mgos_dht_create(5, DHT22);
mgos_set_timer(2000, MGOS_TIMER_REPEAT, dht_timer_cb, dht);
return MGOS_APP_INIT_SUCCESS;
}
- Publishing MQTT messages:
#include "mgos.h"
#include "mgos_mqtt.h"
static void timer_cb(void *arg) {
mgos_mqtt_pub("/test/topic", "Hello, MQTT!", 12, 1, 0);
(void) arg;
}
enum mgos_app_init_result mgos_app_init(void) {
mgos_set_timer(5000, MGOS_TIMER_REPEAT, timer_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}
Getting Started
-
Install Mongoose OS tools:
pip install mos-tool
-
Create a new project:
mos init --arch ESP32 myproject cd myproject
-
Build and flash the firmware:
mos build mos flash
-
Configure Wi-Fi:
mos wifi SSID PASSWORD
-
Monitor device logs:
mos console
Competitor Comparisons
Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Pros of esp-idf
- More comprehensive and lower-level control over ESP32 hardware
- Extensive documentation and official support from Espressif
- Larger community and ecosystem of libraries and tools
Cons of esp-idf
- Steeper learning curve for beginners
- Requires more manual configuration and setup
- Less abstraction, potentially leading to more complex code for simple tasks
Code Comparison
mongoose-os:
mgos_gpio_set_mode(LED_PIN, MGOS_GPIO_MODE_OUTPUT);
mgos_gpio_write(LED_PIN, true);
mgos_msleep(1000);
mgos_gpio_write(LED_PIN, false);
esp-idf:
gpio_pad_select_gpio(LED_PIN);
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
gpio_set_level(LED_PIN, 1);
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(LED_PIN, 0);
Summary
esp-idf offers more control and extensive support but requires more expertise. mongoose-os provides a simpler, more abstracted approach, making it easier for beginners but potentially limiting advanced customization. The choice between them depends on project requirements and developer experience.
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Pros of MicroPython
- Wider community support and more extensive documentation
- Supports a broader range of microcontrollers and development boards
- More lightweight and requires less resources to run
Cons of MicroPython
- Less integrated IoT and cloud connectivity features
- Fewer built-in libraries for advanced networking and security
Code Comparison
MicroPython:
import machine
import time
led = machine.Pin(2, machine.Pin.OUT)
while True:
led.value(not led.value())
time.sleep(1)
Mongoose OS:
load('api_gpio.js');
load('api_timer.js');
let led = GPIO.setup(2, GPIO.MODE_OUTPUT);
Timer.set(1000, true, function() {
GPIO.toggle(led);
}, null);
Summary
MicroPython offers a more Python-like experience and broader hardware support, making it ideal for educational purposes and rapid prototyping. Mongoose OS, on the other hand, provides a more integrated IoT development experience with built-in cloud connectivity and security features. The choice between the two depends on the specific project requirements and the developer's familiarity with Python or JavaScript.
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Pros of NodeMCU Firmware
- Lightweight and efficient, ideal for resource-constrained devices
- Large community support and extensive documentation
- Built-in Lua interpreter for easy scripting and rapid prototyping
Cons of NodeMCU Firmware
- Limited support for advanced networking protocols
- Less frequent updates and maintenance compared to Mongoose OS
- Fewer built-in libraries and modules for complex IoT applications
Code Comparison
NodeMCU Firmware (Lua):
wifi.setmode(wifi.STATION)
wifi.sta.config({ssid="MyNetwork", pwd="password"})
mqtt = require("mqtt")
m = mqtt.Client("clientid", 120)
m:connect("broker.example.com", 1883, 0)
Mongoose OS (JavaScript):
load('api_wifi.js');
load('api_mqtt.js');
WiFi.setup({ssid: 'MyNetwork', pass: 'password'});
MQTT.connect('mqtt://broker.example.com:1883', {client_id: 'clientid'});
Both frameworks provide easy-to-use APIs for common IoT tasks like WiFi configuration and MQTT communication. Mongoose OS offers a more JavaScript-centric approach, while NodeMCU Firmware uses Lua for scripting. Mongoose OS generally provides more abstraction and built-in functionality, while NodeMCU Firmware offers a more lightweight and customizable experience.
Your Gateway to Embedded Software Development Excellence :alien:
Pros of PlatformIO Core
- Supports a wider range of platforms and frameworks
- More extensive library management system
- Larger community and ecosystem
Cons of PlatformIO Core
- Steeper learning curve for beginners
- Can be resource-intensive for larger projects
- Less focus on IoT-specific features
Code Comparison
PlatformIO Core (platformio.ini):
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
Mongoose OS (mos.yml):
author: mongoose-os
description: A Mongoose OS app
version: 1.0
libs:
- origin: https://github.com/mongoose-os-libs/mjs
The code snippets show the configuration files for each project. PlatformIO uses an INI-style format, while Mongoose OS uses YAML. PlatformIO's configuration focuses on specifying the platform, board, and framework, while Mongoose OS includes metadata and library dependencies.
PlatformIO Core offers more flexibility and supports a broader range of development scenarios, making it suitable for various embedded projects. Mongoose OS, on the other hand, is more specialized for IoT applications and provides a simpler setup process for supported devices.
Device OS (Firmware) for Particle Devices
Pros of device-os
- More comprehensive ecosystem with integrated cloud services and hardware support
- Larger community and better documentation for beginners
- Built-in support for over-the-air (OTA) updates
Cons of device-os
- Less flexible for custom hardware configurations
- More resource-intensive, potentially limiting for some low-power applications
- Steeper learning curve for developers familiar with traditional embedded systems
Code Comparison
device-os:
SYSTEM_MODE(AUTOMATIC);
void setup() {
pinMode(D7, OUTPUT);
}
void loop() {
digitalWrite(D7, HIGH);
delay(1000);
digitalWrite(D7, LOW);
delay(1000);
}
mongoose-os:
#include "mgos.h"
static void blink_timer_cb(void *arg) {
static bool s_tick_tock = false;
mgos_gpio_write(mgos_sys_config_get_pins_led(), s_tick_tock);
s_tick_tock = !s_tick_tock;
(void) arg;
}
enum mgos_app_init_result mgos_app_init(void) {
mgos_set_timer(1000, MGOS_TIMER_REPEAT, blink_timer_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}
Both examples demonstrate a simple LED blinking application, showcasing the different approaches and syntax used in each framework.
Ultra-lightweight JavaScript engine for the Internet of Things.
Pros of JerryScript
- Lightweight and efficient JavaScript engine for resource-constrained devices
- Supports a wide range of embedded platforms and architectures
- Highly modular design allows for easy customization and integration
Cons of JerryScript
- Limited built-in IoT and networking capabilities
- Requires more manual configuration and setup for IoT projects
- Smaller ecosystem and community compared to Mongoose OS
Code Comparison
JerryScript example:
#include "jerryscript.h"
int main (void)
{
const jerry_char_t script[] = "print('Hello, World!');";
jerry_init (JERRY_INIT_EMPTY);
jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
jerry_cleanup ();
return 0;
}
Mongoose OS example:
load('api_gpio.js');
load('api_timer.js');
let led = Cfg.get('pins.led');
GPIO.set_mode(led, GPIO.MODE_OUTPUT);
Timer.set(1000, true, function() {
GPIO.toggle(led);
}, null);
The code examples highlight the differences in approach: JerryScript focuses on running JavaScript in a C environment, while Mongoose OS provides a more IoT-centric JavaScript API with built-in modules for common tasks like GPIO control and timers.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Mongoose OS - an IoT Firmware Development Framework
- Over-The-Air firmware updates and remote management - reliable updates with rollback on failures, remote device access infrastructure
- Security - built in flash encryption, crypto chip support, ARM mbedTLS optimized for small memory footprint
- Device management dashboard service
- Supported microcontrollers: CC3220, CC3200, ESP32, ESP8266, STM32F4, STM32L4, STM32F7
- Recommended dev kits: ESP32-DevKitC for AWS IoT, ESP32 Kit for Google IoT Core
- Built-in integration for AWS IoT, Google IoT Core, Microsoft Azure, Adafruit IO, generic MQTT servers
- Code in C or JavaScript
- Ready to go Apps and Libraries
- Embedded JavaScript engine - mJS
Trusted and Recommended By:
- Amazon AWS - Amazon AWS Technology Partner
- Google IoT Core - Mongoose OS is a Google Cloud IoT Core Partner
- IBM Watson IoT - Mongoose OS is a Ready for IBM Watson IoT validated solution
- Microsoft Azure IoT - Mongoose OS is recommended by Microsoft Azure IoT
- Texas Instruments - an official partner of Texas Instruments
- STMicroelectronics - an official partner of STMicroelectronics
- Espressif Systems - an official partner of Espressif Systems
Docs, Support
- Mongoose OS Documentation
- Support Forum - ask your technical questions here
- Video tutorials
- Commercial licensing and support available
Licensing
Mongoose OS is Open Source and dual-licensed:
- Mongoose OS Community Edition - Apache License Version 2.0
- Mongoose OS Enterprise Edition - Commercial License
Community vs Enterprise Edition
Community Edition | Enterprise Edition | |
---|---|---|
License | Apache 2.0 | Commercial - contact us |
Allows to close end-product's source code | Yes | Yes |
Price | Free | Paid, see details |
Source code & functionality | Limited | Full |
Technical support | Community support via Forum and Chat | Commercial support by Mongoose OS development team, see details |
How to contribute
- If you have not done it already, sign Cesanta CLA and send GitHub pull request.
- Make a Pull Request (PR) against this repo. Please follow Google Coding Style. Send PR to one of the core team member:
- Responsibilities of the core team members:
- Review and merge PR submissions
- Create new repos in the https://github.com/mongoose-os-apps and https://github.com/mongoose-os-libs organisations for new app/library contributions
- Create Mongoose OS releases
Top Related Projects
Espressif IoT Development Framework. Official development framework for Espressif SoCs.
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Your Gateway to Embedded Software Development Excellence :alien:
Device OS (Firmware) for Particle Devices
Ultra-lightweight JavaScript engine for the Internet of Things.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot