Skip to the content
2 layers65.4 × 63 mmLoRa Gateway E220, the printed circuit board in 3D

LoRa Gateway E220

ezcGman/lora-gateway39

Gateway to create a bridge between your LoRa devices and Wi-Fi or Ethernet. Also comes with ready-to-use code to drop everything into your MQTT server!

Size
65.4 × 63 mm
Copper layers
2
Thickness
1.6 mm
Parts
15
Nets
37
Pads
141
Tracks, vias
98, 41
Pours
4
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
4 Mar 2022
Updated
4 Oct 2022

Overview

LoRa Gateway E220 is an open-source printed circuit board by ezcGman, from the ezcGman/lora-gateway repository on GitHub. It is a 2-layer board of 65.4 × 63 mm with 15 parts on 37 nets, routed with 98 tracks and 41 vias.

It is built around the M2.5. Its parts include 3 resistors, 3 ICs, 2 capacitors, 1 connector and 1 fuse. It belongs with the radio and wireless and interfaces and adapters boards and the ESP32 boards of this library.

Main components

1

README

README.md

LoRa-To-MQTT Gateway

Introduction

This repository gives you everything you need to easily build (it's a DIY project!) a great quality LoRa-To-MQTT gateway, based on EByte LoRa modules and an ESP32 and works either with Wi-Fi or Ethernet, running off 5V. There are two different versions of the gateway, details on those versions and which you should pick down below:

  • One using an EByte E32
  • One using an EByte E220

For giving the board Ethernet capability, I'm using the QuinLED ESP32 Ethernet Hat. Of course, It's natural that I should have also used a QuinLed ESP32, but I had a few spare standard ESP32 devboards laying around with no use for, so I designed the board around these. But that said, I might one day design a version completely based on the QuinLED-ESP32.

To easily switch between Wi-FI and Ethernet, there's a jumper on the board to do just that. This even works with the board powered; no need to cut power.

What do I need to do to get one?

Again, this is a DIY project! So first off, you need a few soldering skills and I highly recommend either a SMD hot plate or hot air gun to solder the Ebyte E32 module. Its very very hard to solder it with just an iron!

1. Get the PCBs

So you want to get the PCBs printed at a PCB prototype factory of your choice, like JLCPCB or PCBWay. I've included the Gerber files for both in the respectiv folder. If you want to use a different service provider, you need to check if they may accept these gerbers or generate them yourself.

I also highly recommend that you order this PCB with a stencil, otherwise you gonna have a hard time putting the paste on the pads of the EByte module!

2. Get the components

3. Build the board and wire it up

Each PCB folder has an iBOM HTML file which gives you nice soldering instructions / overview, find it in the ibom folder in each versions folder. When you've soldered the board, simply wire it up with a 5V power source and there you go! It consumes less than 200mA, so you can easily use an old 500mA, 1A (or higher) phone charger for it.

4. Install the software

Source is available in the src folder. Download Arduino IDE, check the config.h file and replace the placeholders with your settings, compile and upload to the ESP32. That should be it and the gateway should pop up in your MQTT server and send health check messages every 5 seconds.

How you can now have your sensors and boards have LoRa messages sent to it can be found in the "Source Code / Software" section below.

PCBs

General design

  • Can either be operated using Wi-Fi or Ethernet
    • Jumper on board to (even with powered-on board) switch between those two
  • Uses a standard 30-pin (2x15-pin) ESP32 DevKit
  • For Ethernet, uses the QuinLED ESP32 Ethernet Hat
  • Easily powered using a screw terminal
  • Extra protection using a PTC fuse, in case something goes sideways
  • Can also be powered via USB on the ESP32, but this will skip the PTC fuse and with that your protection. So not recommended
  • Four M2.5 mounting holes to mount it to or into whatever you want

Which one should you pick? That's pretty easy and defined by one factor:

  • If you / your sensors and other boards use the RFM95 modules and the Arduino-LoRa library: Use the E32 version!
  • If you usually use EByte modules that use serial communication and Renzo Mischiantis famous Arduino library: Use the E220 version.

You need to choose between those, as the EByte modules that use serial communication can't communicate with the RFM95 modules, although they use the same Semtech SX1276 LoRa chip. That's because the EByte serial-operated modules also have a litte MCU onboard that already does its own "stuff" / protocol when sending messages via LoRa. So you don't talk directly to the Semtech chip, but that little MCU instead. One would need to understand how exactly that works to read these messages with a LoRa modules that uses direct SPI communication to the Semtech chip (like the specific E32 module I use, or the RFM95) to make them work with each other.

LoRa-Gateway-E32

LoRa-Gateway-E32 This version is based on the EByte E32-400M20S or E32-900M20S, which offers direct serial communicaton to the Semtech SX1276. At the time of last research (begin of 2022), this is the only E-Byte module that works on this PCB, so you can't use any other that uses serial communication: They won't fit on the board / have a different pinout! Pick the right one for your region (tl;dr: 400 for US/Asia, 900 for Europe).

The module is not in the BOM CSV file, you need to get it off AliExpress:

LoRa-Gateway-E220

LoRa-Gateway-E220 If you usually work in the EByte ecosystem with its serial interfaced modules, this board is for you. However I've not done a port of my E32 based software for this board. And I'm actually not planning to do so, as I personally use the E32 version. But you're welcome to port it using Renzo Mischiantis Arduino library.

The module is not in the BOM CSV file, you need to get it off AliExpress:

Source Code / Software

The software I've developed for this is meant to be easily extensible without touching the actual logic of the gateway itself, but instead adding a little piece of code to a separate file.

Take a look at lora-ids.h. This file is meant to be shared between this gateway and all sensors you develop. It has a list of different message types and you can easily add your own. E.g., it has a "mailbox" type which defines a few properties a mailbox would send. This makes it very easy to read and process this messages and create topics in your MQTT server which you then can listen to. There's also a "custom" type which basically has free text and is maybe good for debugging.

Feel free to add your own types in this file. You will need to add two things:

  • An ID for it, like #define LORA_MESSAGE_ID_CUSTOM 0x0
  • Define the struct that describes its properties: struct LoRaMessageCustom : LoRaBase

How do the MQTT topics look like I can subscribe to?

The subject where a message falls into is built out of the gateway ID, device ID and message ID. So for the following example we assume that:

  • Device with ID 0xA and name mailbox-sensor has sent
  • a message of type LORA_MESSAGE_ID_MAILBOX and
  • the gateway with ID 0x1 and name lora-gateway-e32 receives it.

So let's first take the mailbox message type as an example. It define these properties:

  • long duration
  • float distance
  • float humidity
  • float temperature

Additionally, it defines its own name (and with that: The parent for these properties):

  • String getMqttTopicName() { return "mailbox"; }

So whenever the gateway will receive a message of this type, it will read the properties from it and drop them into these topics:

  • ???/messages/mailbox/duration
  • ???/messages/mailbox/distance
  • ???/messages/mailbox/humidity
  • ???/messages/mailbox/temperature

But where does the /messages/ part come form and what is ???/. That's easy: Easy device / sensor you develop should also be registered in lora-ids.h. At the very top, there is list of devices, each with:

  • Device ID
  • Device name (which affectively is used to construct the MQTT topic)

The gateway will sort all messages it receives by device and prefixes it with that device name, plus sorts all messages under a messages topic to allow the device have other topics next to the actual messages. This allows you to listen to specific fields/values of specific message types from a specific device!

So we now know this:

  • ???/mailbox-sensor/messages/mailbox/duration
  • ???/mailbox-sensor/messages/mailbox/distance
  • ???/mailbox-sensor/messages/mailbox/humidity
  • ???/mailbox-sensor/messages/mailbox/temperature

The last missing piece is the gateway that receives the messages. It's also defined as a device, so it also has a name, so we can easily construct the full topic name for our example:

  • lora-gateway-e32/devices/mailbox-sensor/messages/mailbox/duration
  • lora-gateway-e32/devices/mailbox-sensor/messages/mailbox/distance
  • lora-gateway-e32/devices/mailbox-sensor/messages/mailbox/humidity
  • lora-gateway-e32/devices/mailbox-sensor/messages/mailbox/temperature

Now you can easily:

  • Add your own devices by:
    • Adding it to the LORA_DEVICE_IDS with an ID and name
  • Add new message types by:
    • Define an ID for it
    • Define the struct that describes it

How can I actually send messages?

Take a look at the sendLoRaMessage function: bool sendLoRaMessage(byte messageID, LoRaBase *loRaMessage, byte recipientId = 0, byte senderId = 0) It expects us to give it:

  • The message ID we're going to send
  • As also the message itself

We can also optionally specify:

  • The recipientId of this message. If not specified, it defaults to LORA_GATEWAY_ID
  • The senderId, which defaults to LORA_DEVICE_ID, if not specified

So in your code, simply create an instance of the message ID you want to send and pass it to sendLoRaMessage:

text
LoRaMessageMailbox *loRaMessage = new LoRaMessageMailbox;
loRaMessage->duration = duration;
loRaMessage->distance = distance;
loRaMessage->humidity = humidity;
loRaMessage->temperature = temperature;

sendLoRaMessage(LORA_MESSAGE_ID_MAILBOX, loRaMessage);

And that's it :)

How does it work under the hood?

For this we take a look at how the actual message is constructed that is sent via LoRa. The basic idea is stolen from the Arduino-LoRa library, which uses singly bytes to identify senders, receivers, etc.

Looking at a single message:

  • 1st byte is the recipient ID
    • This can also be set to 0xFF, which indicates a broadcase message that is received and can be processed by all devices.
  • 2nd byte is the sender ID
  • 3rd byte is the message ID
  • 4th-255th byte is the message we will split up
    • The message simply has all values joined together by a |. So taking the mailbox message example from above, the value for the message could look like this: 12345|3.56|44.55|27.4

Parts

15
QtyValueFootprintReferences
4M2.5MountingHole:MountingHole_2.5mm_Pad_ViaH1, H2, H3, H4
34,7kΩResistor_SMD:R_0805_2012MetricR1, R2, R3
210µFCapacitor_SMD:C_0805_2012MetricC1, C2
11AFuse:Fuse_1812_4532MetricF1
1Conn_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ1
1EByte E220-400/900T22SAndys-Footprints:E-Byte-E220-xxxT22SU2
1ESP32_DevKit_V1_DOITAndys-Footprints:esp32_devkit_v1_doit-less-silkscreenU1
1Jumper_3_OpenConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJP1
1QuinLED-ESP32-ETH-HatQuinLED:QuinLED-ESP32-ETH-HatU3

More from ezcGman/lora-gateway

1
  • 2 layers65.4 × 63 mmLoRa Gateway E32, the printed circuit board in 3D

    LoRa Gateway E32

    ezcGman/lora-gateway

    Gateway to create a bridge between your LoRa devices and Wi-Fi or Ethernet. Also comes with ready-to-use code to drop everything into your MQTT server!

    12 parts39

Similar boards

  • 2 layers40.9 × 85 mmStudio mic, the printed circuit board in 3D

    Studio mic

    Spirit532/studio_mic

    A simple, easy to build preamplifier for any true condenser capsule, to make a condenser microphone

    63 parts150MIT
  • 2 layers65 × 56 mmPi1541io, the printed circuit board in 3D

    Pi1541io

    hackup/Pi1541io

    Raspberry Pi extension board for the PI1541 project.

    57 parts109CC-BY-SA-4.0
  • 2 layers65 × 56 mmClumsyMIDI, the printed circuit board in 3D

    ClumsyMIDI

    gmcn42/clumsyMIDI

    A THT-only Raspberry Pi expansion board containing a MIDI interface, DAC, and OLED display

    26 parts90CC-BY-SA-4.0
  • 6 layers203 × 151.8 mmPDNode Baseboard, the printed circuit board in 3D

    PDNode Baseboard

    DvidMakesThings/HW_PDNode-600-Pro

    The PDNode-600 is a professional-grade, 600W USB Power Delivery Unit designed specifically for compact 10-inch rack systems, targeting embedded developers, homelab enthusiasts, test benches, and smart infrastructure.

    236 parts86AGPL-3.0
  • 4 layers60 × 127 mmOpenHT RF, the printed circuit board in 3D

    OpenHT RF

    M17-Project/OpenHT-hw

    Repository for the hardware parts of the OpenHT project

    199 parts63
  • 2 layers85 × 56.5 mmModemHAT, the printed circuit board in 3D

    ModemHAT

    astuder/ModemHAT

    Classic Phone Modem HAT for the Raspberry Pi

    111 parts56
  • 4 layers70 × 60 mmMarelleo, the printed circuit board in 3D

    Marelleo

    Zebra-Rodeo/marelleo

    Une boîte qui raconte une histoire quand on pose une figurine dessus. Boîtier, carte, micrologiciel et doc pour la refaire.

    57 parts47
  • 2 layers285.8 × 124.6 mmPunk75, the printed circuit board in 3D

    Punk75

    dsanchezseco/punk75

    Ortholinear keyboard with 75 keys and all components through hole

    194 parts44GPL-3.0

Questions

How big is the LoRa Gateway E220 PCB?

It measures 65.4 × 63 mm and has 2 copper layers, 1.6 mm thick.

What parts does the LoRa Gateway E220 use?

15 parts, built around the M2.5. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the LoRa Gateway E220 KiCad files?

From the ezcGman/lora-gateway repository on GitHub, at the commit this page was made from: the board is pcbs/LoRa-Gateway-E220/LoRa-Gateway-E220.kicad_pcb and its schematic pcbs/LoRa-Gateway-E220/LoRa-Gateway-E220.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the LoRa Gateway E220 design in my own project?

Its repository states no licence, so its author keeps all rights: ask ezcGman before reusing the design.