# Single Channel LoRaWAN Gateway for Raspberry Pi

## Overview

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/069/555/medium800thumb/raspberry_pi_5_no_pkt_rx_yet.jpg?1547751891)

LoRaWAN is similar to a cellular network, our suggested provider is&nbsp;[The Things Network](https://www.thethingsnetwork.org/), a community-driven initiative with a large amount of public gateways to connect to ([check out the map of publicly listed gateways here](https://www.thethingsnetwork.org/map)).&nbsp;

We're going to build a gateway (highlighted in **red** in the diagram below) to pass data from your LoRaWAN device to the internet.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/068/672/medium800/raspberry_pi_what-is-lorawan_edited.png?1546626462 LoRaWAN Network Topology (via https://lora-alliance.org/sites/default/files/2018-04/what-is-lorawan.pdf))

## What is a LoRaWAN Gateway?

If have a Pi (or Feather)&nbsp; LoRaWAN device set up, you'll likely want to immediately start working with LoRaWAN. Our suggested network is&nbsp;[The Things Network](https://www.thethingsnetwork.org/), a community-driven initiative with a large amount of public gateways to connect to ([check out the map of publicly listed gateways here](https://www.thethingsnetwork.org/map)).&nbsp;

**Gateways form a bridge a LoRaWAN device and the Network, receiving the device's data and forwarding them an application.**

If you don't have a gateway near you, it's possible you could face a dead-end. While multi-channel gateways exist (we stock the&nbsp;[official The Things Gateway](https://www.adafruit.com/product/3943)), they're often expensive - placing a cost barrier on entering the network (as a hobbyist/hacker/experimenter).&nbsp;

## About Single Channel Gateways
Warning: 

Single channel gateways (like the one we'll be building) are a LoRa device which forwards data to a network.&nbsp;They're great for getting into LoRaWAN without purchasing a more expensive "full gateway" (like [The Things Network Gateway](https://www.adafruit.com/product/3943) we stock).

_ **However...** _

Single-channel gateways are&nbsp; **not&nbsp;** LoRaWAN compliant and are not currently supported by The Things Network (due to poor coverage, among other reasons). For more information about the debate about single channel gateways, [check out The Things Network forum](https://www.thethingsnetwork.org/forum/t/the-future-of-single-channel-gateways/6590).

## Parts
The LoRa Radio Bonnet is recommended for this guide - you not only get a radio module, but also a 128x32 OLED display for status messages and three buttons you can use for creating a custom user interface or sending test messages.&nbsp;

Featured
### Adafruit LoRa Radio Bonnet with OLED - RFM95W @ 915MHz

[Adafruit LoRa Radio Bonnet with OLED - RFM95W @ 915MHz](https://www.adafruit.com/product/4074)
The latest Raspberry Pi computers come with WiFi and Bluetooth®, and now you can add even more radio options with the Adafruit Radio Bonnets! Upgrade your Raspberry Pi with a LoRa/LoRaWAN radio so it can communicate over very long distances. These bonnets plug right into your Pi and give...

In Stock
[Buy Now](https://www.adafruit.com/product/4074)
[Related Guides to the Product](https://learn.adafruit.com/products/4074/guides)
![A rectangular microcontroller with OLED screen. A blue-manicured index finger presses buttons below the OLED screen, triggering different texts.](https://cdn-shop.adafruit.com/product-videos/640x480/4074-03.jpg)

There's also a 433MHz version which uses the amateur or license-free ISM band (ITU "Europe" license-free ISM or ITU "American" amateur with limitations).

For a less-permanent gateway build, you can build a gateway using a RFM95W LoRa radio breakout and an OLED display, along with a few buttons.

Featured
### Adafruit RFM95W LoRa Radio Transceiver Breakout - 868 or 915 MHz

[Adafruit RFM95W LoRa Radio Transceiver Breakout - 868 or 915 MHz](https://www.adafruit.com/product/3072)
_"You see, wire telegraph is a kind of a very, very long cat.&nbsp; You pull his tail in New York and his head is meowing in Los Angeles.&nbsp; Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there.&nbsp; The only difference is..._

In Stock
[Buy Now](https://www.adafruit.com/product/3072)
[Related Guides to the Product](https://learn.adafruit.com/products/3072/guides)
![Angled shot of a Adafruit RFM95W LoRa Radio Transceiver Breakout.](https://cdn-shop.adafruit.com/640x480/3072-07.jpg)

There's also a 433MHz version which uses the amateur or license-free ISM band (ITU "Europe" license-free ISM or ITU "American" amateur with limitations).

### Adafruit RFM96W LoRa Radio Transceiver Breakout - 433 MHz

[Adafruit RFM96W LoRa Radio Transceiver Breakout - 433 MHz](https://www.adafruit.com/product/3073)
_"You see, wire telegraph is a kind of a very, very long cat.&nbsp; You pull his tail in New York and his head is meowing in Los Angeles.&nbsp; Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there.&nbsp; The only difference is..._

In Stock
[Buy Now](https://www.adafruit.com/product/3073)
[Related Guides to the Product](https://learn.adafruit.com/products/3073/guides)
![Angled shot of a Adafruit RFM96W LoRa Radio Transceiver Breakout. ](https://cdn-shop.adafruit.com/640x480/3073-10.jpg)

Featured
### Raspberry Pi Zero W

[Raspberry Pi Zero W](https://www.adafruit.com/product/3400)
If you didn't think that the Raspberry Pi Zero could possibly get any better, then boy do we have a pleasant surprise for you!&nbsp;The new **Raspberry Pi Zero W** offers all the benefits of the Pi Zero v1.3, but with one big difference – **built-in...**

Out of Stock
[Buy Now](https://www.adafruit.com/product/3400)
[Related Guides to the Product](https://learn.adafruit.com/products/3400/guides)
![Angled shot of Raspberry Pi Zero W computer.](https://cdn-shop.adafruit.com/640x480/3400-06.jpg)

Featured
### Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM

[Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM](https://www.adafruit.com/product/3775)
The Raspberry Pi 3 Model B is the most popular Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 3 better? How about a&nbsp;_faster_ processor, 5 GHz WiFi, and updated Ethernet chip with PoE capability?...

In Stock
[Buy Now](https://www.adafruit.com/product/3775)
[Related Guides to the Product](https://learn.adafruit.com/products/3775/guides)
![Angled shot of Raspberry Pi 3 - Model B+](https://cdn-shop.adafruit.com/640x480/3775-11.jpg)

You'll also want to pick up the following parts from the Adafruit Shop if you do not have them already:

### Assembled Pi T-Cobbler Plus - GPIO Breakout

[Assembled Pi T-Cobbler Plus - GPIO Breakout](https://www.adafruit.com/product/2028)
 **This is the assembled version of the Pi T-Cobbler Plus. &nbsp;It only works with the Raspberry Pi Model Zero, A+, B+, Pi 2, Pi 3, Pi 4, and Pi 5!** (Any Pi with 2x20 connector)  
  
The Raspberry Pi has landed on the Maker World like a 40-GPIO pinned, quad-USB ported,...

In Stock
[Buy Now](https://www.adafruit.com/product/2028)
[Related Guides to the Product](https://learn.adafruit.com/products/2028/guides)
![Angled shot of Assembled Pi T-Cobbler Plus next to GPIO ribbon cable](https://cdn-shop.adafruit.com/640x480/2028-07.jpg)

### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

Out of Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)
![Bundle of multi-colored multi-length wire jumpers](https://cdn-shop.adafruit.com/640x480/153-04.jpg)

### Tactile Switch Buttons (12mm square, 6mm tall) x 10 pack

[Tactile Switch Buttons (12mm square, 6mm tall) x 10 pack](https://www.adafruit.com/product/1119)
Medium-sized clicky momentary switches are standard input "buttons" on electronic projects. These work best in a PCB but [can be used on a solderless breadboard as shown in this tutorial](https://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs?view=all). The...

In Stock
[Buy Now](https://www.adafruit.com/product/1119)
[Related Guides to the Product](https://learn.adafruit.com/products/1119/guides)
![Angled shot of 10 12mm square tactile switch buttons.](https://cdn-shop.adafruit.com/640x480/1119-03.jpg)

### Full Sized Premium Breadboard - 830 Tie Points

[Full Sized Premium Breadboard - 830 Tie Points](https://www.adafruit.com/product/239)
This is a 'full-size' premium quality breadboard, 830 tie points. Good for small and medium projects. It's 2.2" x 7" (5.5 cm x 17 cm) with a standard double-strip in the middle and two power rails on both sides. You can pull the power rails off easily to make the...

In Stock
[Buy Now](https://www.adafruit.com/product/239)
[Related Guides to the Product](https://learn.adafruit.com/products/239/guides)
![Angled shot of full sized breadboard.](https://cdn-shop.adafruit.com/640x480/239-03.jpg)

### uFL SMT Antenna Connector

[uFL SMT Antenna Connector](https://www.adafruit.com/product/1661)
uFL connectors are very small surface-mount parts used when an external RF antena is desired but a big bulky SMA connector takes up too much space. We use this part on our GPS and WiFi boards, they're great! Chances are your antenna doesn't use uFL as the main connector, in which case...

In Stock
[Buy Now](https://www.adafruit.com/product/1661)
[Related Guides to the Product](https://learn.adafruit.com/products/1661/guides)
![Angled Shot of the uFL SMT Antenna Connector.
](https://cdn-shop.adafruit.com/640x480/1661-02.jpg)

### 5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable

[5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable](https://www.adafruit.com/product/1995)
Our all-in-one 5V 2.5 Amp + MicroUSB cable power adapter is the perfect choice for powering single-board computers like Raspberry Pi, BeagleBone, or anything else that's power-hungry!

This adapter was specifically designed to provide 5.25V, not 5V, but we still call it a 5V USB...

In Stock
[Buy Now](https://www.adafruit.com/product/1995)
[Related Guides to the Product](https://learn.adafruit.com/products/1995/guides)
![MicroUSB power supply with bundled cable and U.S. plugs.](https://cdn-shop.adafruit.com/640x480/1995-02.jpg)

# Single Channel LoRaWAN Gateway for Raspberry Pi

## Pi Wiring

# Antenna Wiring
You _can_ use a wire-based antenna, but this 1/2 wave whip antenna we stock works with the LoRa radios we have and extends the range of the gateway.

If you have a LoRa Radio Bonnet, you can connect the antenna directly to the uFL antenna on the bonnet.

![raspberry_pi_1_connect_ufl.gif](https://cdn-learn.adafruit.com/assets/assets/000/069/538/medium640thumb/raspberry_pi_1_connect_ufl.jpg?1547750692)

## Pi Wiring

If you're using an [Adafruit LoRa Radio Bonnet](https://www.adafruit.com/product/4074), you do not need to wire anything - [proceed to setting up the Raspberry Pi as a gateway.](https://learn.adafruit.com/raspberry-pi-single-channel-lorawan-gateway/raspberry-pi-setup)

If you're using a breadboard, follow the wiring below

### Wiring the Push-Buttons

We'll start by wiring three buttons. These will the physical interface between the Raspberry Pi and the Radio - we'll want to control the radio by pressing some buttons.

![](https://cdn-learn.adafruit.com/assets/assets/000/069/377/medium800/raspberry_pi_pi_a___b___2__3_rfm_btns_only.png?1547586023)

Make the following connections between the Pi and the three push-buttons:

- **Pi GPIO #5** &nbsp;to **Button A&nbsp;** (orange wire)
- **Pi GPIO #6** &nbsp;to **Button B&nbsp;** (blue wire)
- **Pi GPIO #12** &nbsp;to **Button C&nbsp;&nbsp;** (green wire)
- **Pi 3.3V&nbsp;** to&nbsp; **Power Rail&nbsp;** (red wire)
- **Pi GND&nbsp;** to&nbsp; **Ground Rail&nbsp;** (black wire)

### Wiring the OLED
![](https://cdn-learn.adafruit.com/assets/assets/000/069/378/medium800/raspberry_pi_pi_a___b___2__3_rfm9x_lcd_btns.png?1547586063)

- **Display GND** to **Raspberry Pi GND** (black wire)
- **Display Vin** to **Raspberry Pi 3.3V** (red wire)
- **Display SCL** to **Raspberry Pi SCL** (green wire)
- **Display SDA** to **Raspberry Pi SDA** (yellow wire)

### Wiring the RFM Radio Module
![](https://cdn-learn.adafruit.com/assets/assets/000/070/340/medium800/raspberry_pi_rfm69_bb.png?1548973566)

Make the following connections between the **Raspberry**  **Pi** and the **RFM Radio Module** :

- **Vin&nbsp;** to&nbsp; **Raspberry Pi 3.3V**
- **GND&nbsp;** to **Raspberry Pi Ground**
- **RFM G0&nbsp;** to&nbsp; **Raspberry Pi GPIO #5**
- **RFM RST&nbsp;** to&nbsp; **Raspberry Pi GPIO #25**
- **RFM CLK&nbsp;** to&nbsp; **Raspberry Pi SCK**
- **RFM MISO&nbsp;** to&nbsp; **Raspberry Pi MISO**
- **RFM MOSI&nbsp;** to&nbsp; **Raspberry Pi MOSI**
- **RFM CS&nbsp;** to&nbsp; **Raspberry Pi CE1**

Next, let's move on to installing the necessary files for this project.

# Single Channel LoRaWAN Gateway for Raspberry Pi

## Things Network Raspberry Pi Setup

Danger: 

This guide assumes that you've gotten your Raspberry Pi up and running, and have CircuitPython installed.

- [If you have not done this yet, visit the installation guide **here** and come back when you're set up.](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi)

## Installing CircuitPython Libraries

We're running CircuitPython on the Raspberry Pi, installing the libraries for radio communication is simple.

To **install the library for the display** , **enter the following into the terminal:**

**`pip3 install adafruit-circuitpython-ssd1306`**

You'll also need to **install the framebuf module** in order to write to the display.&nbsp;

`sudo pip3 install adafruit-circuitpython-framebuf`

To install the library for the **RFM9x** Module, **enter the following into the terminal:**

`sudo pip3 install adafruit-circuitpython-rfm9x`

## Testing the Setup

There have been a _lot_ of steps so far - let's verify that everything is wired up and all the libraries are installed properly before moving on to sending and receiving data.&nbsp;

The following code is for checking if the RFM9x radio is set up for transmitting and receiving. **Save the code on your Pi** as **`rfm9x_check.py`**.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/pi_radio/rfm9x_check.py

To use the code, enter the following in your terminal:

`python3 rfm9x_check.py`

You'll also want to download the font file, **`font5x8.bin`,** and copy it&nbsp;into the same directory as the script:

[font5x8.bin](https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin)
Then, let's check the setup:

If the RFM9x is&nbsp; **detected** , the&nbsp;OLED will display&nbsp;_Detected!_&nbsp;

&nbsp;

You can test&nbsp; the buttons by pressing them and watching the display for changes.

![raspberry_pi_bonnet_test.gif](https://cdn-learn.adafruit.com/assets/assets/000/069/541/medium640thumb/raspberry_pi_bonnet_test.jpg?1547750875)

 **If the wiring of the radio module is incorrect** &nbsp;-&nbsp;the display will show&nbsp; **ERROR**. Check over your wiring on the Wiring Page and re-run the test. You may also need to ensure the correct CircuitPython library is installed for the module.&nbsp;

&nbsp;

**If the OLED does not turn on** &nbsp;-&nbsp;first check that it is wired correctly. Then, make sure you enabled I2C from&nbsp;`raspi-config`&nbsp;and installed the required libraries (`adafruit-circuitpython-framebuf`_and_&nbsp;`adafruit-circuitpython-ssd1306`).

![raspberry_pi_pi_a___b___2__3_IMG_0773.jpg](https://cdn-learn.adafruit.com/assets/assets/000/069/384/medium640/raspberry_pi_pi_a___b___2__3_IMG_0773.jpg?1547586798)

## Install the Single Channel Pi Gateway

[WiringPi](http://wiringpi.com/)&nbsp;is&nbsp; **PRE-INSTALLED** &nbsp;with standard Raspbian systems. To check if it is pre-installed on your system, run:

` gpio -v`

If you get something, then you have it already installed. Otherwise, install WiringPi by running:

`sudo apt-get install wiringpi`

Then, **clone the packet forwarder repository** &nbsp;

`git clone https://github.com/adafruit/single_chan_pkt_fwd.git`

**Navigate** into the packet forwarder directory

`cd single_chan_pkt_fwd/`

and **compile** the code for the gateway

`sudo make all`

You'll also want to download the font file, **`font5x8.bin`,** and copy it&nbsp;into the same directory as the script:

[font5x8.bin](https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin)
 **If you are using a Raspberry Pi ZERO,&nbsp;** you will need to change a value within the configuration file. Using a text editor, open the `global_conf.json` file. Replace `"is_pi_zero": false` with `"is_pi_zero": true`. Your configuration file should look like the following.

```python
{
  "SX127x_conf": {
    "freq": 905100000,
    "spread_factor": 7,
    "pin_nss": 11,
    "pin_dio0": 3,
    "pin_rst": 25
  },
  "gateway_conf": {
    "ref_latitude": 0.0,
    "ref_longitude": 0.0,
    "ref_altitude": 10,
    "name": "Radio Pi Bonnet",
    "email": "contact@email.com",
    "desc": "Adafruit Radio Pi LoRa 1-Ch Gateway",
    "is_pi_zero": true,
    "servers": [
      {
        "address": "router.us.thethings.network",
        "port": 1700,
        "enabled": true
      },
      {
        "address": "router.eu.thethings.network",
        "port": 1700,
        "enabled": false
      }
    ]
  }
}
```

## Gateway Usage

From within the `single_chan_pkt_fwd/` folder, run the Python program by entering the following into the terminal:

`python3 lorawan_gateway.py`

The display should show the Gateway EUI. Keep this screen open, we'll need it for the next step.

![raspberry_pi_gateway_eui.jpeg](https://cdn-learn.adafruit.com/assets/assets/000/069/540/medium640/raspberry_pi_gateway_eui.jpeg?1547750785)

# Single Channel LoRaWAN Gateway for Raspberry Pi

## Configuring The Things Network

Danger: 

## Registering a Gateway with The Things Network
Before a Gateway can be used with [The Things Network](https://www.thethingsnetwork.org/)&nbsp;(TTN), it needs to be registered.

First, **register an account with TTN**.&nbsp;

- [Navigate to their account registration page](https://account.thethingsnetwork.org/register)&nbsp;to set up an account.

Once logged in,&nbsp;**[navigate to the The Things Network Console](https://console.thethingsnetwork.org/).** This page is where you can register applications and add new devices or gateways.

**Click&nbsp;_Gateways_&nbsp;**

![](https://cdn-learn.adafruit.com/assets/assets/000/068/682/medium800/raspberry_pi_The_Things_Network_Console_Gateways.png?1546635645)

 **Click _register gateway_**

![](https://cdn-learn.adafruit.com/assets/assets/000/068/683/medium800/raspberry_pi_The_Things_Network_Console_Reg_gatewy.png?1546635671)

 **Tick the&nbsp;_I'm using the legacy packet forwarder&nbsp;_** checkbox.

Then, enter the Gateway EUI displayed on the gateway.

![raspberry_pi_gateway_eui.jpeg](https://cdn-learn.adafruit.com/assets/assets/000/069/561/medium640/raspberry_pi_gateway_eui.jpeg?1547756159)

![raspberry_pi_The_Things_Network_Console_Leg_Packet_fwd_2.png](https://cdn-learn.adafruit.com/assets/assets/000/068/684/medium640/raspberry_pi_The_Things_Network_Console_Leg_Packet_fwd_2.png?1546635714)

 **Fill out a&nbsp;description** &nbsp;of what the gateway is.

&nbsp;

**Set the frequency plan to** your region's frequency, we set ours to **United States**.&nbsp;

&nbsp;

**Set the Router&nbsp;to the location closest to you**.&nbsp;

- Adafruit is located in New York City, so I set the router to _ttn-router-us-west.&nbsp;_

![raspberry_pi_The_Things_Network_Console_Gateway_Config.png](https://cdn-learn.adafruit.com/assets/assets/000/068/686/medium640/raspberry_pi_The_Things_Network_Console_Gateway_Config.png?1546635961)

 **Click Register Gateway**. TTN will register the gateway and redirect you to the Gateway Overview page.

![raspberry_pi_The_Things_Network_Console.png](https://cdn-learn.adafruit.com/assets/assets/000/068/687/medium640/raspberry_pi_The_Things_Network_Console.png?1546636095)

The Things Network does **not** list Single Channel gateways on their map - these gateways are not great at handling multiple devices or accurately receiving a packets every time they're sent by a device. However, they're great for hacking on, experimenting, and using in a staging/lab setup.&nbsp;

We'll want to **set the Gateway Privacy to Private** and **set the location to Unlisted**.&nbsp;

From the&nbsp; **Gateway Overview&nbsp;** page, **click** _&nbsp; **Edit Info** _.

On the Privacy Page, **_untick_ all of the options&nbsp;** and&nbsp; **click _Save Settings_**.

![](https://cdn-learn.adafruit.com/assets/assets/000/068/693/medium800/raspberry_pi_The_Things_Network_Console_Privacy_2.png?1546636845)

Before starting up the gateway, we'll optionally set the gateway information.

&nbsp;

From the **Gateway Overview** page, **click** _Edit Info__&nbsp;_

&nbsp;

For brand, **select** _Single-Channel DIY Gateway_

&nbsp;

For model, **type** _Raspberry Pi_

![raspberry_pi_The_Things_Network_Console_Information.png](https://cdn-learn.adafruit.com/assets/assets/000/068/690/medium640/raspberry_pi_The_Things_Network_Console_Information.png?1546636489)

![raspberry_pi_The_Things_Network_Console_Info_2.png](https://cdn-learn.adafruit.com/assets/assets/000/068/691/medium640/raspberry_pi_The_Things_Network_Console_Info_2.png?1546636504)

It's time to test! Run the Python program by entering the following into the terminal:

`python3 lorawan_gateway.py`

and **press the middle button** &nbsp;to launch the gateway.

You should see the **Status&nbsp;** of the gateway on your console switch from from _Not Connected_ to _Connected_. If you've had previously connected the gateway: the&nbsp;_Last Seen_ label should update to&nbsp;_Now_.&nbsp;

![raspberry_pi_last_seen.gif](https://cdn-learn.adafruit.com/assets/assets/000/069/388/medium640thumb/raspberry_pi_last_seen.jpg?1547589287)

Our gateway is now listening for new packets, it'll refresh whenever it's received a new packet.

Next, we're going to set up a device to send data to the gateway.

## Usage with Pi Zero

If you are using a Pi Zero, you will need to modify the&nbsp; **global\_conf.json&nbsp;** file prior to running the command above.

**Change the following line** in the JSON configuration from:

`"is_pi_zero": false,`

to

`"is_pi_zero": true,`

And **save the file.**

https://github.com/adafruit/single_chan_pkt_fwd/blob/master/global_conf.json

Then, run the Python program by entering the following into the terminal:

`python3 lorawan_gateway.py`

## Troubleshooting your Gateway
### 

Double check the configuration steps on this page. Make sure the Pi is connected to the internet and that the **Gateway EUI matches the Gateway EUI displayed on the Pi's display**.&nbsp;&nbsp;

# Single Channel LoRaWAN Gateway for Raspberry Pi

## Device Setup

Next, you'll need a LoRaWAN device to send data to the single-channel gateway.&nbsp;

**_Don't have a LoRaWAN device?_**

We have a few options for getting one up and running - with support for CircuitPython and Arduino.

## Building a CircuitPython LoRaWAN Device
![](https://cdn-learn.adafruit.com/assets/assets/000/068/694/medium800/raspberry_pi_guidephoto.png?1546637892)

If you'd like to use CircuitPython to send data to the gateway, we have two guides which use CircuitPython and [the CircuitPython\_TinyLoRa library](https://github.com/adafruit/Adafruit_CircuitPython_TinyLoRa).

[This guide sets up weather-logging LoRaWAN device with an Adafruit Feather.](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/)

&nbsp;

It works with **any** of the Feather Family boards which run CircuitPython and a RFM9x breakout, Feather M0 LoRa or a Radio FeatherWing.&nbsp;

![raspberry_pi_wireless_P1000318_(1).jpg](https://cdn-learn.adafruit.com/assets/assets/000/068/697/medium640/raspberry_pi_wireless_P1000318_%281%29.jpg?1546638068)

[This guide sets up a LoRaWAN node using a Raspberry Pi](https://learn.adafruit.com/lora-and-lorawan-for-raspberry-pi)

![raspberry_pi_pi_a___b___2__3_ezgif.com-video-to-gif_(1)_(1).gif](https://cdn-learn.adafruit.com/assets/assets/000/068/698/medium640thumb/raspberry_pi_pi_a___b___2__3_ezgif.com-video-to-gif_%281%29_%281%29.jpg?1546638132)

## Building an Arduino CircuitPython Device
[This guide uses an Adafruit Feather M0 LoRa and a DHT22 temperature sensor](https://learn.adafruit.com/the-things-network-for-feather) to capture and send data to The Things Network using either the MCCI LoRaWAN LMIC Library or the&nbsp;[Adafruit TinyLora Library](https://github.com/adafruit/TinyLoRa).

![raspberry_pi_hero_guide.gif](https://cdn-learn.adafruit.com/assets/assets/000/068/699/medium640thumb/raspberry_pi_hero_guide.jpg?1546638379)

Now that we have a LoRaWAN Device, let's use it to send data to to our gateway.

# Single Channel LoRaWAN Gateway for Raspberry Pi

## Gateway Usage

## Configuration between Device and Gateway

Before we broadcast to the single-channel radio, there are some things to keep in mind:

Since this gateway only listens on _one_ channel - **&nbsp;frequency and spread factor should be the _same_ between both the gateway and the device**.&nbsp;This means that if you're sending data over 904.1MHz (channel 1 in the US) with spread factor of 7, the gateway should be _listening_&nbsp; for transmissions on 904.1MHz with a spread factor of 7.

From the gateway, you can check and/or modify the gateway's configuration within&nbsp;`global_conf.json` under&nbsp;`freq`&nbsp;and `spread_factor`.

You'll want to modify your code to send over a single-channel (frequency). By default, TinyLoRa sends with a spread factor of 7.

- We have examples for sending data over a single-channel using either&nbsp;[TinyLoRa for **CircuitPython**](https://github.com/adafruit/Adafruit_CircuitPython_TinyLoRa/blob/master/examples/tinylora_simpletest_single_channel.py) or&nbsp;[TinyLoRa for **Arduino**](https://github.com/adafruit/TinyLoRa/blob/master/examples/hello_LoRa_single_chan/hello_LoRa_single_chan.ino).

## Gateway Usage

Run the Python program by entering the following into the terminal:

`python3 lorawan_gateway.py`

 **Press the first button** to display statistics about the Pi, such as its IP, CPU load, and available memory.

![raspberry_pi_3_show_pi_stats.gif](https://cdn-learn.adafruit.com/assets/assets/000/069/545/medium640thumb/raspberry_pi_3_show_pi_stats.jpg?1547751026)

 **Press the third button** to display the name of the gateway along with the frequency, spreading factor, and The Things Network router.

![raspberry_pi_2_show_gateway_info.gif](https://cdn-learn.adafruit.com/assets/assets/000/069/546/medium640thumb/raspberry_pi_2_show_gateway_info.jpg?1547751114)

 **Press the second button** to launch the gateway. It'll display the current status (if a packet is received or not) and update the timestamp every minute.

![raspberry_pi_5_no_pkt_rx_yet.gif](https://cdn-learn.adafruit.com/assets/assets/000/069/547/medium640thumb/raspberry_pi_5_no_pkt_rx_yet.jpg?1547751241)

When a LoRa Packet is received by the gateway, the terminal will display that a packet has been received, and it'll print out useful data coming from the packet :

```auto
incoming pkt...
{"rxpk":[{"tmst":4067850409,"freq":905.1,"chan":0,"rfch":0,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","rssi":-35,"lsnr":10.0,"size":24,"data":"QLERAiYAKAABE0NCX+3lkSnK09WVlk8N"}]}
```

The display will also refresh to display that a packet has been received. In this example, we're sending data from a RFM9x FeatherWing to the Gateway:

![](https://cdn-learn.adafruit.com/assets/assets/000/069/548/medium800thumb/raspberry_pi_4_send_pkt.jpg?1547751393)

We can't read the incoming data since it's encrypted. After all, device data shouldn't be read-able by a gateway operator. We'll need to check our **device** on The Things Network Console to read the decrypted data.

From The Things Network Console,&nbsp; **navigate to the data tab for the device**. You should see a packet pass through this page when a new packet is received.

&nbsp;

&nbsp;

**Click on the packet** to display the packet's payload

&nbsp;

&nbsp;

**Scrolling down** &nbsp;on the packet's information will show the gateways used to communicate (one device can communicate to more than one gateway) and the packet's information (_metadata_) .

![raspberry_pi_The_Things_Network_Console_App_Data.png](https://cdn-learn.adafruit.com/assets/assets/000/068/795/medium640/raspberry_pi_The_Things_Network_Console_App_Data.png?1546885316)

![raspberry_pi_The_Things_Network_Console_Gateway_Metadata.png](https://cdn-learn.adafruit.com/assets/assets/000/068/796/medium640/raspberry_pi_The_Things_Network_Console_Gateway_Metadata.png?1546885323)

We've received data, but what about making it readable by humans -&nbsp;[we have instructions about using the Things Network's payload decoder here](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/using-tinylora#checking-data-on-the-things-network-console-6-30).


## Guide Products

### Adafruit LoRa Radio Bonnet with OLED - RFM95W @ 915MHz

[Adafruit LoRa Radio Bonnet with OLED - RFM95W @ 915MHz](https://www.adafruit.com/product/4074)
The latest Raspberry Pi computers come with WiFi and Bluetooth®, and now you can add even more radio options with the Adafruit Radio Bonnets! Upgrade your Raspberry Pi with a LoRa/LoRaWAN radio so it can communicate over very long distances. These bonnets plug right into your Pi and give...

In Stock
[Buy Now](https://www.adafruit.com/product/4074)
[Related Guides to the Product](https://learn.adafruit.com/products/4074/guides)
### Adafruit LoRa Radio Bonnet RFM96W @ 433MHz

[Adafruit LoRa Radio Bonnet RFM96W @ 433MHz](https://www.adafruit.com/product/4075)
The latest Raspberry Pi computers come with WiFi and Bluetooth, and now you can add even more radio options with the Adafruit Radio Bonnets! Upgrade your Raspberry Pi with a LoRa / LoRaWAN radio, so it can communicate over very long distances. These bonnets plug right into your Pi and give you...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4075)
[Related Guides to the Product](https://learn.adafruit.com/products/4075/guides)
### Adafruit RFM95W LoRa Radio Transceiver Breakout - 868 or 915 MHz

[Adafruit RFM95W LoRa Radio Transceiver Breakout - 868 or 915 MHz](https://www.adafruit.com/product/3072)
_"You see, wire telegraph is a kind of a very, very long cat.&nbsp; You pull his tail in New York and his head is meowing in Los Angeles.&nbsp; Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there.&nbsp; The only difference is..._

In Stock
[Buy Now](https://www.adafruit.com/product/3072)
[Related Guides to the Product](https://learn.adafruit.com/products/3072/guides)
### Adafruit RFM96W LoRa Radio Transceiver Breakout - 433 MHz

[Adafruit RFM96W LoRa Radio Transceiver Breakout - 433 MHz](https://www.adafruit.com/product/3073)
_"You see, wire telegraph is a kind of a very, very long cat.&nbsp; You pull his tail in New York and his head is meowing in Los Angeles.&nbsp; Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there.&nbsp; The only difference is..._

In Stock
[Buy Now](https://www.adafruit.com/product/3073)
[Related Guides to the Product](https://learn.adafruit.com/products/3073/guides)
### Raspberry Pi Zero W

[Raspberry Pi Zero W](https://www.adafruit.com/product/3400)
If you didn't think that the Raspberry Pi Zero could possibly get any better, then boy do we have a pleasant surprise for you!&nbsp;The new **Raspberry Pi Zero W** offers all the benefits of the Pi Zero v1.3, but with one big difference – **built-in...**

Out of Stock
[Buy Now](https://www.adafruit.com/product/3400)
[Related Guides to the Product](https://learn.adafruit.com/products/3400/guides)
### Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM

[Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM](https://www.adafruit.com/product/3775)
The Raspberry Pi 3 Model B is the most popular Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 3 better? How about a&nbsp;_faster_ processor, 5 GHz WiFi, and updated Ethernet chip with PoE capability?...

In Stock
[Buy Now](https://www.adafruit.com/product/3775)
[Related Guides to the Product](https://learn.adafruit.com/products/3775/guides)
### Assembled Pi T-Cobbler Plus - GPIO Breakout

[Assembled Pi T-Cobbler Plus - GPIO Breakout](https://www.adafruit.com/product/2028)
 **This is the assembled version of the Pi T-Cobbler Plus. &nbsp;It only works with the Raspberry Pi Model Zero, A+, B+, Pi 2, Pi 3, Pi 4, and Pi 5!** (Any Pi with 2x20 connector)  
  
The Raspberry Pi has landed on the Maker World like a 40-GPIO pinned, quad-USB ported,...

In Stock
[Buy Now](https://www.adafruit.com/product/2028)
[Related Guides to the Product](https://learn.adafruit.com/products/2028/guides)
### Monochrome 128x32 I2C OLED graphic display

[Monochrome 128x32 I2C OLED graphic display](https://www.adafruit.com/product/931)
These displays are small, only about 1" diagonal, but very readable due to the high contrast of an OLED display. This display is made of 128x32 individual white OLED pixels, each one is turned on or off by the controller chip. Because the display makes its own light, no backlight is...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/931)
[Related Guides to the Product](https://learn.adafruit.com/products/931/guides)

## Related Guides

- [Adafruit Radio Bonnets with OLED Display - RFM69 or RFM9X](https://learn.adafruit.com/adafruit-radio-bonnets.md)
- [Set up Home Assistant with a Raspberry Pi](https://learn.adafruit.com/set-up-home-assistant-with-a-raspberry-pi.md)
- [Adafruit IO Basics: Servo](https://learn.adafruit.com/adafruit-io-basics-servo.md)
- [Adafruit IO Basics: Color](https://learn.adafruit.com/adafruit-io-basics-color.md)
- [PyPortal Wall Mount](https://learn.adafruit.com/pyportal-wall-mount.md)
- [Adafruit IO Basics: Digital Output](https://learn.adafruit.com/adafruit-io-basics-digital-output.md)
- [Face Mask Efficacy Testing with SCIENCE!](https://learn.adafruit.com/raspberry-pi-camera-vision-face-mask-efficacy-testing.md)
- [Adafruit IO Home: Lights and Temperature ](https://learn.adafruit.com/adafruit-io-house-lights-and-temperature.md)
- [Feather Waveform Generator in CircuitPython](https://learn.adafruit.com/waveform-generator.md)
- [Use Blinka in Ubuntu Core on Raspberry Pi](https://learn.adafruit.com/use-blinka-with-ubuntu-core-on-raspberry-pi.md)
- [All About Raspberry Pi HQ Camera Lenses](https://learn.adafruit.com/raspberry-pi-hq-camera-lenses.md)
- [IoT Temperature Logger with Analog Devices ADT7410, Raspberry Pi, and Adafruit IO](https://learn.adafruit.com/iot-temperature-logger-with-python-and-adafruit-io.md)
- [MIDI for Makers](https://learn.adafruit.com/midi-for-makers.md)
- [LED Snowboard with Motion-Reactive Animation](https://learn.adafruit.com/led-snowboard-with-motion-reactive-animation.md)
- [MagicLight Bulb Color Mixer with Circuit Playground Bluefruit](https://learn.adafruit.com/magiclight-bulb-mixer.md)
