MountainWest RubyConf 2013

Summarized using AI

Ruby In My yard!

Corey Woodcox • January 28, 2020 • Earth

In this presentation titled 'Ruby In My Yard!' delivered by Corey Woodcox at MountainWest RubyConf 2013, he explores home automation through the integration of Ruby, Raspberry Pi, and Arduino technology, particularly focusing on creating an automated sprinkler system. Corey begins by sharing his background in software development, emphasizing the importance of automation and how it can simplify everyday tasks.

Key points discussed include:

- Home Automation Concept: Corey expresses his frustration with outdated home automation devices, using his old sprinkler timer as an example of inefficient technology that still requires manual operation.
- Simplifying the Process: Highlighting the desire to streamline operations, Corey discusses how home automation is about avoiding repetitive actions and making systems easier to use, referencing popular gadgets like the Nest thermostat.

- DIY Sprinkler System: The main focus of the talk is on building a cost-effective and efficient sprinkler system that can handle various watering schedules without user intervention. Corey explains the mechanics of a 24V solenoid and how it can replace his clunky old timer.
- Technology Choice: He contrasts the use of Arduino and Raspberry Pi, explaining his preference for the Raspberry Pi due to its broader capabilities and ease of programming with Ruby.

- Live Demonstration: Corey attempts a live demonstration to show the communication between the Raspberry Pi and the sprinkler valves. After some troubleshooting, he successfully opens and closes the valves, showcasing the functionality of his system.
- Components and Resources: He shares details about various components used in his setup, like solid-state relays and GPIO pins, and encourages attendees to explore available resources and materials.

Corey closes by highlighting the immense potential for automation in everyday tasks and encourages continuous exploration of DIY solutions using programming and technology to enhance convenience and efficiency in our lives.

Ruby In My yard!
Corey Woodcox • January 28, 2020 • Earth

Look, I know you love your sprinkler timer, with its endearing little dials and simple, easy-to-use interface, and its killer dot-matrix LCD.
We thought we could do better, and we thought Ruby could help us. With the awesomeness of things like the Raspberry Pi and maybe a little Arduino, who's to say I can't use Ruby to water my lawn, remind me to fertilize, or let me know where I could save a little water?
We'll take you on a quick tour of the automated sprinkler system world and the problems it has, and how we're solving them with Ruby, Raspberry Pi, and about 24V of DC power. We promise not to electrocute you, but we can't guarantee you won't get a little bit wet.

Help us caption & translate this video!

http://amara.org/v/FGbP/

MountainWest RubyConf 2013

00:00:20.760 Hello everyone! My name is Corey Woodcox, and I work for the OC Tanner Company. We have a lot of us here today, and it's awesome. I really like what we do.
00:00:24.880 We utilize Ruby on Rails, automated testing, and we aim for 100% code coverage—because that’s a metric that surely ensures we have no bugs in our code. We also use Angular, Roku, GitHub pull requests, and issues. Last time I checked, we were averaging about 8 to 10 continuous deployments per day, thanks to CircleCI. I had a nice chat with them last night at dinner!
00:00:55.399 We are totally awesome, and as per usual, we are hiring!
00:01:05.920 Before I get started, I want you all to know that I have zero experience in electronics engineering. I have no idea what any of this does. About 20 minutes ago, I don't know if you can smell it in the air still, but there was a distinct scent of an exploded capacitor. That was me; I blew up a capacitor back there. I drove to Radio Shack and bought a new one just in time.
00:01:30.280 So, if you’ve ever heard the expression 'doing it live,' that’s what this is—I really have no idea what I’m doing!
00:01:43.079 So, why did I do this? Home automation is really cool when you think about the electronics we use every day. The thing you probably use the most is probably one of the simplest devices ever invented: the light switch. It has two contacts and is either on or off.
00:01:54.880 And you can replicate that with this little guy right here, called a solid-state relay. It's super simple. I wanted to do something with home automation because I can't remember who said it at dinner last night, but it’s 2013, and I still have to walk through my house to turn off all the lights before I leave. Why has the future left my house behind?
00:02:17.040 I wanted to have some fun setting this up. It’s super easy; I have no idea what I'm doing, and I think I pulled it off. It's incredibly useful. I’ve always wanted to spend a fortune on a home automation system. There was a Disney Channel original movie when I was a kid called 'Smart House,' which had this holographic lady as their maid, and I thought that was the coolest thing ever. How cool would it be to have your Smart House make you breakfast?
00:02:38.000 But really, what it comes down to is that I'm all about automation because I am extraordinarily lazy. I don't like doing things over and over. I had a t-shirt in high school that said, 'Go away before I replace you with a very small shell script.' So, I like it when things are simple, fast, and easy to use.
00:03:02.960 That’s why I use Ruby. I like it when things get out of my way. A great example of this is the Nest device. It’s incredibly cool—it’s easy to use, very simple, and fast. It learns how you like the temperature in your house to be, and they say that the 'Nest moment' is when you walk up to it to change it, and it automatically adjusts for you.
00:03:15.000 That’s truly impressive, and I believe automation like that has a huge place in our lives. We should try to create cool stuff that stays out of the way, doing one thing really well.
00:03:27.199 Now, let’s discuss something from my garage. Right here, I have a timer that was built almost 20 years ago, which runs the sprinklers in my yard. It's clunky; when you turn the knob, it makes a giant clunking sound. It’s probably the scariest thing I’ve ever seen. It’s super annoying because every time the power goes out, it forgets what time it is, and then my sprinklers come on in the middle of the day. It's so slow—in fact, if you’ve ever programmed anything like that, you know that to reset the time when it forgets, you have to hold the plus button down for what feels like forever.
00:05:00.639 Things have certainly improved since then. I visited Home Depot this morning, and the modern version of my timer is still for sale, and it hasn’t really advanced much; it still has knobs and everything!
00:05:06.960 How do I set this thing up? It's really easy—you just need to watch the 10-minute instructional DVD that comes with the system. Some of these are available online. If you want a good laugh, go watch them; they teach you all about how easy it is to set everything up. However, I hate the way this works and how I have to use it.
00:05:32.560 So this winter, after I forgot to winterize my sprinklers, I decided to build something that could manage them for me. I wanted a system that wouldn’t require me to reset the clock all the time and that I could set to run stations more than three times a day. There must be better ways to manage this.
00:06:01.599 I noticed that reasonable defaults would suit most people, which is a general principle with Rails. Not everything should require a connection to a network; I can easily get the time of day. There are around 18,000 different NTP servers in the world, and my device can check for any restrictions on watering times.
00:06:23.560 I also discovered a lot about weather data. The device I am working with is a 24V solenoid. It has a little plunger inside that allows water to flow when the electromagnet pulls it up, which causes the water pressure to push the valve open. It’s dead simple, and so far, mine has been installed for 20 years and still works great.
00:06:48.680 So, let’s wire up an Arduino to make this work. However, I don't want to deal with the Arduino environment because it's mostly C-based. While you can write Ruby and compile it down to the Arduino, I find Ruby a lot more fun. And using Linux dramatically simplifies things, which is why I decided to go with a Raspberry Pi.
00:07:09.960 The great advantage of using a Raspberry Pi is that it's a full-fledged computer running a Unix system. You get native Ruby and can use an NTP connection, so it automatically knows what time it is; it's pretty amazing. You also get UNIX sockets and so much more with Linux without any hassle.
00:07:29.200 However, compiling Ruby takes a long time, but I'm working on optimizing that. I have a build system at home that’s almost ready.
00:07:51.000 Austin Vance, a colleague at Pivotal, gave a talk about Arduino at RubyConf back in October. Arduino is great for small, repetitive tasks because you burn the chip for the specific functions, and it keeps doing those functions as long as it's powered.
00:08:03.920 It's fantastic for automation and regulating inputs and outputs. If you turn on two or three pins on your Raspberry Pi, it can react accordingly, while Arduino has many more GPIO pins available, enabling extensive automation.
00:08:29.199 Sadly, most Arduino projects I’ve seen require a laptop to control everything, which ties you down—the opposite of what I want! Austin made the point that Arduino works best with a connected computer around.
00:08:50.760 But with the Raspberry Pi, you get the full power of a Linux computer that boots right up and allows you to do everything you could ask for in automation.
00:09:08.960 Now, I came across a tweet from Gary Burnhard about two days ago that sparked my interest. It states that we often get excited about software and libraries because we assume they work perfectly, which is not always the case.
00:09:30.080 Unfortunately, I don't have a working example of a Raspberry Pi and Arduino communicating directly yet. However, I do have a functioning example of turning on a valve with the setup I have made.
00:09:40.199 When I set all this up, I thought it'd be neat to blink an LED or something with the Raspberry Pi to showcase everything. But ultimately, I decided to work with a real sprinkler valve that will open and close and actually control water. So we’re going to do that!
00:10:02.640 I pleaded with myself, 'What could possibly go wrong?' I didn't exactly tell Mike what I was planning to do, and I could get into some trouble. You all recognize the meme of Michael Jackson eating popcorn; that felt appropriate given the situation.
00:10:26.640 Now, I have two valves here controlling the hose output. First things first—we need to communicate with this Raspberry Pi.
00:10:38.160 We won’t be doing it over Wi-Fi; I’m smarter than that. Just a little bit of water spilled on the table from my preliminary testing, so let’s see if we can establish a connection.
00:10:52.159 So we’ll just do it live, right? Famous last words! Alright, it came right up, which is fantastic.
00:11:14.440 Last year, I was working on a gem called gpio, which is supposed to handle the differences between Raspberry Pi versions and abstract away some of the operating system interaction. Although I haven’t had the best experience with it, it’s what we’re using today.
00:11:35.120 The interface is quite nice, and I plan on improving it. Let's set up the GPIO output to control the pins.
00:11:48.560 We are going to output to pin seven. Let's see if this works and open the valves!
00:12:02.560 One... That's a good sign; I like this. (Laughter) Now for the second one... Okay, we have water flowing into the bucket, and the valve is closed. It needs to prime for a second because it’s water pressure that actually keeps the valve shut. Let me drain it.
00:12:32.600 When I turn the pin on, we dynamically create control here. Woohoo! Look at how cool this is! It’s so easy, you guys have no idea how simple it is.
00:13:10.320 I have the components I used right here, as well. If you’ve ever been to Adafruit, they have incredible stuff, including wiring harnesses perfect for Raspberry Pi. There's also the Pi Cobbler; it's a printed board with a ribbon cable and pin headers you can solder together. If you get a good soldering iron, you’ll be fine. It’s very straightforward.
00:13:34.480 For switching AC power, I employed a solid-state relay. I can’t remember the exact name for it right now, but it’s basically an optical isolator. This can handle up to 250 volts at 8 amps and can be switched on and off with a mere 3.5 volts, which is incredibly simple. If you follow the instructions, it would take about an hour to set up.
00:14:11.760 The good news is that Raspberry Pis are no longer on backorder, so you can get one shipped to you within a week. However, I’m still building a shopping list for all the components I want to use.
00:14:38.560 Do you guys have any questions for me?
00:19:08.640 Awesome, well...
Explore all talks recorded at MountainWest RubyConf 2013
+28