mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-10 07:10:42 +00:00
restore again...
This commit is contained in:
parent
7158aee459
commit
ce4bf0fd57
@ -1,133 +0,0 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// GATEWAY 2.000
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
|
||||
//
|
||||
|
||||
#include "fdrs_config.h"
|
||||
|
||||
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <espnow.h>
|
||||
#elif defined(ESP32)
|
||||
#include <esp_now.h>
|
||||
#include <WiFi.h>
|
||||
#include <esp_wifi.h>
|
||||
#endif
|
||||
#include <ArduinoJson.h>
|
||||
#ifdef USE_WIFI
|
||||
#include <PubSubClient.h>
|
||||
#endif
|
||||
#ifdef USE_LORA
|
||||
#include <LoRa.h>
|
||||
#endif
|
||||
#ifdef USE_LED
|
||||
#include <FastLED.h>
|
||||
#endif
|
||||
#include "fdrs_gateway.h"
|
||||
#include "fdrs_config.h"
|
||||
|
||||
#define USE_WIFI
|
||||
|
||||
#ifdef USE_LED
|
||||
CRGB leds[NUM_LEDS];
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t selfAddress[6] = {MAC_PREFIX, UNIT_MAC};
|
||||
|
||||
|
||||
#ifdef ESPNOW_PEER_1
|
||||
uint8_t ESPNOW1[] = {MAC_PREFIX, ESPNOW_PEER_1};
|
||||
#else
|
||||
uint8_t ESPNOW1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
#endif
|
||||
#ifdef ESPNOW_PEER_2
|
||||
uint8_t ESPNOW2[] = {MAC_PREFIX, ESPNOW_PEER_2};
|
||||
#else
|
||||
uint8_t ESPNOW2[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LORA_PEER_1
|
||||
uint8_t LoRa1[6] = {MAC_PREFIX, LORA_PEER_1};
|
||||
#endif
|
||||
|
||||
#ifdef LORA_PEER_2
|
||||
uint8_t LoRa2[6] = {MAC_PREFIX, LORA_PEER_2};
|
||||
#endif
|
||||
|
||||
|
||||
MQTT_FDRSGateWay MQTT(WIFI_SSID,WIFI_PASS,MQTT_ADDR,MQTT_PORT);
|
||||
|
||||
ESP_FDRSGateWay ESPNow;
|
||||
|
||||
#if defined(ESP32)
|
||||
Serial_FDRSGateWay SerialGW(&Serial1,115200);
|
||||
#else
|
||||
Serial_FDRSGateWay SerialGW(&Serial,115200);
|
||||
#endif
|
||||
|
||||
LoRa_FDRSGateWay LoRaGW(MISO,MOSI,SCK,SS,RST,DIO0,BAND,SF);
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef USE_LED
|
||||
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
|
||||
leds[0] = CRGB::Blue;
|
||||
FastLED.show();
|
||||
#endif
|
||||
|
||||
MQTT.init();
|
||||
|
||||
ESPNow.init(selfAddress);
|
||||
|
||||
#ifdef ESPNOW_PEER_1
|
||||
ESPNow.add_peer(ESPNOW1);
|
||||
#endif
|
||||
|
||||
#ifdef ESPNOW_PEER_2
|
||||
ESPNow.add_peer(ESPNOW2);
|
||||
#endif
|
||||
|
||||
#if defined(ESP32)
|
||||
SerialGW.init(SERIAL_8N1,RXD2,TXD2);
|
||||
#else
|
||||
SerialGW.init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_LORA
|
||||
LoRaGW.init(selfAddress);
|
||||
#endif
|
||||
|
||||
#ifdef ESPNOW_PEER_1
|
||||
ESPNow.add_peer(ESPNOW1);
|
||||
#endif
|
||||
|
||||
#ifdef ESPNOW_PEER_2
|
||||
ESPNow.add_peer(ESPNOW2);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
LoRaGW.get();
|
||||
SerialGW.get();
|
||||
|
||||
ESPNow.release();
|
||||
MQTT.release();
|
||||
SerialGW.release();
|
||||
LoRaGW.release();
|
||||
|
||||
//It does not matter witch one you call.
|
||||
//it will clear all the data that has been received.
|
||||
ESPNow.flush();
|
||||
MQTT.flush();
|
||||
SerialGW.flush();
|
||||
LoRaGW.flush();
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// GATEWAY 2.000 Configuration
|
||||
|
||||
//#include <fdrs_globals.h> //Uncomment if you install the globals file
|
||||
#define DEBUG
|
||||
|
||||
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE // Should only be changed if implementing multiple FDRS systems.
|
||||
|
||||
#define UNIT_MAC 0x03 // The address of this gateway
|
||||
|
||||
//Actions -- Define what happens when a packet arrives at each interface:
|
||||
//Current function options are: sendESPNOW(MAC), sendSerial(), sendMQTT(), bufferESPNOW(interface), bufferSerial(), and bufferLoRa(interface).
|
||||
|
||||
#define SERIAL_ACT
|
||||
#define MQTT_ACT
|
||||
#define LORAG_ACT
|
||||
|
||||
//#define USE_LORA
|
||||
//#define USE_WIFI //Used only for MQTT gateway
|
||||
|
||||
// Peer addresses
|
||||
|
||||
#define LORA_PEER_1 0x0E // LoRa1 Address
|
||||
#define LORA_PEER_2 0x0F // LoRa2 Address
|
||||
|
||||
#define ESPNOW_PEER_1 0x0C // ESPNOW1 Address
|
||||
#define ESPNOW_PEER_2 0x0D // ESPNOW2 Address
|
||||
|
||||
// Peer Actions
|
||||
#define ESPNOW1_ACT
|
||||
#define ESPNOW2_ACT
|
||||
#define LORA1_ACT
|
||||
#define LORA2_ACT
|
||||
|
||||
//WiFi and MQTT Credentials -- Needed only for MQTT gateway
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
#define MQTT_ADDR "192.168.0.8"
|
||||
#define MQTT_PORT 1883
|
||||
|
||||
//Pins for UART data interface (ESP32 only)
|
||||
#define RXD2 14
|
||||
#define TXD2 15
|
||||
|
||||
//LoRa Configuration -- Needed only if using LoRa
|
||||
#define SCK 5
|
||||
#define MISO 19
|
||||
#define MOSI 27
|
||||
#define SS 18
|
||||
#define RST 14
|
||||
#define DIO0 26
|
||||
//433E6 for Asia
|
||||
//866E6 for Europe
|
||||
//915E6 for North America
|
||||
#define BAND 915E6
|
||||
#define SF 7
|
||||
|
||||
//#define USE_LED //Not yet fully implemented
|
||||
#define LED_PIN 32
|
||||
#define NUM_LEDS 4
|
Loading…
Reference in New Issue
Block a user