Denko is a Ruby library for microcontrollers and connected peripherals. This implementation runs on mruby, self-contained on a microcontroller. It's an early work-in progress, but many basic features are usable. Right now it only runs on the ESP32 series of microcontrollers. See other implementations if you need more.
This repo contains ESP-IDF projects required to build and flash different ESP32 boards with mruby and Denko.
-
Install ESP-IDF (version 5.1 or higher):
Note: If you used
./install.sh all
when setting up the IDF, and are having issues compiling, try install again, but with your specific chip given. Eg. run./install.sh esp32s3
inside the IDF install directory for the ESP32-S3. -
Recursively clone this repo:
git clone --recursive https://github.com/denko-rb/mruby-denko.git
-
Change directory to the project you want, eg.
esp32-2mb
. -
Edit
main/storage/main.rb
as needed. See examples. -
Buld with:
idf.py build
-
Flash and monitor serial output with:
idf.py -p YOUR_SERIAL_DEVICE flash monitor
-
If there are problems, first try
idf.py fullclean
. If that doesn't work, delete the file and folder shown below, then tryidf.py fullclean
andidf.py build
again.components/mruby_component/esp32_build_config.rb.lock components/mruby_component/mruby/build
Note: All paths are relative to the chosen project's root.
-
Each time you edit
main/storage/main.rb
, you must build and flash again. It's faster after the first build.
Here is the "Hello World" equivalent for microcontrollers. More examples here.
# Use submodules without Denko:: prefix.
include Denko
# Blink built-in LED every half second.
led = LED.new(pin: 2)
loop do
led.on
sleep 0.5
led.off
sleep 0.5
end
Reminder: mruby code goes inmain/storage/main.rb
.
Chip | Build Status | Board Tested | Notes |
---|---|---|---|
ESP32 | 💚 | DOIT ESP32 DevKit V1 | |
ESP32-S2 | 💚 | LOLIN S2 Pico | Native USB |
ESP32-S3 | 💚 | LOLIN S3 V1.0.0 | Native USB |
ESP32-C3 | ❤️ | LOLIN C3 Mini V2.1.0 | Native USB |
ESP32-C2 | ❓ | - | |
ESP32-C6 | ❓ | - | |
ESP32-H2 | ❓ | - |
Dependencies are automatically handled by mruby's build system. These links are for refrence.
- The original CRuby gem runs on any computer and uses a connected (Serial or TCP) microcontroller.
- The Raspberry Pi extension allows the CRuby gem to work with the Raspberry Pi GPIO header.