This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
creating-a-lorawan-packet-sniffer [2026/09/05 05:07] sausage |
creating-a-lorawan-packet-sniffer [2026/09/06 23:25] (current) sausage |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| Buying a LoRaWAN gateway for an end device can be a little expensive. You'd need an 8-channel LoRa concentrator (e.g. for a Raspberry Pi) or an all-in-one gateway unit. | Buying a LoRaWAN gateway for an end device can be a little expensive. You'd need an 8-channel LoRa concentrator (e.g. for a Raspberry Pi) or an all-in-one gateway unit. | ||
| - | Then you could build a simple sensor end device and have the gateway route your packets to something like the The Things Network. | + | Then you could build a simple sensor end device and have the gateway route your packets to something like the [[https://www.thethingsnetwork.org|The Things Network]]. |
| The better option, and if you are lucky, there might be a gateway in your area that will pick up your sensor data for you. | The better option, and if you are lucky, there might be a gateway in your area that will pick up your sensor data for you. | ||
| - | That is certainly the case for me being out of town. Thankfully I did discover via the TTN map that there is gateway not very far away, just over the hill. | + | That is certainly the case for me being out of town. Thankfully I did discover via the [[https://ttnmapper.org/heatmap|TTN map]] that there is gateway not very far away, just over the hill. |
| If a gateway is in range, that gives you the opportunity to experiment without the cost and maintenance of a gateway. Now you could probably just start by making an end device and registering it on the TTN, and hope for the best that a gateway may pick it up, but how about we make a sniffer device that scans the downlink channels for LoRaWAN packets? | If a gateway is in range, that gives you the opportunity to experiment without the cost and maintenance of a gateway. Now you could probably just start by making an end device and registering it on the TTN, and hope for the best that a gateway may pick it up, but how about we make a sniffer device that scans the downlink channels for LoRaWAN packets? | ||
| Line 22: | Line 22: | ||
| ===== How will it work? ===== | ===== How will it work? ===== | ||
| - | In our case, we'll be working with the AU915 LoRaWAN downlink channels DR8–DR13 used by gateways to talk to end devices. This is the combination of Frequencies and Spreading Factors. We'll listen for a period of time on each channel before switching to the next. This way we increase the amount of packets that can be heard from any nearby gateway. The table of AU915 downlink channels (gateway to end device) are as follows: | + | In our case, we'll be working with the AU915 LoRaWAN downlink channels DR8–DR13 used by gateways to talk to end devices. The range chosen is the [[https://www.thethingsindustries.com/docs/concepts/features/lorawan/frequency-plans/#au_915_928_fsb_2|Australia 915-928 MHz, FSB 2 (used by TTN)]] This is the combination of Frequencies and Spreading Factors. We'll listen for a period of time on each channel before switching to the next. This way we increase the amount of packets that can be heard from any nearby gateway. The table of AU915 downlink channels (gateway to end device) are as follows: |
| ^ Channel index ^ Frequency (MHz) ^ Data Rate ^ SF ^ BW (kHz) ^ CR ^ Preamble (symbols) ^ | ^ Channel index ^ Frequency (MHz) ^ Data Rate ^ SF ^ BW (kHz) ^ CR ^ Preamble (symbols) ^ | ||
| Line 47: | Line 47: | ||
| Create a blank project with: | Create a blank project with: | ||
| idf.py create-project lorawan-sniffer | idf.py create-project lorawan-sniffer | ||
| + | cd lorawan-sniffer | ||
| If you're using an esp32 set it here. Ensure you set the right esp32 hardware, eg: esp32, esp32s2, etc | If you're using an esp32 set it here. Ensure you set the right esp32 hardware, eg: esp32, esp32s2, etc | ||
| Line 110: | Line 111: | ||
| #define ON 1 | #define ON 1 | ||
| #define OFF 0 | #define OFF 0 | ||
| - | #define MAX_CHANNEL_ATTEMPTS 2048 | + | #define MAX_CHANNEL_ATTEMPTS 2048 |
| #define CODING_RATE_4_5 1 | #define CODING_RATE_4_5 1 | ||
| #define PREAMBLE_SYMBOLS 8 | #define PREAMBLE_SYMBOLS 8 | ||
| - | #define BW_500_KHZ 9 | + | #define BW_500_KHZ 9 |
| int blinkRequest = 0; | int blinkRequest = 0; | ||
| Line 264: | Line 265: | ||
| In the example hex above we can decode that it is: | In the example hex above we can decode that it is: | ||
| + | <code> | ||
| Unconfirmed Data Down (Type 3) | Unconfirmed Data Down (Type 3) | ||
| LoRaWAN R4 | LoRaWAN R4 | ||
| 177 bytes of payload. | 177 bytes of payload. | ||
| + | </code> | ||
| That's paydirt, and that shows there is a gateway somewhere around that you can hear. Ensuring it can hear you will come down to choosing a good antenna and decent position for your end device. But that's for next time. | That's paydirt, and that shows there is a gateway somewhere around that you can hear. Ensuring it can hear you will come down to choosing a good antenna and decent position for your end device. But that's for next time. | ||
| - | Have fun. Everyone loves a Mister Sniffles! | + | Have fun. |