Top Related Projects
Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer
Quick Overview
The ESP8266_RTOS_SDK is an official development framework provided by Espressif Systems for the ESP8266 Wi-Fi chip. It offers a real-time operating system (RTOS) environment, allowing developers to create complex IoT applications with multitasking capabilities. The SDK provides a comprehensive set of APIs and libraries for Wi-Fi, networking, and peripheral control.
Pros
- Built-in RTOS support for efficient multitasking and resource management
- Comprehensive documentation and examples for easier development
- Regular updates and active community support
- Seamless integration with Espressif's IoT development ecosystem
Cons
- Steeper learning curve compared to simpler frameworks like Arduino
- Limited compatibility with some third-party libraries designed for non-RTOS environments
- Higher resource consumption compared to bare-metal programming
- Potential complexity for simple projects that don't require RTOS features
Code Examples
- Connecting to Wi-Fi:
#include "esp_wifi.h"
#include "esp_event.h"
void wifi_connect(void)
{
wifi_config_t wifi_config = {
.sta = {
.ssid = "your_ssid",
.password = "your_password",
},
};
esp_wifi_set_mode(WIFI_MODE_STA);
esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config);
esp_wifi_start();
esp_wifi_connect();
}
- Creating a task:
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void my_task(void *pvParameters)
{
while (1) {
printf("Hello from my task!\n");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
void app_main()
{
xTaskCreate(my_task, "my_task", 2048, NULL, 5, NULL);
}
- Reading from ADC:
#include "driver/adc.h"
void read_adc(void)
{
adc_config_t adc_config;
adc_config.mode = ADC_READ_TOUT_MODE;
adc_config.clk_div = 8;
adc_init(&adc_config);
uint16_t adc_value = adc_read();
printf("ADC value: %d\n", adc_value);
}
Getting Started
-
Install ESP8266 RTOS SDK:
git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git
-
Set up environment variables:
export IDF_PATH=/path/to/ESP8266_RTOS_SDK
-
Install dependencies:
python -m pip install --user -r $IDF_PATH/requirements.txt
-
Create a new project:
cp -r $IDF_PATH/examples/get-started/hello_world my_project cd my_project
-
Build and flash:
make menuconfig make flash
Competitor Comparisons
Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Pros of esp-idf
- Supports a wider range of ESP32 series chips, including ESP32-S2, ESP32-C3, and ESP32-S3
- More comprehensive and up-to-date documentation
- Larger community and more frequent updates
Cons of esp-idf
- Steeper learning curve due to more complex architecture
- Requires more resources (memory, processing power) compared to ESP8266_RTOS_SDK
Code Comparison
ESP8266_RTOS_SDK:
#include "esp_wifi.h"
#include "esp_event_loop.h"
void app_main()
{
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
}
esp-idf:
#include "esp_wifi.h"
#include "esp_event.h"
void app_main()
{
esp_netif_init();
esp_event_loop_create_default();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_wifi_init(&cfg);
}
The main difference in the code is that esp-idf requires additional initialization steps for the network interface and event loop, reflecting its more comprehensive approach to system management.
Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips
Pros of esp-open-sdk
- Provides a more customizable and flexible development environment
- Includes a wider range of open-source tools and libraries
- Allows for greater control over the build process and toolchain
Cons of esp-open-sdk
- Requires more setup and configuration compared to the official SDK
- May have less frequent updates and community support
- Potentially less stable due to its community-driven nature
Code Comparison
ESP8266_RTOS_SDK:
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_system.h"
esp-open-sdk:
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_interface.h"
The ESP8266_RTOS_SDK uses FreeRTOS and ESP-IDF specific headers, while esp-open-sdk relies on more low-level ESP8266 headers. This reflects the different approaches of the two SDKs, with ESP8266_RTOS_SDK providing a higher-level abstraction and esp-open-sdk offering more direct access to the hardware.
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Pros of NodeMCU firmware
- Lua scripting support, allowing for easier and faster development
- Rich set of pre-built modules for common IoT tasks
- Active community and extensive documentation
Cons of NodeMCU firmware
- Limited low-level hardware control compared to ESP8266_RTOS_SDK
- Potentially higher memory footprint due to Lua interpreter
- May not be suitable for highly resource-constrained applications
Code comparison
NodeMCU firmware (Lua):
wifi.setmode(wifi.STATION)
wifi.sta.config({ssid="MySSID", pwd="MyPassword"})
mqtt = require("mqtt")
m = mqtt.Client("clientid", 120)
m:connect("broker.example.com", 1883, 0)
ESP8266_RTOS_SDK (C):
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
wifi_config_t wifi_config = {
.sta = {.ssid = "MySSID", .password = "MyPassword"},
};
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
The NodeMCU firmware offers a more concise and readable approach for common tasks, while ESP8266_RTOS_SDK provides more granular control and follows a C-style programming paradigm.
esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer
Pros of esp-link
- Simpler and more focused on WiFi connectivity and MQTT communication
- Easier to set up and configure for basic IoT projects
- Includes a web-based configuration interface
Cons of esp-link
- Less comprehensive and feature-rich compared to ESP8266_RTOS_SDK
- Limited to specific use cases and may not be suitable for complex projects
- Fewer updates and less active development
Code Comparison
ESP8266_RTOS_SDK:
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "nvs_flash.h"
esp-link:
#include "esp8266.h"
#include "mqtt.h"
#include "config.h"
#include "cgiwifi.h"
#include "cgi.h"
The code snippets show that ESP8266_RTOS_SDK uses FreeRTOS and provides more low-level access to ESP8266 features, while esp-link focuses on higher-level abstractions for WiFi and MQTT functionality.
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
ESP8266 RTOS Software Development Kit
** IMPORTANT NOTICE **
About this repository
A new branching model is applied to this repository, which consists of a master branch and release branches.
1. Master branch
The master branch is an integration branch where bug fixes/features are gathered for compiling and functional testing.
2. Release branch
The release branch is where releases are maintained and hot fixes (with names like release/v2.x.x) are added. Please ensure that all your production-related work are tracked with the release branches.
With this new model, we can push out bug fixes more quickly and achieve simpler maintenance.
Roadmap
ESP8266_RTOS_SDK's framework is quite outdated and different from the current esp-idf and we are planning to migrate ESP8266_RTOS_SDK to esp-idf eventually after v2.0.0.
However, we will firstly provide a new version of ESP8266 SDK (ESP8266_RTOS_SDK v3.0), which shares the same framework with esp-idf (esp-idf style), as a work-around, because the multi-CPU architecture is not supported by esp-idf for the time being.
Actions to be taken for ESP8266_RTOS_SDK v3.0 include the following items:
- Modify the framework to esp-idf style
- Restructure some core libraries including Wi-Fi libraries and libmain
- Update some third-party libraries including FreeRTOS, lwIP, mbedTLS, noPoll, libcoap, SPIFFS, cJSON, wolfSSL, etc.
- Update some drivers
- Others
Developing With the ESP8266_RTOS_SDK
Get toolchain
v8.4.0
If you are still using old version SDK(< 3.0), please use toolchain v4.8.5, as following:
Get ESP8266_RTOS_SDK
Besides the toolchain (that contains programs to compile and build the application), you also need ESP8266 specific API / libraries. They are provided by Espressif in ESP8266_RTOS_SDK repository. To get it, open terminal, navigate to the directory you want to put ESP8266_RTOS_SDK, and clone it using git clone
command:
cd ~/esp
git clone https://github.com/espressif/ESP8266_RTOS_SDK.git
ESP8266_RTOS_SDK will be downloaded into ~/esp/ESP8266_RTOS_SDK
.
Setup Path to ESP8266_RTOS_SDK
The toolchain programs access ESP8266_RTOS_SDK using IDF_PATH
environment variable. This variable should be set up on your PC, otherwise projects will not build. Setting may be done manually, each time PC is restarted. Another option is to set up it permanently by defining IDF_PATH
in user profile.
For manually, the command:
export IDF_PATH=~/esp/ESP8266_RTOS_SDK
Start a Project
Now you are ready to prepare your application for ESP8266. To start off quickly, we can use examples/get-started/hello_world
project from examples
directory in SDK.
Once you've found the project you want to work with, change to its directory and you can configure and build it.
Connect
You are almost there. To be able to proceed further, connect ESP8266 board to PC, check under what serial port the board is visible and verify if serial communication works. Note the port number, as it will be required in the next step.
Configuring the Project
Being in terminal window, go to directory of hello_world
application by typing cd ~/esp/ESP8266_RTOS_SDK/examples/get-started/hello_world
. Then start project configuration utility menuconfig
:
cd ~/esp/ESP8266_RTOS_SDK/examples/get-started/hello_world
make menuconfig
In the menu, navigate to Serial flasher config
> Default serial port
to configure the serial port, where project will be loaded to. Confirm selection by pressing enter, save configuration by selecting < Save >
and then exit application by selecting < Exit >
.
Note: On Windows, serial ports have names like COM1. On MacOS, they start with
/dev/cu.
. On Linux, they start with/dev/tty
.
Here are couple of tips on navigation and use of menuconfig
:
- Use up & down arrow keys to navigate the menu.
- Use Enter key to go into a submenu, Escape key to go out or to exit.
- Type
?
to see a help screen. Enter key exits the help screen. - Use Space key, or
Y
andN
keys to enable (Yes) and disable (No) configuration items with checkboxes "[*]
" - Pressing
?
while highlighting a configuration item displays help about that item. - Type
/
to search the configuration items.
Once done configuring, press Escape multiple times to exit and say "Yes" to save the new configuration when prompted.
Compiling the Project
make all
... will compile app based on the config.
Flashing the Project
When make all
finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this from make by running:
make flash
This will flash the entire project (app, bootloader and init data bin) to a new chip. The settings for serial port flashing can be configured with make menuconfig
.
You don't need to run make all
before running make flash
, make flash
will automatically rebuild anything which needs it.
Viewing Serial Output
The make monitor
target uses the idf_monitor tool to display serial output from the ESP32. idf_monitor also has a range of features to decode crash output and interact with the device. Check the documentation page for details.
Exit the monitor by typing Ctrl-].
To flash and monitor output in one pass, you can run:
make flash monitor
Compiling & Flashing Just the App
After the initial flash, you may just want to build and flash just your app, not the bootloader and init data bin:
make app
- build just the app.make app-flash
- flash just the app.
make app-flash
will automatically rebuild the app if it needs it.
(In normal development there's no downside to reflashing the bootloader and init data bin each time, if they haven't changed.)
Note: Recommend to use these 2 commands if you have flashed bootloader and init data bin.
Parallel Builds
ESP8266_RTOS_SDK supports compiling multiple files in parallel, so all of the above commands can be run as make -jN
where N
is the number of parallel make processes to run (generally N should be equal to or one more than the number of CPU cores in your system.)
Multiple make functions can be combined into one. For example: to build the app & bootloader using 5 jobs in parallel, then flash everything, and then display serial output from the ESP32 run:
make -j5 app-flash monitor
Erasing Flash
The make flash
target does not erase the entire flash contents. However it is sometimes useful to set the device back to a totally erased state. To erase the entire flash, run make erase_flash
.
This can be combined with other targets, ie make erase_flash flash
will erase everything and then re-flash the new app, bootloader and init data bin.
Updating ESP8266_RTOS_SDK
After some time of using ESP8266_RTOS_SDK-IDF, you may want to update it to take advantage of new features or bug fixes. The simplest way to do so is by deleting existing ESP8266_RTOS_SDK
folder and cloning it again.
Another solution is to update only what has changed. This method is useful if you have a slow connection to GitHub. To do the update run the following commands::
cd ~/esp/ESP8266_RTOS_SDK
git pull
The git pull
command is fetching and merging changes from ESP8266_RTOS_SDK repository on GitHub.
Top Related Projects
Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer
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