Farm-Data-Relay-System/FDRS_Gateway/README.md

65 lines
3.6 KiB
Markdown
Raw Normal View History

2022-07-02 11:41:23 +00:00
# FDRS Gateway
2022-06-09 01:48:20 +00:00
The FDRS Gateway listens for packets over ESP-NOW, UART, LoRa, and/or MQTT, then retransmits the packets over these interfaces using rules defined in the "Actions" section of the configuration file.
## Actions
2022-06-09 02:17:49 +00:00
Actions define how the gateway reacts to a packet received via each data source. An action may consist of one or multiple commands separated by (and terminated with) semicolons.
The following commands re-send data instantaneously: ```sendESPNOW(MAC)```, ```sendSerial()```, and ```sendMQTT()```.
2022-06-16 12:25:15 +00:00
These commands send data to buffers to be released at an interval: ```bufferLoRa(interface)```, ```bufferESPNOW(interface)```, ```bufferSerial()```, and ```bufferMQTT()```.
2022-06-09 02:17:49 +00:00
2022-06-16 12:25:15 +00:00
In this example, the gateway is set to take any ESP-NOW packet it receives and send it first over the serial port, then re-transmit it via ESP-NOW to another gateway with the address 0x01:
2022-06-09 02:17:49 +00:00
```
#define ESPNOWG_ACT sendSerial(); sendESPNOW(0x01);
```
2022-06-09 01:48:20 +00:00
## Options
### ```#define UNIT_MAC (0xNN)```
The UNIT_MAC is the ESP-NOW and LoRa address of the gateway. This is the address that nodes or other gateways will use to pass data to this device.
### ```#define FDRS_DEBUG```
2022-06-09 01:48:20 +00:00
This definition enables debug messages to be sent over the serial port. If disabled, the USB serial port is still used to echo data being sent via the sendSerial() command.
### ```#define RXD2 (pin)``` and ```TXD2 (pin)```
These are the pins for inter-device serial communication. The single ESP8266 serial interface is not configurable, and thus these options only apply to ESP32 boards.
### ```#define USE_ESPNOW```
Enables ESP-NOW.
USE_ESPNOW and USE_WIFI must not be activated at the same time!
2022-06-09 01:48:20 +00:00
### ```#define USE_LORA```
Enables LoRa. Make sure that you set the LoRa module configuration parameters in the lines below.
2022-07-07 10:37:04 +00:00
LORA_BAND and LORA_SF (spreading factor) can also be configured in 'fdrs_globals.h' if enabled.
2022-06-09 01:48:20 +00:00
### ```#define USE_WIFI```
Enables WiFi. Used only on the MQTT gateway.
SSID, password, and MQTT credentials are also configurable in 'fdrs_globals.h'.
2022-07-06 14:14:01 +00:00
### ```#define USE_SD_LOG```
Enables SD-card logging. Used only on the MQTT gateway if sending the MQTT message fails. Make sure to set the correct SD_SS (chip/slave select) pin in the lines below.
2022-07-06 20:58:28 +00:00
Logging is done in the following CSV Format: ```timestamp,reading_id,datatype,value```
2022-06-09 03:41:41 +00:00
### ```#define USE_LED```
2022-06-09 01:48:20 +00:00
This option initializes FastLED! I haven't developed this very much, perhaps you have ideas?
## Peers
### Routing
In addition to reacting to packets from general (unknown) ESP-NOW and LoRa devices, the gateway can also listen for traffic from a specific peer's device address (MAC) and react differently than it would to general traffic. This can be used to 'propel' packets upstream or downstream and allows the user to define different paths for data originating from either direction. The user can define up to two peer addresses each for the ESP-NOW and LoRa interfaces (ESPNOW1 & ESPNOW2 and LORA1 & LORA2).
### Buffers
2022-06-09 02:17:49 +00:00
Each peer also has a send buffer associated with it. Buffers are enabled by uncommenting their corresponding DELAY macro (ex: ```#define LORAG_DELAY 1000```). When enabled, the gateway will automatically send the buffer contents at the interval specified.
2022-06-09 01:48:20 +00:00
2022-06-09 02:17:49 +00:00
While ESP-NOW is quick enough to handle a lot of traffic in real-time, LoRa is much slower. For this reason, you must send LoRa data to a buffer. Since buffers are mandatory, a LoRa repeater always needs to be configured using a LoRa peer.
Buffers can hold a maximum of 256 DataReadings.
2022-06-09 01:48:20 +00:00
2022-01-30 03:13:02 +00:00
2022-05-21 13:00:55 +00:00
2022-06-30 13:30:24 +00:00
![Basic](/FDRS_Gateway/Basic_Setup.png)
2022-02-22 14:14:02 +00:00
2022-06-30 13:30:24 +00:00
![Advanced](/FDRS_Gateway/Advanced_Setup.png)
2022-02-22 14:14:02 +00:00
2022-06-30 13:30:24 +00:00
![Basic LoRa](/FDRS_Gateway/Basic_LoRa_Setup.png)
2022-02-22 14:14:02 +00:00
2022-06-30 13:30:24 +00:00
![Advanced LoRa](/FDRS_Gateway/Advanced_Setup_LoRa.png)