Code Monkey home page Code Monkey logo

mruby-esp32's Introduction

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 https://github.com/mruby-esp32/mruby-esp32.git

The main ruby program can be found in the main/simplest_mrb.rb file. The makefile configuration in main/component.mk 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()
{
  nvs_flash_init();
  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-esp32's People

Contributors

carsonmcdonald avatar donatoaz avatar pandax381 avatar takahashim avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.