mruby

Summarized using AI

Build a voice based smart home using Sinatra & mruby/c

Paul Joe George and Do Xuan Thanh • February 20, 2020 • Earth

In this presentation from RubyConf AU 2020, Paul Joe George and Do Xuan Thanh, developers from Monstar Lab in Matsumoto, Japan, explore the creation of a voice-based smart home system utilizing Ruby and mruby/c. They begin by expressing their passion for Ruby beyond traditional applications and their desire to inspire others in the Ruby community towards Internet of Things (IoT) development.

Key Points Discussed:
- Introduction to Mruby/c: Thanh provides an overview of mruby/c, a lightweight Ruby implementation intended for embedded programming, emphasizing its efficient use of resources compared to standard Ruby implementations. For instance, while a basic 'Hello World' program on CRuby utilizes about 16MB of RAM, the same program on mruby operates within approximately 380KB.
- Product Development: The speakers demonstrate how to control home appliances such as lights, TVs, and doors using voice commands. They highlight the simplicity of their product, which connects to home Wi-Fi and processes Alexa commands via a Sinatra web server.
- Communication Protocols: They describe the use of MQTT for lightweight communication between the Sinatra server and the microcontroller, ensuring effective operations. This setup allows users to send voice commands to control devices seamlessly.
- User Experience: The product is designed for intuitive human interaction, making it accessible for people of all ages and technical skills. They emphasize the practicality of developing smart home solutions that can assist even the elderly in managing household tasks through voice commands.
- Challenges and Solutions: The presenters discuss initial challenges, such as debugging difficulties and a lack of comprehensive documentation, but remain committed to making their system user-friendly and effective.

Conclusions/Takeaways:
- The integration of Ruby and mruby allows for an accessible approach to IoT development, encouraging developers to utilize existing programming skills for creating smart home solutions. The innovation not only enhances the functionality of ordinary home appliances but also improves everyday life experiences by enabling voice control. The session concludes with an invitation for audience members to explore these ideas further and engage with questions.

Build a voice based smart home using Sinatra & mruby/c
Paul Joe George and Do Xuan Thanh • February 20, 2020 • Earth

Paul Joe George, Do Xuan Thanh

As of 2019 smart assistants support more than 30 languages and is still learning many more. In the future, it is expected to have a good role in humans life.The usage of smart assistants is rapidly increasing day by day. It can reduce unnecessary effort and time consumption. Nowadays it is not necessary to own a smart device like Alexa Echo or Google Home. A cheaper option is available for free on our phones; it has improved the portability factor as well. And most importantly, training a smart assistant is less complicated so that anyone with basic knowledge in programming can create custom skills and make life much more beautiful. This is an experiment to convert home appliances into smart appliances and normal kids safety door lock to a smart lock by using voice commands. Smart assistants can make the life of everyone better regardless of skill or age. What if old people can control lights, TV, curtain etc using voice commands? It is set to make life more beautiful.

Paul and Thanh are software developers at Monstar Lab Inc. Living in Matz's hometown, where Ruby is more than a programming language. They use Ruby purely for fun as Ruby is fun. Using Ruby only for traditional Ruby on Rails projects never satisfied them. For that reason they decided to experiment using mruby/c - a mini version of Ruby for one-chip microcontroller programming. Currently they are building more and more practical applications to inspire other Ruby lovers to start using Ruby for IoT.

Produced by NDV: https://youtube.com/channel/UCQ7dFBzZGlBvtU2hCecsBBg?sub_confirmation=1

#ruby #rubyconf #rubyconfau #rubyconf_au #rails #programming

Fri Feb 21 14:10:00 2020 at Plenary Room

RubyConf AU 2020

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!
Explore all talks recorded at RubyConf AU 2020
+15