Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Example of mruby on the ESP32

Before you get started you will need to follow the setup documentation from the esp-idf project for your specific operating system.

I have only tested this on macOS and using a certain version of esp-idf. You should try to use more recent version if you have failed.

You will need to recursively clone this project with the recursive flag because it includes mruby as a submodule:

git clone --recursive

The main ruby program can be found in the main/simplest_mrb.rb file. The makefile configuration in main/ and the main entry point source file mruby_main.c will also be of interest if you want to change the name of the ruby script. The examples included are very simple scripts that only print to the ESP32's debug console.

I'm assuming you have followed all the steps in the install documentation and are at least somewhat familiar with the building steps. With that in mind you can do something like the following and see the example running:

make menuconfig
make MRUBY_EXAMPLE=simplest_mrb.rb
make MRUBY_EXAMPLE=simplest_mrb.rb flash monitor

The flag MRUBY_EXAMPLE can be replaced with one of the following:

  • simplest_mrb.rb - Simply prints two strings
  • wifi_example_mrb.rb - An example of connecting to WiFi, you will need to modify this file to include your SSID and password
  • system_mrb.rb - Examples of most of the system APIs

wifi_example_mrb.rb stack overflow

If you experience a stack overflow during execution of the WiFi example, please adjust the stack size on file main/mruby_main.c from 8192 to 32768.

void app_main()
  xTaskCreate(&mruby_task, "mruby_task", 32768, NULL, 5, NULL);

Also adjust the configured stack size using make menuconfig from the default one (which may be either 2048 or 4096) to 32768.

make menuconfig
Component config ---> ESP32-specific ---> Event loop task stack size

References: Issue #11 and mruby-esp32/mruby-socket

The clean command will clean both the ESP32 build and the mruby build:

make clean

There are multiple GEMS that can be turned on and off via the mruby configuration file found in components/mruby_component/esp32_build_config.rb:

  • mruby-esp32-system - ESP32 system calls
  • mruby-esp32-wifi - ESP32 WiFi


mruby application template for ESP32





No releases published
You can’t perform that action at this time.