So today we're going to be talking about IoT Protocols. The idea here is, oftentimes, in IoT you don't just have one device. You instead, what you have is you have a set of devices that are working together to accomplish some sort of objective. They're using a set of distributed algorithms and techniques to work together to actuators collectively sent some sort of environment. What we're going to do today is we're going to start talking about this at a protocols that are used to achieve these sorts of goals. To do this, there's a set of challenges we need to deal with. First, in the context of IoT, you often don't have the luxury of running wires everywhere. You know, if you've got sensors floating in the Arctic Ocean or they're mounted on animals walking around. You hit really run wires everywhere. These devices have to talk without wires and it turns out there's ways to do that. So to become a good IoT Engineer, you've got to learn a little bit of how radio frequency works. How we can kind of sense signals using radio frequency, how radio frequencies propagate how they interact. Next, we're going to learn about how various devices can work together to share a channel. How they can collectively work together to communicate, how they'd make sure they don't overlap with each other when they communicate, and things like that. To do this, we're going to learn about media access control, which is a set of distributed algorithms that are used to collectively share a channel with low power usage. Third, another challenge we have to deal with sometimes is making devices work together when they can't directly see each other. So we need techniques to form distributed meshes, and backbones, and spanning trees, and things like that to allow these devices to communicate, even when they're not directly adjacent. To do that, we're going to learn about mesh routing, which is a set of techniques to allow devices to route across multiple hops, and service discovery to allow them to autonomously discover what services are available in their environment. We're going to be talking about all these, and we're going to start off by talking about radio frequency communications. In particular, we're going to start off by learning about a little bit about some background in terms of what electromagnetism is and what is RF, what is radio frequency? Next, we're going to learn about antenna design. How to choose good antennas for your devices. We're going to learn about signal propagation. So if you haven't IoT deployment and these things are out there in certain environments. How are these wireless signals going to propagate. This can really help you understand how to do a deployment. Then fourth, we're going to learn about modulation. So techniques it's take data and encode it using radio frequencies. So when you design things, you're going to know what sort of modulation techniques you should use for your particular environment or challenge that you're facing. We're going to start off talking about some background in terms of what electromagnetism is and what radio frequencies actually are. I'm going to start off talking about light. So light is something you may have noticed before. People have eyes that can see light. But what is light? Well, light is made up a little particles called photons. But light also has a lot of wavelike property. So when we talk about light, it's helpful to talk about it in the context of waves. There's different kinds of light, and these ways can differ in terms of their frequency, and our eyes can actually kind of pick up this frequency. So light is oscillating and how fast it's oscillating we can pick up on using our eyes and our eyes recognize that as color. So if we see a certain color, the more red it is, the lower the frequency light is oscillating slower, and the higher frequency it is, light is oscillating faster. So it turns out that there's also light that we can't see, that's beyond this spectrum. So if we take red, and we make it more red, we end up with a color called infrared, which is a lower frequency light than red. If we take blue, and we increase the frequency, we make it more and more blue. We get a color called ultraviolet. So ultraviolet is higher frequency than blue, and we can keep going. So if we keep going out, there's a whole spectrum of colors that we can't see. We can only see a very narrow range of it called the visible spectrum. When we talk about this spectrum, this electromagnetic spectrum, we can talk about how fast this light is oscillating. So in that lower axis I have the frequency, how many waves per second the light is oscillating at. You can see the visible spectrum is about 10 to 14th, 10 to 15th waves per second. We can also talk about the distance between the waves. We can talk about the distance between two peaks of these waves. This is called the wavelength, and you see visible light is on the order of 10 to the negative six meters or about a micrometer. So it turns out we give names to these different kinds of light or the visible range ultraviolet, infrared. There's other parts of light too. If we go past ultraviolet, we get what are called X-rays. There's two kinds of X-rays. They're soft X-rays and hard X-rays. Soft X-rays are X-rays that aren't as powerful. They're used in doctors offices if you want to look inside a person and see the bones. There's also hard X-rays which are more powerful, they oscillate faster. That's what they use an airport scanners, if they went to look into luggage because I have to pierce through the hard plastic coating of your luggage. If we go past X-rays, the gamma rays. Now we could also talk about the other direction too. If we have infrared, and we slowed down the frequency, we get a color called microwaves. So microwaves are a lower frequency than infrared, and so on. So we can talk about these wavelengths, and it might be helpful to think about these wavelengths because later on we're going to be talking about how signals propagate and how they interact with devices. It's going to become important how far apart the waves are, because this defines things like how you space your antenna is and where you place your devices and things like that. So to help you visualize that, I'm going to put some images here. So you can get a sense of how big the wavelength is for these different kinds of light. So you see the visible spectrum is about the size of a bacteria, and this is also why it when you buy a microscope and you're kind of looking at things in there. You can see the cells, and you can see bacteria but you can't see things smaller than that. You can't really see viruses. That's because the wavelength of visible light is is bigger than the smaller things. So you can't use that to see those things. We can use light to see all the other things over there. Whereas microwaves, the wavelength is about the size of a bee. In infrared it's about the size of a cell and so on. So this whole spectrum is called the electromagnetic spectrum. So one question is, can we use the electromagnetic spectrum to communicate? One observation is that we can do that. We can use the electromagnetic spectrum to send information. We can encode our information by sending an EM source and then varying properties of it. You know, we might use pulses like maybe we turned the light on for a one and turn it off for a zero. Or maybe we vary the color. We make the color red for a one and green for a zero. So you can take EM and vary properties of it to send information. So then the question is, what frequency should we use to do this? What baseline frequency should we use? So we start with green and modulator on green or start with red or something else entirely? Should we use microwaves or infrared. What should we use? Well, this is actually an important question because EM radiation acts very differently at different wavelengths. Higher frequencies of EM are more dangerous to humans that can cause cancer, cause problems like that. Another important issue is that high and low frequencies tend to go through objects. If we have infrared or optical or UV those tend to bounce off of objects. So if you want to send information through walls or through water or things like that. You don't want to use IRR or optical or UV, because sometimes these things can be reflected or refracted by objects. Where a high and low frequencies tend to either pierce through objects or go round objects or things like that. Another thing to consider, when choosing a baseline frequency is that, lower and middle frequencies are easier to make with circuits. If you make a circuit and you want to do a really, really high frequency, you have to make that circuit ultra precise because you have to modulate that signal very precisely. Whereas lower middle frequencies are easier to do with cheap circuits. So if we use lower frequencies, we can get away with cheaper electronics. So if we look back at this electromagnetic spectrum, we're choosing what sort of wavelength to use. We have a bunch of different options. We probably don't want the really high frequencies because those are harmful to humans. The lower ones are more attractive. So what we do is we kind of use the lower frequencies, and in fact, it's tempting to use lower than microwaves. There are frequencies lower than microwaves. We call these radio waves. Radio frequency is between three kilohertz and 300 gigahertz. It's a very nice range for communication, very low frequency. So you get cheap electronics, safety use, good propagation characteristics as it goes through objects very easily. So when we design systems, when we design IoT systems and wireless systems, we use stuff in this region. We definitely use radio waves. For higher bandwidth communications or communications in certain environments that require it. We use microwaves and infrared as well, and occasionally, we'll use visible light as well. But we very rarely use anything above that. So then the question is, how can we generate EM waves? Well, we need some way to generate them in a controllable way, because we got to send data using them. So we need to send them a certain in a very specific frequencies, with certain patterns to encode the data. So one thing we can do which turns out to help a lot is we can make note of a certain physical property of electricity which we discussed before, and that is that electricity and a wire produces an electromagnetic field. So if you've taken any physics, you might know this already. If I have a wire and I run electricity through it in a certain direction that induces a magnetic field around it. This follows the right-hand rule. If my current goes in a certain direction, my fingers will show the direction of the magnetic field. So one thing I can do is, I can take my wire and I can send pulses of current through it and that will induce a magnetic field that propagates beyond the wire. Then what I can do is I can take another wire and I could put it next to the first wire, and the other thing we note is that if you have a magnetic field, that in turn induces current. So current modulating in the first wire will induce a modulated current in the second wire. This can be bad in some situations, the context to phone networks or wired networks, you might not want this. This can mean cross-talk. Signals from one wire can disrupt communications in another wire. But this is great for wireless communications because this is exactly what we want. You modulate data in one wire and it appears in another wire. So if we're doing this intentionally with wires, we call these wires antennas and we can place them at a distance because the magnetic field will propagate at a long distance. Now, one question is how you structure these wires. You could just have a wire, just hanging out, it's nothing because you can't really make electricity go through a wireless hanging out, it's nothing. So one thing you could do is you take a wire and run current back and forth through it. You could do that but one problem is how do you structure that wire. So one thing you do is take the wire and maybe like curve it up. So the current goes up and down. That doesn't work either because current in one direction produces a magnetic field that opposes the one in the other direction. So they'll cancel out. So instead, there is a particular design of antennas called a dipole. What a dipole is, is you take your wire and then you bend it outwards so that the current goes back and forth in a parallel way, and you drive current flow through that wire using a circuit. This produces a magnetic field that emanates out in a certain direction and it's actually polarized. The magnetic field emanates out parallel to the wire. Then the problem becomes a lot simpler now. What we can do is, if we want to send data, we can change the modulation approach that we're using. If we could use that to propagate information to the other wire, we can place another wire further out and then have that information propagate out. So then the question is, how do we design circuitry to generate this modulated electricity? Well, it turns out we have ways to do that as well. We talked about how you can make electrical components that can manipulate electricity. We talked about these in the context of DC current, current that's fixed or voltage that's fixed at a certain level. It turns out that these components we talked about also worked perfectly fine if the electricity going through them is being modulated. Even if it's being modulated fast at RF frequencies. So what we can do is, we can design circuits where the electricity flowing through them is being modulated at RF frequencies. These circuits are called RF circuits. What we're going to do is we're going to take these components. We're going to assemble them together into something called an RF transmitter. So an RF transmitter is a particular kind of circuit that transmits data. It takes data as input and produces as output a fluctuating magnetic field that propagates out and can be received by a receiver further away. So we have an RF transmitter architecture. What this architecture is going to do is it's going to take data, it's going to take a sequence of ones and zeros. It's going to produce a modulating magnetic field which can be picked up by a remote antenna, and this RF transmitter architecture looks like this. There's a series of components. It takes its input, the digital information, and passes it through a modulator unit. What that modulator unit does is, it takes the data and encodes it in an analog fashion. It turns out one very efficient way to do this is to use something called a carrier frequency. So instead of just sending ones and zeros using analog voltage levels, what we're going to do is, we're going to have a baseline oscillating pattern. We're going to have a sine wave that goes up and down and we're going to vary properties of the simulated send information. We'll discuss this later but it turns out this leads to cheaper electronics. It also makes it easier to pin down your communication to be at certain frequency and that's good. So you can have other people and other devices use other frequencies. You don't get overlap. So you can see what we're doing here is we're taking the data and we're coding it in this kind of pattern. In here, we're using a particular modulation approach called frequency modulation. We're taking the baseline carrier signal and we're modulating properties of it. We're increasing the frequency for a one and decreasing the frequency for a zero. The output of this modulator circuit is then sent to what's called an up-conversion unit. The idea here is that, when you build RF circuits, you can build them cheaper if you use lower frequencies. If you have to use higher frequencies, you have to use more expensive electronics. So to save cost, what we do is we build the modulator unit which has a fair amount of complexity in it using lower frequency electronics and then we up converted. We change the signal to a higher frequency using this up-conversion units, so that saves cost on the modulator part of your design. Then we take the output of that and we put it through an amplifier. So we sent out a really powerful signal which is then sent out over the antenna. It's powerful so can propagate a long way. Now, if you're going to look inside these components, they're not magic. Inside of them, there's specific electronic components that implement each of these features. So if you looked inside the modulation unit, it's taking digital information as input through the circuit which does the modulation, then there's a component that does what's called pulse shaping. What happens is when you do modulation, you have data that's kind of all across different frequencies. So you have pulses that come out. What this pulse shaping unit does is, it shapes the pulse to be a narrower bandwidth and that prevents information from leaking out into adjacent pulses. That goes into what's called a digital to analog converter, which we talked about before, that converts the digital signal into an analog form. That in turn goes to an up-conversion unit, and the up-conversion unit has a low pass filter and a band-pass filter. Those are things that constrained the signal to be within a narrow frequency range so it doesn't leak out into adjacent frequencies and disrupt other devices doing communication. It also has a phase lock loop and that's used for clock synchronization to both sides of the channel. That in turn is fed into an amplifier which amplifies the signal out and that in turn is broadcast out through the antenna. This signal propagates out and it goes out and it's received by an antenna on a receiver. So I'm going to show you the receiver architecture next. The receiver architecture has three modules. There's an amplification unit and what that does is, it amplifies the signal coming back because the signal propagated over a long distance and so it got degraded, so we amplify it back up so we can hear the signal. Then there's a down-conversion unit, and the down-conversion unit takes the high-frequency signal and converts it into a low-frequency signal. So we can use cheap electronics in our demodulation part. Then the demodulation component demodulates the signal. It takes the analog signal and converts it back into digital. So if you're going to look inside each of these components, you'd see how they operate. The amplifier uses what's called a low noise amplifier to reconstruct the signal in a way that filters out some of the noise. It's fed into the down-conversion unit which again uses filters to filter out extra noise outside of the band we're focusing on, uses a phase lock loop. The other end of the phase lock loop to synchronize clocks. Then that's fit into the demodulator which converts the signal from analog to digital. There's channel equalization to amplify the noise of the channel we're focused on, the band we're focused on, and then does demodulation to construct the digital information. So we're done. So we were able to send the data and was able to be received on the other side. So going back to our original challenge here. We want to send data in a way that can be received by the other side. One question that comes up is, what frequencies to use. We have to be smart about this because radio frequency is from three kilohertz to 300 gigahertz which sounds like a lot but isn't really much space because if you look at the visible spectrum that's two million gigahertz wide. So if we have to just use the radio-frequency range, we're limited in terms of bandwidth. So we need some smart ways to pack information into that bandwidth. We need to be really smart about how we take data and modulate it in the right way. How we share the channel with other devices that also want to send data. How we do the frequency allocation and things like that. So one thing we did in the United States and other countries do this too is, it was realized early on that when we send data, we're going to have all these devices that want to send data. We need some way to divide up the space. We need to divide up the radio-frequency range. So you can go online, you can download this chart. This is the law in the United States that defines what's allowed to transmit at each frequency. This is policed. If you don't do this, if you run your devices and you transmit on the wrong frequency, it's illegal. You can get fined. You can get put in jail. So this is the law you have to follow this. If you look at this, you can zoom in or download PDFs online and zoom in and see what's in here, but you're going to see all sorts of stuff. You're going to see certain frequency ranges are set aside for Radio Astronomy and for AM radio, for cellphones and so on. So when you're designing a modulation scheme and you need to choose a baseline carrier frequency, what you do is you look at this chart and you pick a radio range that you're allowed to use. You may have to purchase that range. Some ranges are set aside, they're called white spaces. Those are ranges that are set aside for any device to use. You can just go in and acquire the channel. We need to be really careful about what frequencies you transmit on because some are illegal to use. So that covers radio-frequency communications. I've talked about how you can take data and encode it using electromagnetic signals. In next, what I'm going to do is, I'm going to talk about intended design. I'm going to talk about how you can kind of construct antennas to send RF in efficient ways.