Skip to content

Commit 7a310e3

Browse files
committed
Merge branch 'master' of github.com:ezcGman/lora-gateway
2 parents 6241100 + 5a0f25a commit 7a310e3

File tree

2 files changed

+29
-4354
lines changed

2 files changed

+29
-4354
lines changed

README.md

+29-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
# LoRa-To-MQTT Gateway
22
## Introduction
33
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:
4-
- One with an EByte E32
5-
- One with EByte E220
4+
- One using an EByte E32
5+
- One using an EByte E220
66

77
For giving the board Ethernet capability, I'm using the [QuinLED ESP32 Ethernet Hat](https://quinled.info/quinled-esp32-ethernet/). Of course, It's natural that I *should* have also used a [QuinLed ESP32](https://quinled.info/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.
88

99
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.
1010

1111
## What do I need to do to get one?
12-
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 **impossible** to solder it with just an iron.
12+
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!
1313

1414
### 1. Get the PCBs
1515
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.
1616

1717
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!
1818

1919
### 2. Get the components
20-
* **TBD:** I'll generate a BOM file per board version and throw it into its respective folder
21-
* Components you need for both boards:
20+
* Look up the iBOM files to get a list of components you need:
21+
* [E32 version iBOM](https://github.com/ezcGman/lora-gateway/blob/master/pcbs/LoRa-Gateway-E32/ibom/LoRa-Gateway-E32.html)
22+
* [E220 version iBOM](https://github.com/ezcGman/lora-gateway/blob/master/pcbs/LoRa-Gateway-E220/ibom/LoRa-Gateway-E220.html)
23+
* Additional links for the ESP32 and QuinLED Ethernet hat:
2224
* Regular ESP 32 DevKit (pick one with 2x15 pins!!): https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20220311122647&SearchText=esp32+devkit
2325
* *(optional, if you want Ethernet)* QuinLED ESP32 with Ethernet hat:
2426
* Worldwide store: https://shop.allnetchina.cn/collections/quinled/products/quinled-esp32
@@ -30,7 +32,7 @@ Each PCB folder has an iBOM HTML file which gives you nice soldering instruction
3032
### 4. Install the software
3133
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.
3234

33-
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.
35+
How you can now have your sensors and boards have LoRa messages sent to it can be found in the ["Source Code / Software"](#source-code--software) section below.
3436

3537
## PCBs
3638
### General design
@@ -131,7 +133,27 @@ Now you can easily:
131133
* Define the struct that describes it
132134

133135
### How can I actually send messages?
134-
TBD actual example here after we refactored sending
136+
Take a look at the [`sendLoRaMessage`](/src/lora-gateway-e32/lora-ids.h#L160) function:
137+
`bool sendLoRaMessage(byte messageID, LoRaBase *loRaMessage, byte recipientId = 0, byte senderId = 0)`
138+
It expects us to give it:
139+
* The message ID we're going to send
140+
* As also the message itself
141+
142+
We can also optionally specify:
143+
* The recipientId of this message. If not specified, it defaults to `LORA_GATEWAY_ID`
144+
* The senderId, which defaults to `LORA_DEVICE_ID`, if not specified
145+
146+
So in your code, simply create an instance of the message ID you want to send and pass it to `sendLoRaMessage`:
147+
```
148+
LoRaMessageMailbox *loRaMessage = new LoRaMessageMailbox;
149+
loRaMessage->duration = duration;
150+
loRaMessage->distance = distance;
151+
loRaMessage->humidity = humidity;
152+
loRaMessage->temperature = temperature;
153+
154+
sendLoRaMessage(LORA_MESSAGE_ID_MAILBOX, loRaMessage);
155+
```
156+
And that's it :)
135157

136158
#### How does it work under the hood?
137159
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.
@@ -143,5 +165,3 @@ Looking at a single message:
143165
* 3rd byte is the message ID
144166
* 4th-255th byte is the message we will split up
145167
* 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`
146-
147-
I will soon release my mailbox sensor PCB and source code, so you can see the sender implemeted :)

0 commit comments

Comments
 (0)