We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Go Even Further Without Wires

00:00

Formal Metadata

Title
Go Even Further Without Wires
Subtitle
Long Distance Radio Communication Using Go and TinyGo
Title of Series
Number of Parts
542
Author
Contributors
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
"Go Even Further Without Wires" is the thrilling part 3 of the "Go Wireless Saga". In "Go Without Wires", we wrote TinyGo code that runs directly on Bluetooth devices. In "Go Further Without Wires", we used TinyGo to connect to WiFi networks, and consequently to the Internet itself. Now, we will extend our reach further out into the real world, with TinyGo programs that can connect to Wide Local Networks (WAN) using the long distance radio protocol LoRA/LoRAWAN. This talk will include several live demonstrations, including a flying object. "Go Even Further Without Wires" is the thrilling part 3 of the "Go Wireless Saga". In "Go Without Wires", we wrote TinyGo code that runs directly on Bluetooth devices. In "Go Further Without Wires", we used TinyGo to connect to WiFi networks, and consequently to the Internet itself. Now, we will extend our reach further out into the real world, with TinyGo programs that can connect to Wide Local Networks (WAN) using the long distance radio protocol LoRA/LoRAWAN. This talk will include several live demonstrations, including a flying object.
14
15
43
87
Thumbnail
26:29
146
Thumbnail
18:05
199
207
Thumbnail
22:17
264
278
Thumbnail
30:52
293
Thumbnail
15:53
341
Thumbnail
31:01
354
359
410
Level (video gaming)Machine code2 (number)Lecture/Conference
Price indexPressureSoftware developerWindowInternetworkingComputer animationLecture/Conference
Computer programmingGroup actionOpen sourceAreaResultantCollaborationismLecture/ConferenceComputer animation
Wide area networkAreaLocal ringCommunications protocolLecture/ConferenceComputer animation
Power (physics)Order (biology)Digital signalTelecommunicationWireless LANOSI modelPower (physics)Spectrum (functional analysis)Category of beingPhysicalismLecture/ConferenceComputer animation
TouchscreenAdditionFrequencyComputer animationLecture/Conference
DistanceCommunications protocolComputer animationEngineering drawing
Game controllerInterface (computing)PeripheralSerial portSerial portSeries (mathematics)Lecture/ConferenceComputer animation
MicrocontrollerCompilerComputer programmingLecture/ConferenceComputer animation
Data typePrice indexGamma functionView (database)Computer fileCore dumpSign (mathematics)Charge carrierTerm (mathematics)VideoconferencingDigital photographySpherical capOnline helpLecture/ConferenceComputer animation
MicrocontrollerBitFocus (optics)Multi-core processorArmComputer animation
Session Initiation ProtocolCodeView (database)Computer fileCore dumpComputer-generated imageryUsabilityDiagramPrice indexPower (physics)Flash memory32-bitComputer programmingLecture/Conference
CodeComputer fileView (database)Lemma (mathematics)MicrocontrollerVirtual machineMultiplication signFunctional (mathematics)CodeDirection (geometry)Computer hardware
Computer fileView (database)World Wide Web ConsortiumArithmetic meanWhiteboardConfiguration spaceLecture/Conference
Core dumpMiniDiscFlash memoryComputer programmingComputer animation
Computer fileDivision (mathematics)Computer programmingType theoryFlash memoryArithmetic meanWhiteboardComputer animationLecture/Conference
Computer fileActive contour modelError messageCodeAsynchronous Transfer ModeDemo (music)Sign (mathematics)Demo (music)GodComputer animation
Device driverDevice driverDemo (music)Wireless LANDifferent (Kate Ryan album)Adaptive behaviorCommunications protocolLecture/ConferenceComputer animation
Different (Kate Ryan album)Computer animation
Order (biology)Broadcasting (networking)CodeComputer animationLecture/Conference
CodeComputer fileView (database)Virtual machineElectronic visual displayGamma functionLemma (mathematics)Term (mathematics)Virtual machineDevice driverTelecommunicationLecture/Conference
CodeComputer fileView (database)Virtual machinePersonal identification numberVisual systemStandard deviationGamma functionGame theoryDevice driverBounded variationInterface (computing)
View (database)Computer fileMaxima and minimaGamma functionVisual systemCodeGame theoryVirtual machinePersonal identification numberConfiguration spaceBand matrixLecture/Conference
Lemma (mathematics)Computer fileView (database)CodeVirtual machinePersonal identification numberAugmented realityGamma functionLecture/Conference
View (database)Computer fileGamma functionMessage passingDemo (music)GodComputer animationLecture/Conference
Demo (music)Error messageCodeMusical ensembleWireless LANComputer animation
2 (number)Serial portLecture/Conference
Error messageDemo (music)Computer animation
Video gameGroup actionComputer animationLecture/Conference
Gamma functionElectronic visual displayDifferent (Kate Ryan album)Computer programmingBitLecture/ConferenceComputer animation
Computer animation
Discrete element methodComputer programming2 (number)Computer animation
Virtual machineLecture/Conference
HypermediaMessage passing
Multiplication signLatent heatQuicksortLecture/Conference
Wide area networkMereologyPoint cloudRight angleLecture/Conference
Computer networkGateway (telecommunications)Server (computing)InternetworkingAddress spaceHypermediaGame controllerGateway (telecommunications)Computer architectureBitLecture/ConferenceComputer animation
Computer networkLattice (order)Server (computing)Multiplication signInternetworkingGateway (telecommunications)Server (computing)Cartesian coordinate systemSoftwareCommunications protocolConnectivity (graph theory)Lecture/ConferenceComputer animation
Goodness of fitServer (computing)SpacetimeLecture/ConferenceComputer animation
FreewareStack (abstract data type)BitService (economics)Front and back endsLibrary (computing)Computer animationLecture/Conference
Discrete element methodKey (cryptography)Internet service providerPattern languagePower (physics)MereologyComputer animation
Decision theoryKey (cryptography)Point cloudServer (computing)Perfect groupLecture/Conference
Distribution (mathematics)Computer networkServer (computing)LaptopComputerSocial classMobile appComputer animationProgram flowchart
LaptopComputerLecture/ConferenceComputer animation
Lemma (mathematics)ComputerAnalogyDegree (graph theory)LaptopoutputExecution unitOcean currentStatisticsCentralizer and normalizerMultiplication signComputer animationLecture/ConferenceMeeting/Interview
MereologyPlastikkarteSoftware development kitBranch (computer science)Continuum hypothesisLecture/ConferenceMeeting/Interview
Program flowchart
Transcript: English(auto-generated)
While Ron is setting up these slides, I'll quickly introduce him. I have a lot of things to say about him, but he's already learning late. But I've never seen such dedication to even five seconds before he came on stage debugging his codes. I've never seen such dedication for a talk.
I think this is true conference-driven development. Thank you, Ron! At FOSTAM 2021, we learned to go without wires. And we discovered Go Bluetooth,
a new package that let you use Go to connect with Bluetooth, not just on microcontrollers, but on Windows. Yes, I said Windows. Here at FOSTAM, I'm very brave. On Windows, on Mac OS, and on Linux. Then, at FOSTAM 2022, we learned to go further without wires.
And we discovered the mysteries of Wi-Fi and the internets. Now, at FOSTAM 2023, we will go even further without wires. This time, we go long. I am Ron Evans, dead program.
I am technologist-for-hire, aren't we all these days, of the hybrid group I microconsultancy here on planet Earth, where we're all technologists-for-hire. So we do a lot of open source work, usually for little or no renumeration. And TinyGo is the result of the amazing collaborations of a huge community of people all over the world.
So this is about going further without wires. So what we're actually talking about here is low-powered wide area networking, or LPWAN. So we talked about personal area networking two years ago, local area networking, and now we're going for wide area networking. And, of course, we're talking about LoRa and LoRaWAN.
So what is LoRa? That's a very good question. Maybe we should ask who is LoRa or why is LoRa, but let's start with what is LoRa. So LoRa is, of course, long-range radio. It is a semi-proprietary but freely licensed protocol
that was created in order to do long-range wireless communication of digital data. And, yes, I had to ask why is LoRa. Well, long-range, of course, I mean, you knew that from the name, right? Ultra low power. Not just low power, but ultra low power. And license-free spectrum.
That means you do not need to go to any governmental entities and ask permissions. But that does not mean free for all. That just means we must share the commons gently because these airwaves are, in fact, the property of all human beings. So LoRa is the physical layer protocol.
And what we mean by that is it actually tells us when the radio signal comes whether it's a one or a zero. So a question, what do these three things have in common? A bat? A dolphin? The screen star of the 20th century, Hedy Lamarr?
I know you're probably wondering. The answer is, of course, chirp spread spectrum. You have that, right? So Hedy Lamarr, in addition to being an actress, probably many people know, was an inventor of what is now known as frequency hopping, which was a technology that was used to avoid jamming and detection during World War II.
And we use this today for the LoRa protocol. So to kind of get you an idea, there's an up chirp and a down chirp. So I will now imitate the up chirp. And the down chirp. I'm like, imagine that in a cute little dolphin voice. So by being able to parse and modulate these signals,
it's able to actually send across long distances using very low power. So how to use LoRa? Well, chips, of course. Thank you. Good night. Chips mostly from Semtech. So Semtech is a company that are the creators of the LoRa protocol, and they make most of the chips and they license them out. The two that are the most common are the SX126X series
and the SX127 series. And so what we're going to do is we're going to see you have a microcontroller, some type of device, and we're going to connect through the serial peripheral interface, which is a low-level serial interface, to the actual LoRa chipset, and then with the antenna, talk out to someplace far, far away.
So this is where TinyGo comes in, right? You knew that when we saw a microcontroller. So the Go compiler for small places. If you haven't checked it out, you can program Arduinos with Go. You'll see in a minute. So let's start with the Holo world of things, which, of course, is a blinky LED. And we're going to start with a Raspberry Pi Pico,
which, oh, I forgot to start my video. Let's see here. You need some, actually, to see what's going on, or it's not quite as exciting. Well, let's see here. Yes, I use all Linux tools, don't we all? Let's see if the camera will come up.
Oh, wrong camera. It looks like, well, I think that is, I forgot to take the lens cap off. Oh, that helps. No, I am not a professional photographer by trade. And, of course, if we make that bigger, it's a lot easier to see. And we can even bring it into a little bit of focus. All right, so this is a Raspberry Pi Pico RP2040,
which is a microcontroller made by Raspberry Pi. And, as we were seeing a minute ago, it's got a dual-core ARM Cortex N0, which is a very, very low-powered, not very powerful ARM Cortex microcontroller, 32-bit. Runs at 133 megahertz and two megabytes of flash.
So, let's just take a quick look at some code, just so you get an idea of what it is that we're looking at. And the whole world of things is a very simple program. You can see this kid. All right, so it's just a Go program, right? But it's run through the TinyGo compiler, and it compiles to the code that can actually run
on the microcontroller. So, we'll import the machine package, which is a special package TinyGo uses to communicate with the hardware directly. Then the time package, same time package. And our function main, you've seen this before. So, first we're going to say LED colon equals machine LED, which is like the built-in LED that's on a lot of boards.
We'll configure that as an output, meaning we're going to send a signal to it to turn it on. And then forever, we're going to turn it low, meaning off. We're going to wait for 500 milliseconds, half a second, turn it on, and then wait for another 500 milliseconds.
All right, so let's go and let's see this actually work. So, if we go back to my press up, there we go. And if we make blinky, I really like make. So, we'll then compile that code, flash it on there,
and you can see that it's a 7K program. Can you see that? Yeah, it's really small, both the type and the program. And then if we go and we take a look, if we, oh, I forgot to plug it in. I was a little rushed for time, I'll admit.
Naturally, it failed the flash. That would have been frightening if it had. There is no wireless in there yet. It's very inexpensive, meaning there's no wireless built on board. All right, so now it's flashed, and if we take a look, we can see an LED is turning on and off. Yes!
All right, we're off to a good start. I tempted the demo gods quite a lot today. So, now we're going to use the TinyGo drivers package, which is a package that is a sister package to the TinyGo compiler, which contains support for all different kinds of sensors, of displays,
and other interesting things like, for example, our LoRa wireless adapters. So, our first demo is going to be showing LoRa, just a low-level protocol transmitting and receiving. And we're going to use the same Raspberry Pi Pico, but we're going to add to it an RF solutions lambda 62.
So, if we can actually take a look at that here. If we go to the video, we'll take away that one, and we'll put in this one. Different Raspberry Pi, and it's wired up to one of those chips that I showed you before. This, by the way, is the antenna. This little wire.
Do I tell you that? I think I do. Yes. It's a Semtech SX1262 with an 868 megahertz radio, is what you need in order to be legal and broadcast here in the European region. And it's got a wire antenna, which is literally just a short piece of wire. And so, if we take a quick look at the code
of our SX1266, so we can see it's not that much longer. It's got a package main, our machine package, time, and now we bring in the drivers for LoRa, which is the actual communication for LoRa, and then for the chip itself.
And what we're going to do here in our main is we'll start by sleeping, and then we'll set up the LoRa interface, and then we'll try to receive data, transmit some data, and then sleep. So setting up the LoRa interface is really just about configuring the SPI interface, the SPI interface, creating the driver that we need
in the TinyGo drivers package, attaching a radio controller, which because these chips have so many different variations that we need to be able to do so we can tell it which wires are going to be turning it on and off, and then make sure we actually have the device detected, configure it appropriately.
So here we've got our 868.1 MHz frequency, the bandwidth that we're using, et cetera, and then once we've got that configured, if you recall, we have our setup, then we'll receive data. So to receive, it's just a matter of saying LoRaRadio.Rx, and then how long we should wait, and if we don't receive any data,
time out and return. And then transmit is almost exactly the same thing. That's going to be transmitting this message here, which is from RP2040 saying, Hello, TinyGo, and then it's going to use LoRa.Rx. All right, let's see if it actually works.
The demo gods are just waiting, waiting for their chance. All right, so let's actually plug that in this time, since we are professionals, and let's run make, which will now flash that code,
and that one's a whole 15K. Yeah, you have to add something to go wireless. All right, and we're actually using one of the capabilities we added into TinyGo two releases ago, which is it's got a built-in serial monitor, so we can see it's trying to receive LoRa data for 10 seconds.
There's no one sending, apparently. And then it will try to, after that, it'll try to send. So because there's no one sending, wait, what? Who is that? That's my next demo.
All right, the Yo badge. You may have seen several of us are wearing these Go badges. So the Go badge is a, it started out like, oh wow, it's upside down. It started out life as an Adafruit Pi badge,
but we helped it transition to its final form, a Go badge. And it's much happier now, I can tell you. I mean, just look at its display. Not to mention that we've got such cute stickers. So we're actually running a different TinyGo program on there, which is called Yo badge.
So Yo badge is using the Adafruit Pi badge. I told you about that a little bit. And it's using this Adafruit LoRa Featherwing, which is a little daughterboard that can be added to some of these. I soldiered it on here. It's got a UFL antenna, which is one of those little antennas that clip on.
That way you can wear it as a badge because, I mean, it is, in fact, a badge. And then, naturally, I need to reboot it. Okay. So you can see the cool Yo logo. And then, because the other program is still running,
remember, it's plugged in. The Adafruit Pi is still plugged in. So we could say Yo to it, and within like ten seconds or so, it should say something back. Let's see. Let's see if it's still here.
Oh! Yep. That was it. The machines are talking to us, and we're talking back. I feel so warm. I really like machines, if you hadn't noticed that. All right. So now let's talk about LoRaWAN.
Because this was all just peer-to-peer, which, actually, before I do that, just real quick before I do that, so we brought a few of these Go badges, the giveaway, here today to some very special, lucky individuals. We'll do that this afternoon. So if you go on Mastodon or any of those other social media things that you're still using, and you send out some really great messages
about how awesome TinyGo is and how cool FOSDEM is and how you really would like to be one of the kids with a programmable badge with wireless, then we'll sort of arbitrarily decide who gets these badges. Maybe random. I don't have time to write any more software. All right. So we don't have that much time left.
So LoRaWAN. Now we're going to go really wide. So the first LoRaWAN specification was actually created in January 2015. So we're not cutting edge here, my friends. We're just catching up on what the cool kids have been doing since back when they were kids. So this is the WAN part of the talk,
which means the cloud. Take a refreshing breath. All right. So that means routable packets. I mean, if you want to go between Internet works, generally we use media access control addresses or MAC addresses. You've seen these and wondered, that's so ugly. But we need this because with LoRaWAN,
our architecture is a bit more complex. We have our end devices, as you saw, like the badge, and they talk to a LoRa gateway. And the gateway is what I was trying to get working before, but I had to do a router reset and I didn't have time to finish. I apologize. They didn't give me an Ethernet cable. They were worried about what I would do with it.
I don't know why. Anyway, the gateway then has a backhaul to the Internets. And that's where the LoRaWAN protocol has three components that are very important. The join server, the network server, and then the application server. So by the way, LoRaWAN is already running on Go.
Go is in all the good places and it's already LoRaWAN. What do I mean? Well, you may have heard of a company called The Things Network. Very, very cool company. Real pioneers in the space. And they have a complete stack for a LoRaWAN server back end
that's all written entirely in Go. Come on, give it up for them. Not to mention an awesome free public service. And then ChirpStack, a little bit more recent entry. They're actually doing amazing stuff with a similarly entirely in Go back end stack for LoRaWAN. And they have a lot of cool tools
and libraries that we're using. So give it up for them. We're talking about devices here. I mean, they've already got Go on the back end. We don't need to reinvent that wheel. They're doing amazing work. No, we're talking about the actual end devices here. And the most important part starts with device activation.
So device activation is like when you buy a phone and it turns on. You don't have to keep logging into your phone. Maybe you should be. But let's skip over that. That's another talk. So it connects. It's activated. You go to your cellular provider. And now you just start making calls. Well, this is the same model, the same pattern that we use with LoRaWAN. And there's two kinds of activation.
One is activation by personalization, which means pre-saved keys on the device itself. Uh-oh. We're running out of power. 4%. The question is, what do I unplug? It's a tough decision. Well, and also, I don't have my adapter with me. You only have five minutes, so go.
Oh, perfect. And then over-the-air activation, which means that you just connect to some server somewhere and you get your keys down from the cloud and then you save those and then you can use those. And then you use those for uplink and downlink. And one thing to remember that's really important
is that with uplink and downlink in LoRaWAN, there is really only uplink. You uplink and then you maybe get a chance to download some data. So this is the reason why it's so low power. It mostly talks and doesn't really listen, which is the opposite of the app I showed you before, which is just a peer-to-peer thing. So we have lower gateways.
That's what this awesome antenna here is. It's a micro-tick-not that I couldn't get rebooted in time with a Yagi antenna. And this is a very powerful antenna. And you'll see what this is all about tomorrow. What do I mean? What I mean is Tiny Globo, a Pico high-altitude balloon.
So if you go to tinyglobo.com, and we'll see if we have internet. Yes, it will redirect you to this page, which is showing you when it's turned on the actual current location, altitude, and stats of the high-altitude balloon. This balloon we will be launching tomorrow
here at FOSDEM. Uh-oh, I think it may have fallen asleep. No? 12 noon Central European time, weather permitting, of course. And that's the end of the talk.
That's the best ending ever. We still have some time for questions, weirdly enough. Thank you, battery. How did that happen? I have no idea. Any questions for Ron? I'm sure you have a lot of questions.
Apparently no questions. Sorry, sorry, sorry. Hi. Have you ever managed to compile the whole Raspberry Pico SDK in C and then import it successfully in TinyGo?
I'm sorry, could you repeat the first part of the question? Have you ever managed to successfully compile the whole SDK for Raspberry Pi Pico and then successfully import it in TinyGo? Because a year ago it didn't work. Well, so the question is, can we import the Raspberry Pi C SDK and then compile it into TinyGo?
The answer is, I'm not really sure. Actually, I think you can, but that's not something we're really trying to do. You're probably interested in the Wi-Fi support. Watchdog, for example. Most things are probably better implemented in TinyGo itself. There is no Watchdog in TinyGo?
There is a branch with a Watchdog, WDT, experimental branch for it. Check that out, but yes. Watchdog, low-power, and bringing in C, those are all things that are part of the TinyGo continuum.
So it's 12 noon tomorrow. Look for us outside somewhere. You'll notice by this antenna. Look for this antenna and some people wearing glowing helmets with actual balloons at the back of my hotel room. And by the way, all the parts are of Chinese origin, but it was made by these American hands. Thank you.
Thank you very much. And please do not tell the government about tomorrow. I'm sorry I don't have any cards. No worries.