00:00:01.199
Our next speakers, Paul Joe George and Do Xuan Thanh, are developers at Monstar Lab in Matsumoto, Japan. They love Ruby because it's fun. Like many of the speakers in this conference, they weren't satisfied with the work they did in their day-to-day jobs, which mainly involved standard Ruby on Rails applications. To pursue their passion, they started experimenting with mruby/c, a mini version of Ruby for one-chip microcontroller programming, aiming to inspire Ruby enthusiasts to explore new avenues and potentially use Ruby for Internet of Things (IoT) applications.
00:00:40.120
Thank you all for having us. This is my first time outside of Asia, and I want to extend a big thank you to the Ruby community for inviting us. Today, we will discuss how to build a voice-based smart home using Ruby. We will showcase the products we developed to control home appliances with minimal programming and hardware requirements.
00:01:10.230
My name is Paul. I am from India, and I admit I'm terrible at dancing. This is my friend Thanh from Vietnam, who likes to call himself a great photographer, but I haven’t seen many of his photos. We both hail from Matsumoto City, which is home to the national treasure, Matsumoto Castle. How many of you have heard of Matsumoto City? Just a few of you? Well, it is the hometown of Yukihiro Matsumoto, the founder of the Ruby programming language. We feel fortunate to be from a city associated with Ruby, as Ruby is more than just a programming language for us; it’s an emotion.
00:01:43.550
We are developers at Monstar Lab, a Tokyo-based IT company specializing in digital product services including mobile game development, among others, with 26 offices in 15 countries. Our focus on global sourcing is the foundation of all our activities. Now, let's come to the subject of today's talk. We will divide it into two parts: in the first half, my friend Thanh will explain about mruby/c, and in the second half, I will discuss the product we developed. I believe after this talk, you will be able to create a better product than ours.
00:02:58.220
Alright, I will hand it over to my friend Thanh.
00:03:41.110
Thank you, Paul. Good question everyone. I appreciate you being here, especially since my English isn’t the best. I will try to explain things as clearly as possible. First, is anyone here familiar with MVC? No one? Well, if you are familiar with it, I suggest you take a break during this session because I will be discussing some fundamental concepts of mruby/c that you likely already know.
00:04:26.290
Let me introduce myself again. My name is Thanh, and I am a newbie to mruby. To grasp the concept of MVC, it is important to understand mruby. You might have heard some discussion about mruby yesterday, but I will briefly cover what it is. Mruby is a lightweight implementation of Ruby designed specifically for embedded programming, with minimal resource requirements and a focus on portability and extensibility.
00:05:43.229
Using mruby/C allows us to call C functions and achieve compact memory usage, which is crucial for microcontroller programming. In fact, the memory consumption of a simple Hello World application when run on different Ruby implementations shows a striking difference: CRuby takes about 16MB of RAM, while mruby needs only around 380KB. This illustrates the efficiency and lightweight nature of mruby.
00:07:55.690
With mruby, we also introduced MVC as another improvement, offering similar functionality while being even more lightweight. Managing multitasking with mruby requires a real-time operating system, which is essential because we have streamlined this implementation to reduce the need for extensive built-in classes. We will cover practical examples shortly.
00:09:25.970
For example, let’s look at a simple piece of raindown. With the mruby/c compiler, we can use compiled bytecode which then supports various platforms, demonstrating how it can control peripherals like lights or motors. However, we realized that while mruby is powerful, it is essential to layer additional simplicity on top of the underlying C functionalities required for hardware control.
00:10:45.710
Initially, we chose to work with an Arduino board, but later realized that it was overkill for our needs, as we primarily required I2C communication to manage simple devices. We switched to ESP32 as our microcontroller, which is a cost-effective solution for engineers.
00:11:41.060
Let’s dive into the specifics of our product design and communication protocols. The challenges we face include debugging and lack of official documentation, but we are making strides to address these issues.
00:12:27.370
Ultimately, our goal is to use Ruby to control home appliances intuitively. It resonates with the way people interact with their environments, making technology accessible.
00:12:59.480
Now, turning the floor back to Paul so he can explain in detail how our product functions.
00:14:47.280
Thank you, Thanh. Let me give you an overview of the product we developed. It is designed to control lights, TV, and doors using your voice. I'll show you a small demo to illustrate its functionality.
00:15:15.900
[Demo demonstrating voice commands controlling a light switch and other devices visually appears.]
00:15:46.030
So, as you can see, the product is quite simple. It connects to the home network and thanks to Alexa commands, it can perform actions based on predetermined instructions.
00:16:22.431
From a user perspective, if you say something like 'Alexa, turn on the TV,' the command goes to a server, which maps it to the TV on intent, directing it to our Sinatra web server. Here, our Ruby code processes the request and sends a response back to the user confirming the action.
00:17:45.590
On the backend side, we use MQTT for communication between the Sinatra server and the microcontroller. This messaging protocol supports lightweight communication, ensuring efficient operations.
00:19:08.460
Each interaction between the user and the device relies on proper parsing of commands, which the Sinatra application handles efficiently, allowing control over any connected appliance.
00:20:05.359
Moreover, we made sure that our product can work seamlessly in any environment where internet access is available, emphasizing portability and ease of use for both users and developers.
00:20:36.879
In summary, we were able to leverage the power of Ruby, the portability of mruby, and the efficiency of embedded C programming to create an accessible and user-friendly smart home solution. Thank you for your attention! If you have any questions or feedback, feel free to ask.
00:21:00.250
[Audience applause] Thank you, everyone!