LoRa video:

  • Long Range Intro
    • Sensors super-far away
    • Relatively low cost, but also very low bandwidth and update rate
    • I already have used cheap 433mhz sensors, Zigbee, Z-wave, and Wifi in my house, and they all have their place, but they just aren’t reliable enough for the sensors outside of my house. Zigbee barely even works in my basement because some vendors don’t support repeaters properly, and none of them can give me data from the gaming shed reliably. If I had a larger property, it would be an even bigger nightmare.
    • If you have a need to send data outdoors, over long distances, and with battery or solar power, maybe LoRa or LoRaWAN is right for you
  • The Hardware I’m Working With
    • Elecrow sent me a LoRaWAN gateway
    • And a LoRaWAN sensor node
    • Also, Crowtail sensor modules to use with it
    • So I’m going to build a LoRaWAN network, completely self-hosted, and see how far it can take me
  • What is LoRa?
    • I’m getting ahead of myself, what is LoRa anyway?
    • A technique for chirp spread-spectrum communication
    • While a lot of communications we rely on today use amplitude, phase, and frequency modulation
    • Or a combination of those, such as QAM
    • LoRa uses frequency-slewing ‘chirps’ which can be more easily demodulated at very low signal strength, even with a negative signal to noise ratio
    • This makes LoRa very attractive for long range, and low power equipment
    • But why don’t we all use LoRa chirp modulation for everything??
    • BECUASE IT’s SLOW AF. The data rate is usually measured in tens of bytes per second, with a maximum of 50kbit/sec, slower than dial-up.
    • But, this data rate is perfectly acceptable for a lot of remote sensing applications, like I’ll explore in this video.
  • Gateway
    • So, to get my low speed sensor data onto my network where I can work with it, I need a gateway
    • I’m using the Elecrow gateway with a Pi 4, although an older Pi should be perfectly fine for this
    • I set it up in my cat’s bedroom, I hope he doesn’t mind
    • Elecrow provides a repository on Github which you can clone. It’s actually just the code from Semtech, the chip manufacturer, with a few configuration files modified to set the right hardware ports for their board on a Raspberry Pi.
    • I have a fork of my own which supports IPv6, if you need that, and the actual configuration file I used is available on my website as well
    • We need a unique ID for the gateway, and it needs to be a 64-bit hex value. We can randomly generate this, or use the MAC address of the Pi, or something like that. Some gateways will already include their EUI64 from the factory, this one does not.
    • I also wrote a systemd service for the lorawan forwarder, also available on my github fork if you want to use it.
  • So what is LoRaWAN anyway?
    • You might have noticed that I’ve mentioned LoRaWAN a few times by now, so what is that?
    • LoRa is a modulation and communication scheme now owned by Semtech, but it’s not a protocol on its own. It really just sends raw frames over the air, without any sort of meaning.
    • We could try to develop an entire protocol from scratch, but there are already some good ones for us to choose from.
    • Meshtastic is an example of a fairly custom peer to peer protocol using LoRa, popular for its ability to send text messages several kilometers without cellular service.
    • But today, we’re using LoRaWAN, a technique developed for very large scale sensor networks
    • In LoRaWAN, we have a gateway which has a steady power source and can act as a relay between the LoRa network and the internet. But this gateway doesn’t do a whole lot, it really just forwards packets to and from the core network in the cloud
    • It does however support 8 frequencies at a time, so it can handle a fairly large number of client devices
    • Since all of the intelligence is in the cloud, we can deploy a ton of these gateways, and they will pick up and communicate with the nodes around them. The nodes have no idea which gateway they are using, and they don’t need to care, so even if they are mobile they can wake up and transmit. If a gateway is nearby, it will work.
    • LoRaWAN also supports encryption, and this is all cloud-managed as well, so we don’t need to trust the gateways
    • This has led to some public LoRaWAN networks, such as The Things Network or the Helium ‘cryptocurrency’ network, which both provide publicly accessible LoRaWAN networks which you can rely on for connectivity in many parts of the world.
    • But, we can also locally host the cloud bits ourselves, using the open-source Chirpstack, which I’m going to do in this video
  • Chirpstack
    • So we have our gateway setup, now we need a LoRaWAN core network for it to talk to. I already gave it a name in the past segment, we called it chirpx. After this guy (from Cities Skylines)
    • So now we need to set it up. And they have Debian packages! So that makes it easy, I’m installing it on a Debian Bookworm container but any Debian system including the Raspberry Pi you’re also using for the gateway should work just fine.
    • Walk through entire setup on Debian
    • The Semtech gateway uses a UDP-based protocol, but Chirpstack prefers to use MQTT. So, we need a gateway to convert between the two. Thankfully, it’s all included in Chirpstack, we just need to run it. You can choose to run this on each of your gateway nodes, or on the core module, it’s really up to you. Remember, traffic at the LoRaWAN level is authenticated and encrypted, but there might still be some DoS risks to using the UDP-based protocol on the open internet, I’m not sure.
    • Once we’ve got the protocol converter setup, we can start the full stack and add our gateway
    • It should show up, and since this gateway has GPS it will even show up on a map. How neat!
  • Use Cases