So we just talked about hardware a lot. We've talked about all the different metrics that you'd use to measure electricity flow, all the different components, how they plug together and things like that. Next, what we're going do is we're going to get into some of the details, we're going to talk about specific components and how they work. To make this more applicable so that we can understand how these things are applied, I'm going to talk about this in the context of a set of use cases. So we're going to talk about a set of real-world use cases that are common, that come up when you build IoT devices. Then I'm going to talk about a set of components that you can use to solve each of these use cases, to give us some intuition on how these products and systems are designed. Suppose you want to build something that uses electricity. Pretty much all IoT devices use electricity in some way. Maybe they need to do something, do some physical movement, or send something, or make something light up, they need electricity to do that. So how do you get electricity into these devices? Let's talk about that. Well, there's different sources that we can use for electrical power, one of which are batteries. So we know how to create these little things that can store electrical charge, they're called batteries. There's lots of different kinds of batteries. They differ in terms of how many volts they produce, in terms of how long they can produce electricity, how many amp hours they work for. Depending on what battery you're using, there's different battery holders that can hold them, plug them in. Another thing you might consider is plugging your device direct right into the grid. If it doesn't need to be mobile, if it's something you mount on a wall or something or an electrical outlet, you just plug it in. There's different components that can change the voltage of electricity. Because if you plug something in the wall, in North America for example it's a 120 volts out of the wall, that might be too much for your device. So there's components that can step down the voltage to something like five volts or whatever your device uses. There's also techniques to get energy from the environment. So there's this technique called energy harvesting. What that is, is that's used for devices where you can't have a battery because the battery wouldn't last long enough, or might be too heavy, or something like that, you can't plug into the grid. So energy harvesting is about what kind of energy can I get from the environment at all. There's things like solar cells, so these are components that take light and transform that light into energy. There's different kinds of solar cells, there's flat ones, there's ones that you can bin in a shape around objects. There's also these things called generators. So a generator is an electrical motor that you've run in reverse. So you have some motion, you can transform that motion into electricity through the use of a generator. There's also things like piezoelectric generators. So what these do is they use any vibrations in the environment and turn those into electricity. So you don't get much electricity out of them. But what these things can do is even things like sound or if you have an engine that's shaking, or a washing machine, or something that's tending to move a lot, it'll transform that motion into electricity. There's also antennas. You can get energy from radio waves. This is how RIFD works, using those sorts of technologies. You can get energy from heat using thermoelectric generators. So all you'll do is you'll build something that maybe it's mounted on a surface that's warm, and you'll put one of these thermoelectric generators on top of it. The heat flow through that generator will create electricity and so on. So these are ways of squeezing electricity out of your environment to continue operating. So those are some different sources of power. Now, what if you actually want to take these sources of power and plug them together and actually build something useful? Well, oftentimes what we need to do is merge different sources of power. We might want to take a source of power and transform its voltage to be a certain level or take multiple sources and use them all at the same time. So how do you combine these different current sources? Well, let's talk about this. As a motivating example, let me use batteries as an example. So suppose you have a battery and the battery is 1.5 volts and it has 1,800 milliamp hours of current inside of it. Then we could use that, but what would happen if we actually had two batteries? So a lot of stuff you buy you have space for multiple batteries in there. What happens if you put two batteries back-to-back in your system? What happens to the electricity coming out of this? Is is still 1.5 volts or do they add up? Is three volts going to come out of this? What happens to the current? Do I still have 1,800 milliamp hours for this entire system of two batteries or does that add up too? Does that turn into 3,600 milliamp hours? So as we take different voltage sources, if you have four batteries, we can talk about the aggregate energy or the aggregate electricity that comes out of them. It turns out that if you have several energy sources and you connect them together in series like this, the voltages add up and the current or the capacity doesn't add up. You might be wondering why that is. If you connect things in series, and the way to think about this is you can think of voltage as falling down steps. Each step is like a voltage level. So if you think of water falling down or maybe you have some balls rolling down a staircase or something like that, the more steps you have, the more voltage you have, the faster they're going to fall down. So if you talk about things connected in series like a series of steps, voltages add up, but it doesn't change the total amount of water coming down or the total number of balls coming down. So that's the way to imagine how connected voltage sources in series works. Another way to connect voltages together is in parallel. So what happens here if I have four batteries and the batteries are all the same, but instead of connecting them in series, I'm connecting them in parallel like this? Well, it turns out in this case, the aggregate system still only produces 1.5 volts of current, but the capacity adds up. So now I have 7,200 milliamp hours of electricity coming out of this circuit. Intuitively, the way to think about this is I have four batteries and they're all pushing the circuit together, but they're pushing in parallel, they're each pushing a smaller amount and collectively driving the circuit if you connect things like this. But since they're pushing a smaller amount, that means they're using less electricity to push, and so they can keep pushing for a longer time. Intuitively, the way to think about this is you have a set of steps in parallel. So you have more balls or water flowing over, but you're limited in terms of how much water can fall out per unit time. So therefore, if you are generating a certain amount of water, you can keep generating that amount of water for longer. So that's an analogy that might be useful to keep in mind when you're thinking about this. But the bottom line is if you connect in series, then you add the voltages, if you connect in parallel, you add the capacities. This is useful for keeping in mind when you design different circuits.So this is one way to change the properties of electrical power that you generate, there's other ways to do that too. There's actually certain components that we know how to design that can change properties of the voltage in the current, and here are four very important ones. So the first one is a transformer, a transformer is something that can take in a certain voltage level and transform it, it can step it up, make it a higher voltage or step it down, make it a lower voltage. Transformers work for alternating current voltage. So that's the electricity that you get out of the wall outlet. It turns out that electricity can oscillates up and down a lot. You wouldn't use a transformer for DC voltage which is the voltage that using typical circuits. The next component is a voltage regulator. So would a voltage regulator does is it takes a voltage source, it keeps it within a certain small range, and that's useful if you have a circuit and the circuit needs to operate effectively, its operate effectively because the law circuits get messed up if the voltage oscillates all over the place, which can happen if you have easy inputs, maybe you have a solar cell, and it starts getting cloudy or if cloud is in front of the sun or you have a battery, and battery starting to get flaky. A voltage regulator can help protect your circuit by keeping it nice clean voltage within a certain range and filtering out noise. Another component is called a buck converter, and what that does is it steps down DC voltage. So you have a certain voltage coming in, it's too high a buck converter move it down. There's also a boost converter, which steps up DC voltage. You have a certain voltage coming in, we need more voltage, it will step it up. So this comes up all the time when you design circuits, because you have a battery or you have a voltage source from the wall. We have components which use different voltages, so in a lot of circuits you'll see some communities that use 3.3 volts, and I said they use 5 volts and so on. Then you'll see these components scattered around the borders, keep the voltage in nice ranges to keep your circuit operating effectively. Another way to change voltage is through a technique called pulse-width modulation, and this is interesting technique because what it does is it doesn't change the voltage by just changing the voltage directly. What it does is it works by rapidly turning on and off the power, you change the duty cycle. How often you remain off to change the voltage level. So you might wonder why you would do this, instead of just changing the voltage and it turns out it's cheaper to design components that change voltage through the use of pulse width modulation. So it's very widely used, if you buy an Arduino some of the analog pins that change the voltage works by using pulse width modulation. So the way it works is suppose you have a light bulb and you went the light bulb to be on with its maximum brightness, you'll just have the voltage all the way up, and then maybe these are says, well, I want the voltage to drop down to be 25 percent of maximum brightness. Well, instead of reducing the voltage down by 25 percent which would require expensive analog circuitry, where you can do is just turn on and off the light really fast, and you could do it with a 25 percent duty cycle. You'd be on for 25 percent of the time and then off 75 percent of the time in, on for 25 percent of the time and off for 75 percent of the time and so on, and there's a question, how fast do you do this? So this is done really really fast on the order of milliseconds or less. So the human eye can't perceive these changes, and then if the user wants a the light to be on more you can increase the duty cycle. So it's on a larger fraction of the time. So you still get all the benefits of saving power, reducing brightness, we also gets cheaper components which are easier to design. So those are some ways to change power and change voltage. We also talked about resistors. So I want talk about those in a little bit more detail. So resistors are these components which resists the flow of current. There useful for a lot of things, they are useful for protecting components from getting too much current, they can be used to actually increase and decrease the voltage as well, and that can be used for measuring things. Because it turns out we know how to make resistors that are sensitive to temperature and sensitive to light, that's what sensors are. Sensors are components that we can sense in the circuit, external phenomena such as light and so on. If you have a resistor, they differ in certain ways and so there's certain metrics associated with resistors. We talked about resistance which is how much they resist current, and if you want to know how much resistance a resistor has you can use the sheet I have over here on the left. So an resistors you may have noticed there's these little colored bands on them. These colored bands actually mean something, you can look up how much resistance they have by reading the bands and putting them together using that chart. So there's resistance, there's also tolerant. So for resistor says, "Hey, you know I have 10 Ohms of resistance. How accurate is that"? We can't build perfect resistor. So tolerance is a you know a plus or minus rating for how accurate the resistance reading is maybe it's 10 Ohms plus or minus 5 percent. So that would be the tolerance. There's also a power rating which is a rating of how much current the resistor can have. If you have a little resistor and you put way too many watts through it it'll short-circuit and allow all the current to go through. There's also maximum voltage, which is how much voltage you can apply to resistor before it shorts out. So those are resistors, there's also things called potentiometers which are variable resistors. So we know how to make resistors, we can make them. So you can have a little knob on them, and you can tune the knob to control how much resistance they have, that's useful for user input. If you have a user and the user is telling the circuit to do something, you can measure how much resistance and potentiometers is generating, and use that to drive certain functions of the circuit. We talked about capacitors, these are devices that can store electrical charge, and they're useful for temporarily holding some charts to drive something like a little tiny battery. They're also useful for smoothing out voltage spikes. So if you have some noisy voltage coming in, those spice can get stuck in a capacitor. So capacitors are useful for smoothing out noise, and it turns out capacitors are also useful for measurement. We can use them to measure things like humidity and pressure and touch and things like that. In the way capacitors work, there's often designed so that there's two metal plates, and there's something called a dielectric in between them where electricity cannot flow between the plates, electricity sort as a charge differential between the two plates, and there's certain metrics that matter for capacitors. There is capacitance which is about how much charge the capacitor can store, there's tolerance which is about how accurate that capacitance rating is, and then there's things like maximum voltage which is how much voltage they can withstand, there's leakage current because it's impossible to build a perfect capacitor and sometimes some current does leak through them, and then there's things like equivalent series resistance, because capacitor is often do have some tiny amount of resistance in them. So all these metrics if you need to know them are going to be listed in the data sheet for the components. We talked about diodes. So diodes are these devices that allow current to go through in one direction, but not the other direction. This is useful for a bunch of things, is useful for protecting your circuits, you'll see diode used a lot when you have a motor. Because what happens is if you spin a DC motor app and start spinning and then if you cut power to it, the motor will actually produce kickback voltage, well send voltage back in the opposite direction. We could fry party your circuit. So what you do is you put a what's called a flyback diode there which can prevent the voltage from going back in the opposite direction, and that protects your circuit. It can also be used to rectify signals. So we talked about AC and DC. So AC is voltage that oscillates up and down over and over which is used in wall outlets. There's also DC voltage which is constant. So if you want to convert AC voltage the DC voltage you can use a diode because it'll prevent the reverse direction of the voltage from being applied into your circuit. In diodes are also useful for measurement, there's lot of sensors that are built out of diodes as well. So when you have a diode, there's a few things you have to be careful about. So there's certain metrics you care about in terms of how much current can go through them and voltage and things like that. All the law of the sea metrics we've talked about already. One tricky thing about diodes though is they're often non-linear components. So there components where the amount of resistance that they have or the amount of current that they allow through increases with voltage. But there's often a breakdown point where if you have more than a certain amount of voltage suddenly then a virtually infinite amount of current can go through them, and that can fry your circuit. So that's shown on the diagram on the left here. If you apply a little bit more voltage and a little bit more voltage. More and more current will go through. But once you reach a certain point the amount of current that can go through is unbounded and you'll have a short circuit. So diodes are often paired with resistors to prevent them from getting overloaded. So there's maximum forward current, how much current can go through in the forward direction. We can also talk about maximum reverse voltage. No current should go through in the reverse direction, but we can't build things perfectly. So if you apply too much voltage in the reverse direction eventually they'll shut down and burnout. Then there's maximum forward voltage which is how much voltage you can apply in the forward direction without them burning out. So these are kind of a set of components that you can use to manipulate electricity, so if you build a device and you want to bring electricity into it, oftentimes you'll need to manipulate properties of that electricity, and these are some components that can help you do that.