Internet of Things with Ruby

I love Ruby. It’s the language that I feel most comfortable with. I almost use it every day to express my ideas. With Internet of Things at large, the question is why not use Ruby in embedded systems? That’s why we have mruby.

mruby is the lightweight implementation of the Ruby language complying to (part of) the ISO standard. Its syntax is Ruby 1.9 compatible.

Last month, I attended Fukuoka Ruby Night in downtown, San Jose. It was fun, I met Yukihiro Matsumoto aka Matz, had some nice conversations with him and heard bunch of cool stuff about mruby. The outcome of that session for me was to have some hands-on experience with Enzi, an embedded board that runs mruby.

This is how enzi board looks. Similar to Raspberry Pi.

The applications are endless. You can make an app that notices when your plants need to be watered. You can make a house automation system. Most importantly to me, you can code it in Ruby, our good old language.

The API for Enzi can be found here. The reason that I am writing this is the fact that documentations are not mature yet and what we do have right now is in Japanese. If you ever faced Enzi and wanted to work with it, first you need a terminal. Hopefully as programmers, you are gonna have one. You also need the Virtual COM port driver. VPC drivers cause the USB device to appear as an additional COM port available to your computer. Application software can access the USB device in the same way as it would access a standard COM port. If you use mac, download it from here. You will also need CoolTerm (Or you can use ‘screen’). In settings make sure that the right device is selected. In terminal options page, Change the terminal mode to Line Mode and also check Local Echo (Otherwise you will not see the commands when you type them into your device). Upon connection, you should see the prompt.

 — — — — — — — — — — — — — — — — — — — — -
Network Configuration Information
— — — — — — — — — — — — — — — — — — — — -
MAC: 04:CF:25:04:C4:F5
IP :
SN :
GW :
enzi — mruby rapid prototyping platform
Copyright(c) 2013–2014 mruby developers, FUKUOKA CSK CORPORATION & Manycolors, Inc.
Firmware : v1.0.2
enzi start.
initialize mruby…OK
mirb — Embeddable Interactive Ruby Shell
This is a very early version, please test and report errors.
Thanks :)

Voila. You can either type your program in mirb prompt or you can put it in a SD card and load it into the Enzi. Either case, you are going to have lots of fun.

A simple script that turns an LED on and off can be written as:

status = 0
loop do
status ^= 1
digitalWrite(D8, status)

Enzi board is a great tool for quick prototyping of IoT. For me the most interesting part was obtaining a nice experience using mruby.

Software Engineer living in the Bay Area

Software Engineer living in the Bay Area