Video Summary and Transcription
The Talk covers various experiments with JavaScript and C++, including controlling lights and creating a car control system. The speaker shares his experiences with home automation and the challenges of hiding wires. He explores using JavaScript with Esperino for face recognition and discusses the benefits and limitations of the platform. The Talk concludes with suggestions for using JavaScript in hardware projects and learning opportunities.
1. Introduction to JavaScript and C++ Experiments
Hello, my friends. I'm excited to share some tips and experiments with JavaScript and C++. Software development is not simple, and I'll show you some of my hardware burnouts. Raspberry Pi is like a supercomputer with its own OS, while microcontrollers are smaller and cheaper. They have limited memory but can run on walls and control lights.
Hello, my friends. How's it going, everyone? Going well? I'm so excited. It's been a while since my pandemic and this whole stuff. I'm kind of nervous, but I think this is something like my experience at work at home making my wife crazy at home, so I'm gonna give some tips about it as well, okay?
So I've been speaking about JavaScript, sharing a bit of my knowledge as well. And today I'm gonna show you some content I've been doing. So everything here is already online, so you can take pictures, publish. Please mention the event as well, so it helps us a lot as well. And here I'm gonna show some experiments using both JavaScript and C++. But don't blame me, I'm not a C++ developer, I'm just trying to experiment and actually to make my wife crazy, right? All this talk is just to make her crazy.
Well, we know that software is not just something simple, right? We know that we struggle a lot. I'm not an expert in what I've been doing, this is just experiments. So later on the QA I can show you some burnouts that I did on my hardware. Okay. When I started working with IoT stuff, the first thing I was like, oh, I should use Raspberry Pi for everything. And then I figured, well, it's not actually it, right? So I could use Raspberry and microcontrollers. And I wasn't aware of what does it mean.
Well, to fix this first question, a Raspberry Pi is actually a supercomputer, right? It has its own operating system. You can run games, you can run processing. You can use it for programming as well if you wanted. You can use Linux, Windows, and a lot of other operating systems. And actually, you can expand memory. This is crazy. People are using Node.js inside it to make production apps. I don't recommend it, right? But you can do it as well. Okay. When we go to the microcontroller world, the microcontrollers are a bit smaller, right? We call them like the microservices of hardware. It's like a small unit of processing. You can run on your walls, control your lights, but it's much cheaper, right? You can buy it for $1 sometimes on Aliexpress. Well, as you can see, the whole thing is like 320 kilobytes run, right? JavaScript developer doesn't care much about memory, right? So this was my first struggle, and I'm going to show you later. It's a single core, but we can simulate threads and other things as well.
2. Introduction to Beer Cane Project
But you might have heard of Arduinos as well. This is the Brazilian version. I'm Brazilian, so I brought some of our country as well. I was like, why not make my own assistant? Let's first understand the project. This is my first demo, running inside the beer cane. The whole project was good, but turning on an LED, it's like a hello word on harder, right?
But you might have heard of Arduinos as well. Who have heard about Arduino? So popular, right? So this is the Brazilian version. I'm Brazilian, so I brought some of our country as well, just to show you.
Okay, now I introduce you about what I've been doing or what the difference is for you to get some context. And now I'm going to show you some experiments and some not good things that I've been doing as well. The first stuff I was like, man, Raspberry Pi, people are using Raspberry to create HTTP servers. This is so boring. Curds. I don't care about curds anymore. Creating products and this kind of stuff. I was like, I should do something interesting.
So I like beers. I was like, why not make my own assistant, right? So here I have my beer cane, and there I have a Raspberry Pi. I'm going to show you later how it's working. Let's first understand the project, right? So I could have my beer cane on my main wall. I have a camera right there. And when I see a friend, I will just recognize. And my beer cane will say, oh, welcome home. Or just make some jokes. And that's it. I was like, yeah, let's make it.
Well, this is my first demo. Right here I have a Raspberry Pi, a supercomputer, running inside the beer cane, and on the other side, I have another one to recognize friends, right? Here I have a camera, and I'm using, like, Azure API. I don't know anything about machine learning here. Just using APIs. But then I recognize my friends. And then it sends a message through the beer cane. When it recognizes, it says, oh, welcome back. This is so... Like, the whole project was good, but turning on a LED, it's like a hello word on harder, right? Well, I was like...
3. Creating a Car Control System
I saw a kid in the Purge movie moving a car with a VR glass, and I thought I could do something similar. So I hacked my PS3 controller using Bluetooth and used other microcontrollers to control different aspects. It's working well and helps understand threads in processing different units.
I should do something more interesting, right? I've watched the Purge movie. I saw a kid there moving a car with a VR glass. I was like... I could do something like this. So this was my version. Well, it's an MVP, right? I'm a back end developer. This is a back end of the hardware. So here I just hacked my PS3 controller using the Bluetooth. Right there I have other microcontrollers just controlling the other thing. And here, it's working. Well, this is something good to understand. Like threads, right? Because when you are accelerating, if you try to horn, to press the horn, the car just stops. So you have to make it in different units of processing. But it's working really well right there. Okay.
4. Home Experiments and Automation
I started trying more at home, building wires and interfaces to control the lights and my main door. It was a struggle, but good enough. For those living with someone, be aware of the mess and wires. I moved to a bigger house and wanted to automate turning off the lights at night.
Well, I started trying more at my home. So I built some wires. Now, it starts to mess, right? But here I have some interface right there. When I press a button, the lights will change a bit. But this will control my main door right there. Let's see. Like, the lights are changing. I go faster there. And then I can see that my door is open.
Well, I had a lot of struggles here. And I have a lot of cavemats that we can talk a little bit more later. But yeah. It's good. It's good enough.
But as I said, I have some tips for you who live with someone else. So how many of you are living with someone? Like, parents? Okay. So you should be a bit aware. Because your weekend should look like this. Like, all the main dinner table with a lot of our hardware. A lot of our friends come in there, making a lot of projects. And I think they don't like seeing a lot of wires right there.
Starting about the whole automation thing. I just moved to a bigger house right there. And I figured, at night, I have to walk through my whole home. Like, turning off all the lights. I was like, mmm... I'm a programmer. I'm a lazy person. So let's try doing something.
5. Controlling Light Switch and Adding Sensors
So the whole idea here was to control the light switch using the ESP8266 microcontroller and a relay. I struggled a bit to figure it out, but I managed to make it work. I also added humidity and temperature sensors to create a dashboard. However, hiding the wires was a challenge, and the box to conceal them ended up being more expensive than the entire project. Despite that, my wife approved of the project and even tested it on her Instagram. Throughout this project, I used C++ and found a platform that made uploading code and managing dependencies much easier.
So let's try doing something. So the whole idea here was to control first the light switch. Okay? So I Googled it and I used the ESP8266, like a microcontroller, and I have a relay. Basically, I send one to the relay and it will just cut the energy. If I send zero, it will just keep the energy going on. Yeah. It's very inverted. I struggled a bit to figure it out as well. But yeah. I have one thing for each light, and this is how it should be working.
Well, just turning buttons on and off wasn't enough, so I was about to get some sensors. So I got humidity and temperature sensors, so I can have like a dashboard. And I will start to think how I can make the lights turning on and off just automatically. So this was the MVP. MVP, right? You can see a lot of wires right there. My wife got crazy with me. She was like, no way we're going to do this. But it works, right? When I press the buttons, we can see it working. Just a thing.
Well, I figure out some other problem. The whole thing about IoT is cheap, right? But the most expensive piece was to hide the wires. So this little box was more expensive than the whole project. So I could print it. The whole thing. But I was like, OK, let's make my wife happy. Well, my wife approved. I saw on her Instagram she was testing it. And I was like, oh, QA passed, right? For all of this project, I've been using C++. I'm not a C++ developer, but I found the platform I owe that helps a lot to upload the code, to generate the dependencies and work really well. Right there we can see, like, you can have a YAML file that you can put all of your configurations, your dependencies, and a lot of stuff.
6. Working with Hardware and Node-RED
As a web developer, I found working with hardware to be fascinating. I wrote integration tasks and published my code to the board to ensure the sensors were functioning correctly. I used Node-RED to create flows and an interface to display the temperature, humidity, and other data. I also worked on making the lights turn on and off as part of my MVP.
But for me, a web developer, this was the most interesting thing. Imagine a thing. You are not an expert as me, working with hardware. What if you put some cable in the wrong input? You're never going to know, right? It's already on the wall. How do you know that? So here I wrote some tasks, some integration tasks that I published my code to the board, and then I see all the sensors working fine, and then I can see, really, it's working or not. So this was really hacking for me. And as a developer, I'm a lazy person, right? So I've been using Node-RED, no code in this case. So here you can see all my flows in the left screen for you, right? And in the right screen, we have the results right here. So I'm going to show first the interface. So if you click all the buttons on the switches, you can see on the back end, just changing all of the messages, you can see the temperature, the humidity, and here I'm going to show some flows. Well, when someone presses a button, I'm just showing the logs here, not something like confused, not something hard to make it. But for the weather, I have two JSON properties that I'm converting and just showing on the interface as well. And then in the last one, I'm logging some more data and actually trying to make the first MVP to make the lights turn on and off. But this is just another subject, okay?
7. Automating Tasks and Overengineering
Automating tasks can sometimes take longer than doing them manually. I faced a similar situation when I automated the task of turning on the lights in my main room. However, my wife wasn't too happy with the solution, as she found it easier to just click a button.
You automate something that you could have done in 20 minutes doing two hours, right? So here I was like this is not smart enough. Because I had some buttons, right, and I create another problem. Imagine, I'm going to my main room with my dishes and was like, oh, turn light, right? So I put all the food on the table, I get my phone, I connect to the Wi-Fi, I open the app, I click the button and then the light's on, right? You couldn't imagine my wife, right, she wasn't so happy with it. She was like, oh, it's not easier just to click on the button, right, overengineering at my own house.
8. Recognizing Faces with JavaScript and Esperino
My wife found it inconvenient to click a button to turn on the lights, so I decided to try something new. I used an ultrasonic sensor to detect movement, but it wasn't always accurate. Then I thought, why not try recognizing faces? I used a microcontroller with 5 megabytes of processing power to create a proof of concept. Initially, I struggled with C++, so I switched to JavaScript using Esperino, which allows for easy code uploading over the network. With just 120 flash memory, we can make everything work with JavaScript.
She was like, oh, it's not easier just to click on the button, right, overengineering at my own house. So I was like, okay, let's try doing something. So this is my little brother and we were drawing a POC right there. I'm using here a ultrasonic sensor so it's like a radar, it's just sending signals and getting back. But the problem was, we're developers, right? We know that it's not 100% sure sometimes.
Well, my wife, she's afraid of ghosts. This sensor is just reverberating. So sometimes the lights just turn on. Imagine in the middle of the night, the lights just turn on. Well, I was like, okay, we have power right now. We have processing power right now that we can use. Let's try recognizing faces. So right here I use the microcontroller that not only promises to detect faces, but to recognize that you are you. Man, this is 5 megabytes processing power that can do a lot of stuff. Well, to do my first POC, I wasn't trying to use on the machine because it was C++. I was like, oh my God, this is so messy. C++ is hard, yeah, sure. And here I was just taking pictures, staying to my note read and just scratching some screen here. You can see the video is not that good because I was just posting on the Instagram as I was getting some results. Well, C++ is hard. It's really hard for me that I've never touched C++. I was like, what if we try using JavaScript to reuse my knowledge from the web on the hardware, right? To really feel the power. Well, I found out Esperino. How many of you have heard about Esperino? Ooh, nice. Esperino has a lot of benefits I'm going to show you later. But the first thing is, it's JavaScript. You can drag and drop stuff as well, but you can also upload your code using SSH over the network. So you can have all of the machine connected to the wall, and over the network, you can send signals and upload new code. So this is really, really nice. Right here, one thing that we should care is when we are using microcontrollers, we know that the memory and processing is limited, right? But here, we can see it's just 120 flash that they use to make everything work with JavaScript.
9. Using JavaScript with Esperino
It's like a small, a tiny interpreter that we can use JavaScript inside of it. I found the docs and decided to rewrite everything. However, it didn't work due to memory and processing limitations. Switching to the ESP32 board solved the issue. JavaScript is powerful, and using Esperino makes development easy. The platform has room for improvement, and some features may not work. However, JavaScript offers benefits like not needing to recompile the project every time and the ability to work remotely via SSH.
It's like a small, a tiny interpreter that we can use JavaScript inside of it. Well, I was like, okay, man. Really easy, right? Let's rewrite everything. Just convert everything to JavaScript. Well, I found the docs right there, and on the docs, I was like, okay, let's just use the docs, let's rewrite everything, and then my code was something like this. I had an interval, send the data, receive the data, and sending the light density as well. And then I put this code to my machine.
Well... It doesn't work, right? I just used all the memory and processing, and I was like, oh, my God, I cannot use the JavaScript for it. But I just changed the board to the ESP32, and everything started working again. So this is my final POC for the piece that will go through the wall, and let's make it work. Right here, you can see a lot of logs. We back-end developers love logs, right? We have all the other stuff working right here. But you can see that the camera is not working properly yet, because I haven't finished this project yet.
Well, JavaScript is magic, right? We can use a lot of stuff, and for this one, I really feel the power. So if you want to use Esperino, you can use the interface or the terminal and make everything work so easily. This is not a tutorial, right? I'm just showing some of the challenge. Well, the first challenge, it was meant to work on Esperino devices, so using generic devices might not work well. The platform has a lot to improve, like we have some generic errors, so we should use it more, so we can improve it more. And for me, I felt an imposter when I see that asyncuate doesn't work. So a lot of features is not working on this interpreter, because it's just a small thing, right? Well, and just finally some benefits, right? I think this is the whole thing about this talk. You don't need to recompile the project every time. When I was working with C++ it was like back and forth. I compile, I see errors. I come back, compile, see errors. And on the third time it works. So I was like no. Using JavaScript is much better because you can do it on SSH remotely. And that's pretty much the idea. Helps a lot, minimize your code.
10. Final Thoughts on JavaScript and C++ Experiments
You can use less memory processing. And you can reuse your knowledge in JS. Try adding more sensors, not just moving buttons. Make something smart to make decisions using it as well. Learn JavaScript. All my presentations are on my website. Check out my new course on Node.js streams. Follow me on Twitter and show me your experiments. Thank you so much for having me. Woo! Woo! That was mind-blowing. I love it.
You can use less memory processing. And you can reuse your knowledge in JS. You're a web developer. You can make something to scare your mom. To make your cat better. To play with your friends for you if you don't want to, right?
We are developers. Well, some final words for you. I think this conference is so amazing. It's so nice to be back. The whole thing here is for us just... I know that CRUD pays the bill, right? Making, creating product, creating service. But when we're trying to challenge ourselves, when we're trying to make something for us, when we are seeing a car moving, we can see a lot of new challenges and we can feel that adrenaline, that we're like, oh I'm not sure if it will work. But when it works, it's indescribable, right? And if you are trying to start on this, try adding more sensors, not just moving buttons. Try to make something smart to make decisions using it as well. And actually, learn JavaScript, right? Without Async08, we can back to callbacks. So yeah, it's hard, right? But we're gonna learn a lot of vanilla JavaScript as well.
Well, all my presentations are already on my website if you wanna take a look, everything about Node.js, JavaScript I've been putting there as well. I've actually just released a new course right now. It's about Node.js streams. If you wanna learn the most powerful Node.js feature, go there and see, it's just on the pre-release. And if you wanna take a look at the videos, my website, follow me on Twitter, take some pictures. Show me your experiments on Twitter, please go there. Okay, so thank you so much for having me. Woo! Woo! Thanks a lot, Eric. We're gonna go and keep streaming. Believe. All right. Well, that was mind-blowing. I think you over-engineered. I love it.
Q&A on Learning and HomeKit Support
I can imagine it's fun and challenging. Best way to learn is to search on Google or YouTube. Building is cheaper and more fun. Tried Azure and Node-RED, but wiring takes more time. No idea about HomeKit support.
So, I can imagine that it's a lot of fun to work on that stuff. A bit challenging. First question is from Jen. Oh, it's just a compliment for your wife. Special dedication to your wife who resisted the divorce. You still wearing a ring? Yeah, it's tattooed, right? Oh, tattooed, so you can't get a divorce. So, yeah, smart, smart.
Question from Jaylen. Where is the best place to get started to learn how to implement similar features in my own home? Oh, it's hard, right? It's like Google, it's right. Oh, just before going, let's take a picture with everyone, with the hands to go there, right? Just a second. Should I take it? Yeah, yeah, sure. Let's count to three, and then we make some noise, okay? Five, one, two, three, hey! I'm Brazilian, I have to do this, right? One more time, one more time. One more time. Three, two, one, hey! Well, the best way to learn this is find on Google, right? Or on the YouTube. I tried to find new projects about James Bond on IoT. There's some guys with, like, watches, showing flames and fires on the smartwatch, right? So this is something that we can find a lot of new stuff as well. Yeah.
Question from Brittany Joiner. What made you want to build this when there are already apps and smart lights out there that you can automate these things out of the box? Well, I think the first thing that we should know that we are programmer, right? We learn to make things new. But for me it's the price. I spend, like, one dollar in one microcontroller. If I want to buy, I would pay like $100, $20, right? And we miss all the fun, right? For us to build something and to create a new product is very cheap, right? Don't forget your time is also not free. Yes, yes, but I think it's fun, right? Yeah, yeah. All right.
Question from PiroPiro. Have you ever tried the Arduino IoT Cloud Platform in your projects? No, I've tried Azure a bit. I've tried Node-RED, but for the kind of stuff I've been doing, I spend more time trying to wire the cables than programming or configuring the cloud itself, right? Okay. And the last question from Anonymous. How is the support for HomeKit? Ooh, for HomeKit? For Apple HomeKit. Oh, I have no idea.
Ideas for Assistant Skills and Beer Can Project
I have some ideas for Google Assistant and Alexa skills. On the beer can project, I can install and connect everything to make decisions. Thank you, Eric, for your talk and filling in on short notice. If you want to talk to Eric about home automation, visit the speaker booth.
I have- You just need to write some plugins. Oh. Or maybe a Google- Assistant. Google Assistant skills. Yeah. Some Alexa skills, but hey, that's I guess a whole different project.
No, actually on the beer can that I build, I can install there and make everything to connect it and to make decisions as well. Yeah. Very cool.
Well, I enjoyed your talk really a lot, Eric. So thanks also for filling the spot on such short notice. So thanks a lot, Eric. If you want to talk to Eric, go to the speaker booth and we'll talk about home automation more. Thank you, Eric. Valeu. Thank you.
Comments