Skip to content

denko-rb/mruby-denko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mruby-denko

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.

Installation

  1. 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.

  2. Recursively clone this repo:

    git clone --recursive https://github.com/denko-rb/mruby-denko.git
    
  3. Change directory to the project you want, eg. esp32-2mb.

  4. Edit main/storage/main.rb as needed. See examples.

  5. Buld with: idf.py build

  6. Flash and monitor serial output with: idf.py -p YOUR_SERIAL_DEVICE flash monitor

  7. If there are problems, first try idf.py fullclean. If that doesn't work, delete the file and folder shown below, then try idf.py fullclean and idf.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.

  8. Each time you edit main/storage/main.rb, you must build and flash again. It's faster after the first build.

Examples

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.

Supported Hardware

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

Dependencies are automatically handled by mruby's build system. These links are for refrence.

Other Implementations

  • 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.

About

denko on mruby on microcontrollers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published