627

June 14th, 2023 × #electronics#IoT#DIY

Electronics for Beginners

Wes gives an overview of basic electronics concepts like voltage, amperage, microcontrollers, coding, and projects he has built.

or
Topic 0 00:00

Transcript

Wes Bos

Welcome to Syntax, the podcast with the tastiest web development treats out there.

Wes Bos

We have Kind of an interesting show for you today that is web development adjacent.

Wes Bos

I promise there will be some JavaScript in the show, But we're gonna talk about electronics for beginners.

Topic 1 00:23

Talking about electronics for beginners

Wes Bos

Something that is very interesting to a lot of developers, including myself, Is tinkering and fixing and playing with electronic items around the house, so specifically around ready. Working with microcontrollers, but also just the basics of, like, how do how do batteries work? What are the different voltages? You know what's amperages? What are watts? What is GPIO? Sometimes you get into these things and you you start looking at tutorials and you're going, oh, my goodness. Like, I I don't know what any of these things are. And what I found is that once I had with everything, once I had a good base of how electronics work, You're able to pretty much tackle anything, not anything, but you can tackle a lot of DIY projects without rid Get in too deep for a lot of the stuff I'm gonna talk about. You don't even know how to sort or something, which is you just plug in stuff together and and run-in

Scott Tolinski

Code that somebody else wrote. Yeah. I'm really excited because I like, my level of electronic prowess comes in and, like, I can install an outlet or an install light switch.

Topic 2 01:31

Scott is interested in learning more about electronics

Scott Tolinski

I can do very basic things. I I am bad at soldering. I soldered 1. I, I mean, like, a motion controller that used a Wiimote in college that used an IR, like, a custom IR bar that I built. And, like, I had to solder that thing, and it, like, didn't work over and over again because I was just really bad at. I didn't know what I was doing, and I haven't gotten any better at that. So I'm interested to hear a little bit about some of the stuff that you have to say here in general because, I I would consider myself the very much a noob In this regard.

Scott Tolinski

Hey. Before we get started, the west, I did have a a fun little sidebar.

Topic 3 02:17

Tip for using AirTags to track kids

Scott Tolinski

Yeah. I love a sidebar. You know, we were talking just before the show started about Stuff that we had our key chain on our key chain. And I mentioned that all I have is, like, an AirTag and whatever.

Scott Tolinski

I have a nice little tip for you and anyone out there who is a parent. This is a tip from my wife who got it from Instagram from somewhere.

Scott Tolinski

If you're gonna be somewhere where your kids are running rid. Wild, like, we went to some kids' play place for their birthdays recently. Yeah. We pinned AirTags on the kids. What Oh. Revelation.

Scott Tolinski

That was so great. That was a great idea. It works so well. You just pin the little AirTag. You can also we heard from other parents there who had done the same thing that said that rid. You just hit the button to make the sound and say, hey. When it starts beeping, you gotta come to go running. Food. Yep. Yeah. Pavlov. That's,

Wes Bos

rid. That's the the dog starts running when it knows who's a snack.

Wes Bos

Yeah. It's totally. It's actually not a bad idea. I've seen people do it with their dog as well because the. Mhmm. I don't know what the range is for the range is good thing for GPS.

Scott Tolinski

That's actually rid. Good idea to put them on a dog collar. That seems like a great idea.

Wes Bos

We have 1 on our dog, and it's great. It's hilarious because we went to the cottage And I guess the distance between the cottage and the dock is far enough That every time I walked to the dock to look at the water, it says, hey, you forgot your dog. Yeah. I was like, he's he's inside. And I I guess I hadn't, like rid. You're allowed. You can say, like, don't tell me if I leave my items at this residence, and we have that for our home. But at our cottage, Every time I walk to the dock, it's like, oh, you forgot your keys, your AirPods, your dock, and your backpack.

Scott Tolinski

I'm at home.

Topic 4 04:02

Back to electronics discussion

Wes Bos

Sorry for the sidebar, but let's see. Let's get back to our regularly scheduled program. Yeah. It's certainly interesting. So I thought I would talk let's just talk about some of the projects that I've worked on just to give you some context for how these things work. And then we'll get into a bit more of the nitty gritty and how these things work. So rid. My most recent project was a LED backlit mirror for our gym, so I got a massive 6 by 3, mirror and I glued From where? I have a question. Where do you think I got it? Do you think I just went to a store rid. Got it. If I'm gonna guess you, I you you you were walking out, and you saw it on on somebody's,

Scott Tolinski

garage sale, or it was either a garage sale rid purchase or it was a marketplace purchase? Oh, yeah. Even worse, my parents found it in the garbage in front of somebody's house.

Wes Bos

So my parents were just walking by somebody's house, and I guess they were renovating their bathroom, and they just had the mirror sitting out front for free. So they grabbed it and it was the perfect size. Gosh, like $500 to buy a mural that big. I'm very jealous. Yeah. Yeah.

Wes Bos

I just glued some Wood to the back and then I around the entire mirror. So basically, the wood was a couple inches inset to the back of the mirror. And then around that wood, I glued LED strips. And then those LED strips Are called ws 2815bs, which I'll link up the which ones I used. But essentially what they are, they are addressable individually addressable LEDs, meaning that you can turn every single one On and off and change the color of it programmatically.

Topic 5 05:10

Wes' LED mirror project

Wes Bos

It's amazing. Like I didn't write any code. There's this software called WLED that it runs on. Rid. So basically what I did is I got a 12 volt power supply. I got a microcontroller. I'll talk about it in a second. Ran the software on it.

Wes Bos

And now I have this, like, wicked backlit mirror in our gym that you can do anything. Like, one thing I want to do now is use it as a minute timer because my wife does a lot of workouts. Yeah.

Wes Bos

You got to hold it for a minute or 15 seconds. And I was like, how do I rid. Visualize with colors Yes. 15, 30, and 62nd increments.

Scott Tolinski

Yeah. In the last rid 5 seconds. You could have it flashing for the last 5 seconds and then go right. Just the the tail of the last 5 seconds could be flashing. Like, Again, there's Oh, man. 300 LEDs on this thing. I have control over all 300. Question. When when you say you run the software on it, rid. On the microcontroller.

Scott Tolinski

Can you elaborate on what that means to say I've ran the software on the microcontroller?

Wes Bos

This I'll hold it up For you, Scott here. And maybe maybe this will be on YouTube at some point. Okay. This is called an ESP thirty two, And it's very similar to an Arduino. You've probably heard of that. Mhmm. And it has a Wi Fi chip in it. It has a Bluetooth chip in it, and you can run software on So people have written software on it that will it outputs voltages and signals. And we'll talk about what all that is. But So all you have to do is you literally flash the thing in a web browser.

Wes Bos

There's you go to WLED.

Wes Bos

New or whatever the URL is, and it uses web serial to detect a serial interface on this thing. You plug it in via USB, it flashes it with the WLED software, and then it becomes a Wi Fi access point.

Wes Bos

You jump on that. You give it your WiFi password and then it reboots. And then all of a sudden the thing broadcasts on a local domain on your local network

Scott Tolinski

And, you can you get all the software that that controls it all. It's pretty unreal. That's so cool. Yeah. It feels like when I hear about, like, flashing software to a microcontroller, like that makes me very

Wes Bos

uncomfortable for every day because it it doesn't it doesn't sound hard, but it feels hard, you know? Yeah. Rid. Yeah, it it can be hard. But the thing about all the stuff that I talk about today is that this is very much an enthusiast space And the stuff on it is it's kind of like when you you go on YouTube and you search for like smart home stuff. A lot of that stuff is enthusiast, And I think we're developers, so we are more technical than their average enthusiast user.

Wes Bos

So this kind of stuff is pretty like as long as you understand, like, a little bit of networking and IP addresses and whatnot, you can get up and go in and You literally just plug the thing in and it finds it. You know, there's no, like, port mapping or USB serial mapping or weird cables or anything like that.

Scott Tolinski

Rid. And does that something like that become Z Wave, or is it just straight up Wi Fi? So it comes baked in with

Wes Bos

rid. Wi Fi and Bluetooth.

Wes Bos

Okay. And then if you want it to do other To be, man. Other things, you have to get different radios for it. So people extend them, right? So one thing I was looking into is we have a spin bike and the spin bike has Ant, which is or Ant Plus, which is some proprietary Garmin based protocol that it sends data to you can get it sends data to your phone. You can get it's like you can send it to the Peloton app. All kinds of stuff like that, right? So I was like, oh, like, where's the Ant adapter for this type of thing. So, yeah, you can you can get it to work with anything. But generally, WiFi is the best because

Scott Tolinski

rid As long as it's on your Wi Fi network, it'll work all the time. So

Wes Bos

that's the LED lit mirror. That was really fun. I also just did a Bluetooth boom box, which I found.

Topic 6 09:54

Wes' Bluetooth boombox project

Wes Bos

Oh, I don't have it here. It's in the gym right now. But so I found at a yard sale a seventies boombox, like the kind you put, like, a massive tape deck, big speakers on it, you know, like you can record, Has microphone input, all that stuff. And the lady is like a buck. Take it, take it or leave it. 1 of the speakers broken, she said. So The speaker wasn't broken. She just had the the balance knob on it. So I fixed that. I fixed it. I turned the knob.

Wes Bos

The balance knob was rid. Oh, that's a good one. I I was like, okay. Like, I wanna put, like, a Google Home in this thing because I I want to be able to stream my music to it. And I was like, I didn't have an extra Google Home. And and the Google Home stuff, it doesn't have aux out. So you have to, like Yep. It's it's a little involved. I'm going to do it. It's iffy. Yeah, but I was like, you know what? I do have a 12 volt car adapter for Bluetooth.

Wes Bos

That. What it will do is it will take.

Wes Bos

A like if your car has aux in, but no Bluetooth, this was from like 10 years ago when not all cars had Bluetooth, you know. So what you do is you just you plug the thing in the cigarette adapter, you plug the aux aux in and then it gives you a little puck that is Bluetooth. And you can just rid. That that adds Bluetooth to your car. Right? So I had that sitting in a bin somewhere. I hadn't used it in 8 years because all cars have Bluetooth now. So I was like, I wonder If I can put this in the boom box, so I open the boom box, I got my little meter out, I found 12 volts DC, rid.

Wes Bos

And that is so that's 12 volts DC. That will power it.

Wes Bos

And then I made a little, rid. Headphone adapter that and I tapped into before the speaker amplifier.

Wes Bos

And then I Put all the guts inside the battery case because it took like 9 d batteries or something like that.

Wes Bos

And, boom, it's It's Bluetooth enabled. I can turn it on and it works great.

Wes Bos

It gets loud as hell because I inputted the audio before the amplifier of the speaker.

Scott Tolinski

It just just works super well. So it's like a really fun, quick project that I did.

Wes Bos

Other ones real quick. I fixed some traces on our dryer. This is why it's helpful to understand how it works. So I put did I tell this story? I don't know. I don't even know if I know what a trace is. So I put, like, 6 pairs of shoes in the washing machine, and I took them all and I put them in the dryer.

Topic 7 12:04

Wes' project fixing a broken dryer

Wes Bos

And apparently that's too heavy Or a dryer to spin her out.

Wes Bos

So I was like, whatever. It's fine.

Wes Bos

But the thing about motors is if you Tax a motor too much.

Wes Bos

It's going to do 1 of 2 things. It's going to say I'm having trouble turning.

Wes Bos

Give me more energy. This is that's what Amperage is.

Wes Bos

It was pulling too much current.

Wes Bos

And usually Things have fuses in them. The pop. You replace the fuse. You did something you shouldn't have. There was no fuse in this circuit or whatever.

Wes Bos

So I went on YouTube, found a tutorial. This happens to everybody.

Wes Bos

So I just took the logic board off and I looked at it and there's a trace. A trace is Basically a wire that is part of a circuit board.

Wes Bos

So basically, power is going from here to here, right? And That trace had too much power go through it, so the trace melted and then the the whole the whole dryer would not turn on. So we were like, all right, well, I'll I'll try to fix it. Otherwise, we'll go buy a new dryer. You know? Yeah. It's the worst that can happen. At that point, it's already pooched.

Wes Bos

But bitty of YouTube found some guy, rid. 90,000 views. Yeah. Comments of people. Oh, this work perfectly.

Wes Bos

Just soldered a little jumper wire on from before the burn to after the burn.

Wes Bos

Rid. And generally, you don't want to, like, just, like, fix stuff unless you know why it happens.

Scott Tolinski

Yeah. Well, especially with, like, something high voltage,

Wes Bos

you know? Yeah, exactly.

Wes Bos

But luckily, I knew why it happened because I put shoes in the dryer, so I fixed rid And the thing turned right on. It's been chugging away great for 6 months now.

Topic 8 14:06

Wes hacked kids' electric cars

Wes Bos

Built a sprinkler system that auto turns on a pump At our cottage, so it as soon as the sprinkler calls for water, it sends a signal, from the controller. And then I take the signal from the controller rid And, use what's called the relay to turn on the pump. And then the pump starts pumping water from the lake, and that feeds it into the sprinkler system. That was a fun one because it's not like

Scott Tolinski

water is always available, like in the city, right? You have to have water pressure before the sprinklers push it out.

Wes Bos

I've hacked many kids cars. I have at last count, I think 5 or 6 of those little 12 volt cars.

Wes Bos

I've rid. Put juice batteries in new batteries, replaced batteries, put drill batteries in it to make them go faster. Pretty fun stuff. And then I took my I got, like, a knockoff Theragun, a yard sale.

Wes Bos

And the guy's like, oh, it just needs to be charged. I don't know, $5. So I bought it for $5, and the one of the batteries in it was fried.

Topic 9 15:13

Wes converted a massage gun to battery power

Wes Bos

And Working with lithium batteries is not something I am super stoked about because it's they're kind of explode. They're exploding. So it's not something. Rid. Yeah, I don't really mess with that all that much. I have a few things here or there, but it's not worth my doing your hands. Rid. Exactly. So what I did is I just converted it. Unlike AliExpress, you can buy these at DeWalt adapters.

Wes Bos

And I just converted it to rid Run on a DEWALT battery. So now I have a DEWALT powered Theragun, and it works great. It's awesome.

Wes Bos

All right. So let's talk about microcontrollers. I told you about this one, the ESP 32. These things, I'm not lying, are $4.50 per piece on AliExpress.

Wes Bos

Rid. Has Wi Fi in it. And so the way that a microcontroller works is that it's essentially a little computer Where the resources on it are extremely limited. So this is different from like a Raspberry Pi. A Raspberry Pi is literally a tiny little Linux computer.

Wes Bos

You can hook up a monitor to it. You can hook up, networking adapters. Pretty much anything you can hook up to a Linux computer, a Raspberry Pi can do, Right? It's just a small little computer.

Wes Bos

On contrast, an Arduino or an ESP32 are Smaller microcontrollers that only run specific languages on it. So the Arduino has been popular for a long, long time, but it's Sort of recently been upstaged by this one called the ESP32 because it comes default with Wi Fi. You don't need to buy Arduino Wi Fi adapter comes default with Bluetooth.

Topic 10 16:26

Overview of microcontrollers

Wes Bos

It has a button right on it so you can configure the button to do something. Rid. And then basically what it is, it's just a little a little board.

Wes Bos

And then along the sides of the boards are there's 1 for voltage in.

Wes Bos

And generally you power them with usually it's 3, 5 or 12 volts. I'll talk about that in a second.

Wes Bos

And then it has a whole bunch of what are called GPIO general purpose input output.

Wes Bos

And those are the pins that you see when you Google something like an Arduino or ESP32.

Wes Bos

And those pins can output different things. Generally, they're outputting voltage, but they can also output data as well.

Wes Bos

And that's how you control the lights on your Those led lights that I was talking about.

Wes Bos

So you you give your lights a positive and a negative 12 volts. You can get them in 5 as well, and then you give it a data line that is coming from this thing. And the data line is what's sending to the The LED lights and the LED lights, every single one has a tiny little chip in it, and it knows, Okay, when you're sending me the specific data. I know how dim and what color to change to and whether I should be on or off. So So that's what this thing is doing is it's not sending it the voltage. The voltage is you have to get a 12 volt power supplier, get an old computer plug and use that to give it to 12 volts. But the This this case, the

Scott Tolinski

the ESP and the lights both need rid. Twelve volts of power.

Scott Tolinski

Like, they need to be powered separately. The ESP needs

Wes Bos

I believe it is 5 volts.

Wes Bos

Rid. There are some threads that say you can run it on 12 volt, but there's lots of threads of people that Cook them, which is nice because these are $4. You don't have to worry about, oh, man, I crossed some wires and the thing I let the smoke out. Right. Like, if you if you fry the thing, rid. Who cares? It's $4, you know?

Scott Tolinski

So But you do need to power them both. You need to power both. This thing's not sending power. The ESP can be either powered by

Wes Bos

USB or it can be powered by direct voltage in. So it depends you have a number of different ways to be able to right. So what I did with my LED project is actually I used another board that had a Voltage dropper in it. And basically you gave it 12 volts in and then it it had the chips on board to convert the 12 down to 5.

Wes Bos

But then on another project I'm working on, I had a 12 to 12 to 5 volt converter. And that's generally what you have in your Car because your USB is 5 volt. Your car is 12 volt. So somewhere in your car, there is a little thing. You can buy 1 on Amazon and you You connect 2 wires to 12 volts and then it goes through some sort of circuit and converts it into 5 volts because that's what USB power is actually needing.

Wes Bos

So that's microcontrollers.

Wes Bos

There's tons of different microcontrollers out there. But if if you are interested in getting into this right now, rid. Get an ESP 32 almost, if not all, Arduino stuff works with the ESP 32.

Topic 11 20:05

ESP32 microcontroller recommendation

Wes Bos

So all the code examples, Even the Arduino IDE works with it. So there's nothing to really to sweat about there.

Wes Bos

Let's talk about voltages.

Topic 12 20:27

Overview of DC and AC voltage

Wes Bos

So there's 2 types of voltages out there. There's AC and DC. Actually, there's even I listen to a really interesting podcast once about Elevators in San Francisco run on high voltage DC or something like that.

Wes Bos

Interesting kind of an interesting read, but AC and DC AC is what's in the wall at your house. DC is pretty much everything else rid. That needs to run. So your phone, your computer, everything, everything is just taking in AC.

Wes Bos

And sorry, I shouldn't say everything, but most electronics are taking in AC and converting it to DC so it will run. And that's why Every single thing that you plug in has some sort of power brick or it has a wall wart that you need to plug in and you can't just plug in straight voltage. It's because it's Taking the AC, dropping it down to a much lower voltage, and also converting it to a DC signal.

Wes Bos

Rid. Then when you have voltages in DC, there's several different popular voltages out there. Pretty much everything is is standardized, so it's going to be either 3.3 volts, which is the standard voltage of a rid. 18650 battery.

Wes Bos

So if you have a a flashlight or a laptop Or something like that. A lot of times they have these little circle batteries in them. Even most Tesla's out there are running on these. Those cells are 3.3 volts.

Wes Bos

And the reason why a lot of stuff works on 3.3 volts is so that they can they can be powered by a battery or an input.

Wes Bos

Then you get up to 5 volts is USB power, 12 volts.

Wes Bos

Your car is 12 volts. Computer power supplies are 12 volts. Generally, your computer power supply, and if you've built PCs, you probably know this, but a computer power supply will output.

Wes Bos

Rid. It takes in 120 AC from the wall and it will output 12, 5 and 3.3, and different components On your your border are going to need those different voltages.

Wes Bos

But like in my case, remember, I said I needed 12 volts for the boom box.

Wes Bos

Rid. I opened up the boom box and lucky me, there was 12 volts in there because, again, most stuff runs on 5 or 12

Scott Tolinski

volts. So how did you know it was 12 volts?

Wes Bos

So there's a couple of giveaways on the back of The boom box, it said there was an AC in, but then there was also the ability to plug in 12 volts rid directly. So I said, Okay, well, there must be a converter in there or you can plug in your own 12 volts, which is good if you want to Plug directly into your car and have a boom box.

Wes Bos

And then the battery compartment was took 9 d batteries and 9 times the batteries are 1.5 volts. Right. So 90 batteries,

Scott Tolinski

a. K. A. Your entire month's salary.

Scott Tolinski

Do you remember paying for batteries and your disc win? Oh my god. I had a Game Gear, man. That Game Gear took, like, a 1000000000 batteries. Yeah. And then they lasted like an hour.

Wes Bos

Oh, I had a Game Boy, and my parents bought me like this like NiCad Rechargeable pack. Mhmm. And you could you could plug it in the DC port on the side of the Game Boy. Oh, I know exactly what that looks like. Yeah.

Wes Bos

Sprinkler system runs on 24 volt AC, which is kind of odd, but it's not that odd because everything runs on it. So Your thermostat that you get from Ecobee or Nest runs on 24 volts.

Wes Bos

Those wires running up behind your thermostat are carrying 24 volts. Rid. Baseboard heaters, they will they don't run on 24 volts, but the controls to turn them on and off are 24 volts, Your sprinkler system to open and close the water valves need a 24 volt signal sent to them. And then when they when they receive the 24 volts, they open right. There's a little servo on them that goes opens opens up for you. So rid. There also is a lot of items that will handle a range of voltage.

Wes Bos

So I have A floodlight from like, you know, you see like these guys in those big Jeeps and they put those big LED bars or those big spotlights on top of their cars.

Wes Bos

Rid. So those will run, most of them will run if you look at the spec sheet, they say they've run from 20 rid. Down to 5 volts. And that's really cool because if they have a range, you can power them from a number of different things. So in my case, I took a rid. Most people are running it on 12 in a car, but I took them and I powered it with a drill battery. So I hooked up 1 to a DeWalt drill battery, and now I have, like, the brightest flashlight in the world that runs off of a standard dual battery.

Wes Bos

Rid. Next up, amperage in watts. So volts, we just talked about, come in.

Topic 13 25:51

Overview of amperage and watts

Wes Bos

Volts is electrical potential, rid. And amperage is the amount that it that it flows. And that's the old saying is that volts don't kill. It's it's amperage.

Wes Bos

And a really good example of that is, like, a you can lick a 9 volt battery, and you'll laugh at at that. Like, have you ever licked a 9 volt, Got, like, a square one?

Scott Tolinski

I know you can.

Scott Tolinski

You haven't? I I was in a a a band for a long time, and, Anybody who's been in a band knows that you had, like, a lot of guitar pedals, and our guitarist are always looking the battery to check to see their their pedals if their battery is good. And And I was just like, you know what? I don't wanna do that. And, for some reason, I just never have, and I don't know if I ever will. Maybe I will for fun, but the, rid. The spontaneousness of the shock is kinda make me a little anxious. Yeah. Exactly. So you think, okay,

Wes Bos

9 volt, you can lick. So 12 volt on a car, probably fine.

Wes Bos

But how the hell does a 9 volt battery power your guitar amp? Rid. Sorry, 9 volt battery powers your guitar transmitter or pedal, and a 12 volt battery can literally spin an engine over to start it, rid. And the difference between there is amperage, meaning that how much it's actually flowing through the thing. The more amperage that flows through is the more current there is. In my example of the drier I burned up the trace, there was too much amperage being transmitted over The wire size or in my case, the trace.

Wes Bos

The more amperage you have, the thicker the wire you need. That's why your jumper cables From going from 1 car to another are very thick, whereas the wire that plugs in a tiny little stereo, which could also be 12 volts, is absolutely tiny, and if you have wire that is too small for the amount of amperage that can go through it, that is when your rid. Wire will start to melt or heat up because there's too much going through it at once.

Wes Bos

And that is why you need fuses in line. So if you if there's a possibility that too much power is traveling over a wire, then you put a fuse in there. And what will happen is you can get a fuse that says, all right, this is the 5 amp fuse. If there is more than 5 amp traveling through it, the fuse melts and then the flow of power stops before anything worse can happen. So is this why the Technology Connections

Scott Tolinski

Guy says that extension cable should have fuses in them. Exactly. Yeah. So our

Wes Bos

British listeners will probably be laughing.

Wes Bos

Rid. So in Britain, if you open up a plug, I guess a lot of places in the world, if you open up the head of a plug, There's a little fuse in there.

Wes Bos

And the reason behind that is because if there is too much current Traveling over an extension cord or a cord for a kettle or something like that, then that thing can melt. And that's because the wires in your house are properly rated.

Wes Bos

However, an extension cord might not be properly rated enough, so That's why there's all these fires with space heaters. A space heater is going to take 1500 watts, and Watts is the calculation of amperage times volts.

Scott Tolinski

So So if something is high wattage, that means dangerous. Do not touch.

Wes Bos

Correct? Yeah. If if something is high wattage, that means it is rid Moving either some combination of current and watts. So if you think about 1800 watts is a space heater, and that's the max that a circuit a regular circuit breaker in your house can handle, right? And In North America, it's 120 volts. So you have 1800 watts divided by 120 volts. That means that 18 amps is going through the cord.

Wes Bos

So if your wiring in your house can handle 18 sorry, 15 amps, but your extension cord, you might have bought at the dollar store And it can it can't handle 15 amps. And there's nothing in place to stop that in North America from from checking right. The The house is going to say, Hey, it's fine, fine by me. But the extension cord will start to heat up, especially if you go on very long runs as well. The longer the run, the thicker the cord you need as well. There's all these calculations in terms of like how much Should you need over a specific span, you also start to get what's called voltage drop. Like I rid ran a pretty long thing of LEDs, and you have to measure the voltage going in. And then at the very end of the LED string. You have to measure the voltage coming out and you have to do a calculation to say, Okay, I think it's like the 3% voltage drop is fine. So it went down 0.2 volts or something. Okay, that's that's within the safe zone. But if it drops more than that, then, you know, Okay, I need to Do what's called power injection. You have to you have to go somewhere down the line of the LED strip and just inject power in So that the power is not traveling all the way to the end. It just I'm just gonna start halfway and and go down from there. And when you say, like, safe, rid. What's the risk of it not having enough power? The risk of not having enough power is your Circuits like the chips in these things could be running out of voltage that is not safe and the thing could burn out or it could decrease the life of it Or it's very unlikely, but it could melt, right? The traces could melt on it. The LEDs could overheat rid So or the the actual wiring inside of the LED strip could start to get hot and whatnot, so you have to ready. Be extra safe. All the specs on this stuff is like way over what should be safe, and you just have to make sure you follow all of that stuff. And there's tons of really good read. Dreads online about how to calculate how far these things need to go.

Wes Bos

GPIO, I talked about that in rid on these microcontrollers, there are input and output values. It is how you get data in or have data being sent out.

Wes Bos

Rid. Generally, you can buy attachments. So I bought a bunch of little motion detectors And because I want to be able to say when somebody walks in front of these LED lights, turn them on like I'm going to do rid. LED lighting in our master bedroom closet.

Topic 14 32:22

Overview of GPIO pins

Wes Bos

And I want it to be motion detected. As soon as you walk in, I want Turn on. So you for like a dollar, you can buy a tiny little motion detector and then you input those into the GPIO.

Wes Bos

You give it, I think, 5 volts And then and then you it will return to you a signal, and you can say, okay, when this signal goes from Low to high or whatever it is. There's settings for it inside of WLED. You don't have to code anything, then Turn the lights on or turn the lights off. Right. At that point, it's just home assistant. Right. You can just turn things on or off or react to specific events.

Scott Tolinski

Rid. But that's how you get Is this not is this bypassing home assistant so that it's faster or this is still using home assistant? It's actually kinda cool. So WLED

Wes Bos

has its own UI, but then it also publishes to the network.

Wes Bos

So it Home Assistant sees it immediately.

Wes Bos

And it poses everything to what's the protocol MQTT.

Wes Bos

Rid. That's a messaging protocol.

Wes Bos

And basically anything it does, it changes color, it dims, it turns on, it turns off. It sends a message out to the network saying I just did this, and then Home Assistant consumes those MQTT messages, And it can also send them to the thing as well. So whether you want to use WLED's UI or whether you want to use Home assistant. It it doesn't really matter.

Scott Tolinski

Okay. But so the the motion sensors you're getting. Are they connected to this microcontroller?

Wes Bos

Yes. They are connected via GPIO.

Wes Bos

So if you take a look,

Scott Tolinski

yeah, at the back of the I wish I it has all the pins. Yeah. But so so then you have to have, like, wiring for the you either have to, like, keep the microcontroller close to the motion sensors rid Or long enough wiring in that case. Yeah, exactly. Yeah. You so you run

Wes Bos

you would run a wire from The controller to wherever you want it to be and then input it into one of the GPIO pins. And there's Schematics online about which GPIO pins are good for different types of things.

Wes Bos

Like ones was some are good for temperature sensors, Some of them are good for motion sensors. Some of them are good for LED data outputs.

Wes Bos

But yeah, and you can use either what's called a breadboard.

Wes Bos

A breadboard is just a grid of holes where you can plug the microcontroller in And then you can use these little jumper cables that I have here, and the jumper cables will connect one thing to another, or you can literally just solder the sucker together rid and go for it. It's generally better to use connectors, or you can you can solder leads on and use the WAGO connectors that we love just to connect them on and off. I love doing that because it's it's never permanent.

Wes Bos

Never have to unsold or something if you if you goof it up.

Wes Bos

Ready. Next concept here, resistance resistors are kind of an interesting thing. And once I learned what a resistor was, I started seeing them everywhere in life, and it's wild to me how they just work everywhere. So Resistors are used to limit the amount of current or voltage that flows through them. So a really good example I'll give you is My ATV has a little LED light, and the LED light turns on When you put it in reverse and there's if the oil is over temp, one of those turns on and they're all burnt out because I bought a clapped out piece of crap. Rid So I was like, I'll just replace the LED.

Topic 15 36:32

Overview of resistors

Wes Bos

So I, I went and I actually just cracked open some Broken electronic I had because I didn't have LEDs on me at the time.

Wes Bos

I took the led out of it, opened up my my rid. ATV soldered in the LED. I was like, done. Put it in reverse. Boom.

Wes Bos

It exploded And glass went everywhere. I'm so lucky to keep my eyes. So what had happened is LEDs run on, like, 1 volt or 1.2 volts. The different color LEDs run on a different set of voltages. Mhmm. That makes sense. The ATV is 12 volts. So 12 is 12 times bigger than 1.

Wes Bos

So Usually it just burns out, but I I over vaulted it so high that the thing exploded.

Wes Bos

And the answer to that is either You'd buy 12 volt LEDs, which is what the ATV had initially. So I didn't realize that I thought, oh, there's probably a voltage converter in there for me. There wasn't.

Wes Bos

Rid. Or the other the other thing is you just you just solder on resistors in between the power, the 12 volt and the LED, and that will drop the voltage from 12 down to whatever is required. You buy different types of resistors

Scott Tolinski

to drop down as much as you need. So you could think of it as a kind of like A dam for electricity? I mean, a lot of these words really feel like fluid

Wes Bos

dynamics anyways or water. There's a really rid. I would probably defer to some of the YouTube experts in this because there's some, like, trickiness of Is it only letting some electricity through or is it literally dropping the voltage? And then where does the excess voltage go? Sometimes it goes to heat, rid. You know? So I'm not gonna answer that because I don't think I have a good example of of how to describe it. But, yeah, it we can the engineering mindset has a video called

Scott Tolinski

Unraveling the mysteries of resistors that I will link to here because I'm sure that explains a little bit of that. I put LED headlights in our Subaru at one point,

Wes Bos

And they're flickering like crazy. And the reason behind that was because I'm pretty sure they were over bolted. So I had to put a resistor in between those And it would drop down the 12 volt for incandescent down to whatever the LED headlights

Scott Tolinski

required at the time. And it's just a common thing you can buy on Amazon and plug it in before you get there.

Wes Bos

So resistance is measured in ohms, so how much Something is being resisted can be measured in ohms. And what is cool about this is that Resistance is used in a lot of day to day things, so your meat thermometer is using what's called a thermo resistor.

Wes Bos

And you when you put your thermometer in something that is hot, the resistor changes the heat changes the quality rid of the resistor, and it will it will report back less voltage when it is warmer than when it is cooler, And it's kind of cool. So if you're putting 12 volts through a cold resistor, you might get 12 volts out the other end, but then you heat it up. And the more that it heats up, the less voltage that is passing through the resistor. And that's how that's how most thermometers work, which blew my mind To actually learn about That is interesting. And then I also learned that's how scales work.

Wes Bos

If you step on the bathroom scale, rid You are a you're standing on a very thin little resistor.

Wes Bos

And as the resistor bends under your weight, It is letting through less voltage, and there's some sort of correlation between Man. How much Yeah.

Wes Bos

Resistance comes through the thing and how much the person actually weighs.

Wes Bos

So when you're when you stand on the bathroom scale, you're literally just bending a tiny little piece of metal And measuring how much voltage can go in and out of a resistor

Scott Tolinski

blew my mind. Yeah, my scales are resistor because when I when I step on it, it says, no, Please stop.

Scott Tolinski

Alright. That's not that's not real. I just get that out. I'm sorry.

Wes Bos

Oh, that's good. There's all kinds of different resistors out there. And quite honestly, I don't know a whole lot about them, but I think just understanding the basic concepts of them is It's pretty important.

Scott Tolinski

Yeah. Yeah. Cool.

Wes Bos

We by the way, we well, next week, we're having somebody on the show who is going to talk more about Programming these ESP 32 specifically program them with JavaScript, so we'll ask him all of our questions.

Topic 16 41:01

Overview of sensors

Scott Tolinski

Yeah,

Wes Bos

I'm not going to talk about capacitors. That's Capacitors hold.

Wes Bos

They're often used to either hold voltage or to spike up voltage For things that need a lot of them. So that is why when you open a piece of electronics, especially something like Something that has heating elements or air conditioning or something like that. Be careful because even though it's unplugged, capacitors hold energy and you should take a rid. You should wait for them to discharge. I'm not gonna tell you how to discharge them manually.

Wes Bos

Probably not. Good advice. Yeah. I know.

Scott Tolinski

Rid. You know, I had a capacitor blow on one of my powered speakers at some point, and I was like, you you you read the back. It's like opening this Speaker up could result in death. And I was just like, yeah.

Scott Tolinski

I think I'm good. I think I don't need to get in here. Yeah. Yeah.

Wes Bos

Rid sensors. So we talked about the motion sensor. You can pipe all kinds of different sensors into these things, and they all They're all very simple. The sensors themselves generally don't have any a whole lot of of stuff in them, if not anything. So The PIR is sensor is called the motion sensor. Those are really good. A lot of cameras will have those built in. Rid.

Wes Bos

Water moisture sensors are pretty interesting. So the leak detensor sensors that you see, those are not rid. GPIO.

Wes Bos

All those are doing is they have 2 pins, and they send a tiny little bit of voltage through 1 pin. And as soon as the water connects those 2 pins together, because there's water on the ground, then the water will go in the other pin and they'll say,

Scott Tolinski

rid. Somebody connected me. It's like putting a battery into a toy. Right? Oh. Yeah. I'm I'm alive. And then it says there must be a All these things are so simple sometimes when you, like, think There must be some missed like, some fancy technology going in there, and and it's just is the, is it is it connected? Is the circuit connected? If it is, then fire. Yeah.

Scott Tolinski

Have you heard of, millimeter wave sensors? Have you seen these at all? Is that

Wes Bos

How close someone is to something? Well so, like, there's a,

Scott Tolinski

Aqara makes a FP 2 sensor, which is, like, their new one that is, like, not out yet. But it's a millimeter wave radar sensor that is basically a motion or a present sensor, but it's able to Essentially, map out space, not the same way that, like, a LIDAR is or something like that. But Yeah. It's it's a motion sensor where you can pinpoint Down to, like, a layout. If there's motion in this quadrant or this tiny little space or this tiny little space, then fire off using millimeter wave. It's a it's like a new thing. Rid Oh, millimeter wave is not a new thing, but these sensors are new.

Wes Bos

I have I have not seen that. That probably would not directly work with this type of thing because because it's software. Yeah, a lot of software. Yeah, there's probably some sort of computing going on in on the device. Most of these sensors will simply just rid. Return of value. Same with like like another good use is the knob. You could take a knob, and depending on how much you've turned it, It will report those values back to the board, and then it's up to you on the board to actually do what you want with that specific data. Our British listeners are going nuts right now, man. But so I just thought of another thing. So at Christmas, Century sent us these boxes of, like, Christmas gifts. They do it every year. They always have some really cool stuff. And they do one thing. They did this, like, theremin that rid. It makes different sounds based on where your

Scott Tolinski

hand is on top of it. It uses a light center length light sensor specifically to do that where the theremin uses like a radio.

Wes Bos

Oh, yeah. Yeah.

Wes Bos

But so guess what the light sensor is?

Scott Tolinski

Rid. I that's a great question because it looks cool, but I don't know. It's a resistor. I didn't even know this.

Wes Bos

So rid The if you look up photo resistor, the photo resistor will I've heard that word. Detect how and it works with your hand, And it's doing it because the closer you put your hand, the darker it is.

Wes Bos

So.

Wes Bos

The darker it is, the different voltage that it reports, and then you can then pipe that voltage into something else like a it's called the rid. Piezo sensor? Yeah.

Wes Bos

And those will make a noise like.

Wes Bos

I only know that because I had to open our waffle maker and take ours out because it scared the shit out of our dog. He would hit the deck every time because it sounds like a fire, like a smoke alarm when it goes off.

Scott Tolinski

They're annoying.

Wes Bos

Yeah. Anyways, there is there is moisture sensors That you can put in your plants and based on based on how much how moist the soil is, it will conduct a different amount of voltage.

Wes Bos

And then you can use that data to say this is how moist this thing is. So I thought like there's somebody out there that sells a moisture sensor you can plug into these ESP 30 rid and you can just put them in, you know, for $6, you could put 1 in every plant and have Wi Fi based Reporting, you know? Wouldn't that be cool? I think the hardest thing with that would be like getting power to it. Rid. I often wonder if you could put a battery on it and program it to wake up twice a day or something.

Wes Bos

I don't know. Yeah. That's something for the guest. Yeah, right.

Wes Bos

Yeah. Love my my pay grade.

Wes Bos

Relays are another important concept here.

Topic 17 46:49

Overview of relays

Wes Bos

Rid. Relays are little switches that run at low voltage that open up Gates for high voltage.

Wes Bos

So a good example of that is the windshield wipers on your car. So when you turn the windshield wipers on in your car, the little button to turn them on doesn't the power to the The power to the motor of your windshield wiper doesn't go from the battery all the way up to the the stock on your car and then out of the car all the way to the motor. That would be really annoying because those motors need thick wire And you would be wasting a lot of money running thick wire and voltages throughout your car. So what most things in your car are Is they're just tiny, thin little wires that run to buttons, and those buttons run at low voltage. And when you press it, rid. It flips the switch in the relay that says, okay, high voltage.

Wes Bos

I'm on. Now you can go on yourself. So ready. If you look at a relay, there's generally like 5 inputs to it, right? There's a ground and there's input output for the low voltage and input output for rid. The higher voltage and it basically allows you to turn on higher volt. That's how light switches The smart light switches work right. You hear the click when when your smart switch turns on. That's a relay. The low voltage DC Wi Fi chip rid. Is telling the high voltage house wiring

Scott Tolinski

to turn on. Kind of tracks with the JavaScript

Wes Bos

rid. Relay library and its name. Oh, you're right. Oh, interesting. I never even thought about that. I like it.

Wes Bos

Coding microcontroller.

Wes Bos

So I haven't I haven't done rid. Very much coding on these types of things, but I've been sort of digging into it a little bit more myself.

Topic 18 48:37

Coding microcontrollers

Wes Bos

Rid. You can't just run node on these things because there's not enough space on them. There's not enough memory.

Wes Bos

They're not powerful. They run embedded code, right? They run C and other lower level languages like that. And it's quite honestly, it's impressive that Whoever wrote WLED, maybe we should have him on the show.

Wes Bos

Got an entire web server running on it. And I went on like the GitHub. I was like, man, like, Is he running react for this interface because he has a whole it's a whole web UI that's running on this tiny little computer here.

Wes Bos

Rid It's pretty sweet. So what projects are there out there? There's, so QuickJS is an implementation of JavaScript That is meant for a lot of these embedded things.

Wes Bos

Web serial port is another one. Johnny five is kind of an interesting project as well rid. For robotics, it's pretty heavily, heavily Arduino based.

Wes Bos

ESP Home at ESPHome.

Wes Bos

Io Is kind of the spot if you want to make any of these things yourself: temperature sensor, humidity sensor, WiFi based sleep tracker. You want to integrate it into home assistant. That's kind of where you want to go to look at All the different sensors, magnetic sensors, weight sensors, all of that good stuff. I did link up a millimeter wave human presence sensor as well. Oh, awesome.

Topic 19 50:19

Microcontroller coding resources

Wes Bos

There's Esprino, which uses QuickJS, and it looks like they started it For like a watch project, but basically you can run JavaScript on these devices, And that doesn't mean you can npm install every package under the sun. But what it means is that you can interface with all of the APIs.

Wes Bos

Rid. For that hardware in JavaScript, which is nice. I see you can use the sync away. You can use your variables as if you're used to. And Quite honestly, that's kind of what I want is that I want to be able to code this stuff in a language that I'm familiar with and write functions as I'm familiar with them and not like I'm not installing like a Svelte compiler or something like that on this thing. But it Seems like a pretty cool project, and that is what we're gonna have our guest on to talk about the different things that he's he's made with him. That's really interesting. I also found this,

Topic 20 51:16

Rust support for microcontrollers

Scott Tolinski

This is not a, this is something that we talked about briefly in one of the other episodes, but the ESP Rust book, which I I you know, if you're into Rust, rid. There is a nice little ESP Rust Yeah. That's all about what you can do and what you can't do. And, yeah, it even involves a lot of the different ESP units. Rid. So that that is so wild to me that.

Wes Bos

You can run Rust on this type that you can run Rust or JavaScript on these tiny little devices rid.

Wes Bos

And that's actually kind of another little interesting aside is these ESP 30 twos.

Wes Bos

A lot of the smart home stuff, if you open it up, the thermostat that I use to heat my floor in my office, If you open it up and you look at it, it's going to say something like ESP32 on it because these chips are like this entire board is 4.50 ready. Shipped from China. How much does it cost to put a WiFi chip in a smart home device when you're ordering 20,000 of them at once? No, probably even cheaper than that.

Wes Bos

So pretty wild times for that type of stuff. I remember buying an Arduino for $60 or something like that. Yeah. Having my mind blown, you know? Yeah, yeah, totally.

Wes Bos

That is it. I'm not gonna talk about soldering today because quite honestly, You don't need soldering for a lot of stuff. Even with a lot of the LED stuff, it's much easier just to buy these clips If you need to cut them and connect them or you need to cut them and connect it around a corner, it's almost easier just to buy Clips on Amazon. You clip them on both ends and you're good to go. You don't have to solder mess with the mess with any of that stuff. Rid Nice. Cool. Oh, this it's been really interesting. I I think, again, you know, the

Scott Tolinski

applications here in programming besides just, like, what can you do with it? I think the general concepts are are fascinating, and I need to I need to spend some time in this space just as a hobbyist stuff. You know, my my son is getting more into experiments, and he's like, what kind of experiments can we do? Yeah. And it's like, yeah, we've kind of exhausted the basic, volcano type of chemical experiments. And I'm not a chemist, so I don't wanna get too deep there. But it's like, well, what can we do with, rid. Interesting electronics projects. What can we do with

Wes Bos

not necessarily code yet or anything like that? But what can we do here? You know what you To do, and I'm going to do this with my daughters, is I've ordered some of the 5 volt light strips so that I can run both this rid. The ESP32 and the light strips off of the same 5 volt power supply. You probably have a 5 volt power supply Or a old USB thing kicking around somewhere that you can use. And then what you can do is you just take like a foot of led strips and you like turn something into a light in there. Take an old toy, cut a cut a hole in it and stick the light strips inside or find rid turn something into a lamp, you know, and you can show them the whole process of flashing it and connecting the wires and things like that.

Wes Bos

Rid. You could even hook up, like, a little motor to it that spins something around. You know, that's always exciting for kids as well. Yeah.

Scott Tolinski

Yeah. A lot of great ideas here. So check it out.

Wes Bos

Sick pick today. I'm going to sick pick the ESP 32.

Wes Bos

It's Amazing to me that you can get something for so affordable and I don't know for $20, $30, you could get Some LED strips, a couple jumpers, and you're up and running with this type of stuff. It's pretty fun to play with. Okay. Here's what I'm going to sick pick. This is a

Scott Tolinski

kitchen cleaning thing. I may have even sick pick this before, but it's cheap. What it is, it's like a A 2 sided, razor. One side's a, like, a a razor blade, and one side's like a a fake plastic razor blade.

Scott Tolinski

And our counters can use the razor blade without scratching it. You get a bunch of gunk on the counters. You just clean it off. You got a cooktop, any of that stuff. Or the other side, I use the plastic side for cleaning off dishes or anything like that. And it it's literally just, You know, like, you have a paint scraper, but one end is a a a blade and one end is a plastic blade. And I use it every single day of my life to do the dishes. Rid dishes are my chore, and I do, I I do the dishes every day. So I am very happy to use this tool. It comes with, I don't know. It's $10. You could probably find it cheaper on AliExpress or something. But, if you just want a cheaper one out of Amazon,

Wes Bos

anything like that, this little, razor scraper works really well. Oh, I have this exact one. That's amazing. It's it's honestly so good that you have plastic, because so many times there's, Like a sticker you wanna get off of something, but, like, using a razor blade will likely scratch it.

Scott Tolinski

Yeah. Or I don't wanna scratch off my seasoning of my rid. Cast iron? Yeah. You know, the blade is too sharp. It's going to cut in there. You know what?

Wes Bos

Before we sold our last house, I used a razor blade to get all the, like, Stuffed baked on gunk under the stove worked really well. Oh, yeah. Also razor blades work super well on windows that are If you got a window that you can't seem to get clean or has a little bit of fog on it Gunk. Or dirt. Your kids put a sticker paper sticker on there, you can't get it off. Yeah. Yeah.

Scott Tolinski

Rid. Cool. Well, shameless plugs. I'm going to shamelessly plug the syntax Discord. Hop on there and chat. I'll have a link in the show notes. It's a A wonderful place full of a lot of cool people, and everybody's talking code. We're talking about the pod. We're talking about the new website. We're just talking about anything. We're talking about sports and all that stuff. So rid. Check it out. The Syntax Discord.

Wes Bos

I'm going to shamelessly plug I'll shamelessly plug my Instagram. That's where I post a lot of these fiddly things. I post this stuff on Twitter sparingly.

Wes Bos

Like I'll post like 1 photo of something I'm doing on Twitter, but like I'll post literally every single step of what I'm working on in Instagram because it's a great medium and I've recently been trying to go back and Put them into, like, Instagram memories or saved stories, whatever those are called, so that you can go back and see kind of what's going on. I just did the whole gym build into too big. It's 200 photos and videos that I recorded over the months. And if you're into that kind of stuff, Check it on out. I am Wes Boss on Instagram.

Scott Tolinski

Sick. Cool. Well, that's it. Hope you learned something.

Scott Tolinski

Alright. Peace.

Scott Tolinski

Head on over to syntax.fm for a full archive of all of our shows, And don't forget to subscribe in your podcast player or drop a review if you like this show.

Wes Bos

Rid.

Share

Play / pause the audio
Minimize / expand the player
Mute / unmute the audio
Seek backward 30 seconds
Seek forward 30 seconds
Increase playback rate
Decrease playback rate
Show / hide this window