Rapid IoT prototyping with mruby
IoTLT MORIOKA #2
@pandax381
Hello!
‣YAMAMOTO Masaya
‣ @pandax381
‣Work at KLab Inc.
‣ K-Laboratory (R&D dept.)
‣ C programmer
‣ I can network programming a little
‣ OSS Contribution
Now I’m into Hobby Electronics
https://www.youtube.com/watch?v=DkHOJYTbYVk
IoT prototyping
IoT - Internet of Things
+ +
DeviceSensor
(and Motor)
Network
IoT - Internet of Things
Cycle of prototyping
Making
CodingTesting
‣Poor system resource
‣ Processor <= 100MHz
‣ Memory <= 100KB
‣ Strorage <= 1MB
‣Development language
‣ C or similar languages
Bottleneck of prototyping
Bottleneck of prototyping
‣Transferring Flash Image
‣ UART (Serial Port) rate 115,200 bps
1MB => 72.8sec
Firmware
ESP32
ESP32 microcontroller
‣Low-cost and Hi-performance SoC
‣ Wi-Fi & Bluetooth support
‣TELEC Certified !!
‣ Xtensa LX6 Dual-core 240MHz
‣ 520KB SRAM
‣ Rich Peripheral interfaces
‣ I2C, I2S, SPI, SDIO, UART, ADC, DAC

IR, PWM, Temp sensor, Touch sensor …
Development environment of ESP32
‣ESP-IDF (Espressif IoT Development Framework)
‣ Official development environment
‣ FreeRTOS + newlib
‣ Provide Native C API and library
‣Arduino core for the ESP32
‣ Yet another official development environment
‣ Provide Arduino compatible API and library (similar C)
‣ Developable with Arduino IDE
meets
mruby-esp32
‣Port mruby to ESP32
‣ https://github.com/mruby-esp32
mruby-esp32
‣mruby-esp32
‣ mruby standalone application template for ESP32
‣ Original code author is Mr. Carson McDonald.
‣mruby-esp32-app-mirb
‣ Running mirb (Embeddable Interactive Ruby Shell)
‣ Use mruby-esp32
Demo
https://www.youtube.com/watch?v=XIvaMQ7gUAo
mruby-esp32’s mrbgems
‣mruby-esp32-system
‣ System specific library (sleep, SDK version, etc…)
‣mruby-esp32-wifi
‣ Provide Wi-Fi connection setting
‣mruby-io / mruby-socket
‣ Ported to the ESP32 (Support lwIP)
‣mruby-esp32-gpio / mruby-esp32-i2c
‣ Provide GPIO and I2C access (LED, LCD, Sensors…)
Demo
https://www.youtube.com/
watch?v=M_mGSt0bB-4
include ESP32
i2c = I2C.new(I2C::PORT0).init(I2C::MASTER)
p i2c.scan
lcd = ST7032.new(i2c)
until lcd.ready?
System.delay(1000)
end
lcd.init
lcd.print("Hello, world!")
System.delay(3000)
(0..63).each {|c|
lcd.contrast(c)
lcd.print("c=#{c}")
System.delay(100)
}
lcd.contrast(32)
lcd.clear
i2c.deinit
Case Example
http://mruby.sh/201707150753.html
Case Example
http://2017.rubyworld-conf.org/ja/program/
mruby 1.4.0 was released at January 16, 2018
mruby 1.4.0
‣MRB_WITHOUT_FLOAT (Build option)
‣ Remove floating point numbers from mruby
‣ It can running without FPU (and soft-float)
‣ It also easy works in Kernel-space and BareMetal
for more tiny devices…
mruby/c
‣mruby/c is an another implementation of mruby.
‣ Small memory consumption (<40KB)
‣ Limited class libraries
‣ Small size rather than execution speed
https://github.com/mrubyc/mrubyc
Let's Happy Prototyping with mruby!

Rapid IoT prototyping with mruby