mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-10 07:10:42 +00:00
This is a tested version of the example files
This commit is contained in:
parent
fc117c1f42
commit
ccf1123032
@ -4,7 +4,7 @@
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
|
||||
//
|
||||
#include "sensor_setup.h"
|
||||
#include "sensor_config.h"
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <espnow.h>
|
||||
@ -18,6 +18,19 @@
|
||||
#include <LoRa.h>
|
||||
#endif
|
||||
|
||||
#ifdef GLOBALS
|
||||
#define FDRS_BAND GLOBAL_BAND
|
||||
#define FDRS_SF GLOBAL_SF
|
||||
#else
|
||||
#define FDRS_BAND BAND
|
||||
#define FDRS_SF SF
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(a) (Serial.println(a))
|
||||
#else
|
||||
#define DBG(a)
|
||||
#endif
|
||||
typedef struct __attribute__((packed)) DataReading {
|
||||
float d;
|
||||
uint16_t id;
|
||||
@ -77,16 +90,16 @@ void beginFDRS() {
|
||||
#endif
|
||||
#ifdef USE_LORA
|
||||
DBG("Initializing LoRa!");
|
||||
DBG(GLOBAL_BAND);
|
||||
DBG(FDRS_BAND);
|
||||
DBG(SF);
|
||||
#ifndef __AVR__
|
||||
SPI.begin(SCK, MISO, MOSI, SS);
|
||||
#endif
|
||||
LoRa.setPins(SS, RST, DIO0);
|
||||
if (!LoRa.begin(BAND)) {
|
||||
if (!LoRa.begin(FDRS_BAND)) {
|
||||
while (1);
|
||||
}
|
||||
LoRa.setSpreadingFactor(SF);
|
||||
LoRa.setSpreadingFactor(FDRS_SF);
|
||||
DBG(" LoRa Initialized.");
|
||||
#endif
|
||||
}
|
||||
|
@ -4,14 +4,16 @@
|
||||
//
|
||||
#include <fdrs_globals.h> //Uncomment if you install the globals file
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x00 //Address of the nearest gateway
|
||||
#define DEBUG
|
||||
|
||||
#define USE_ESPNOW
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x04 //Address of the nearest gateway
|
||||
|
||||
//#define USE_ESPNOW
|
||||
#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define DEBUG
|
||||
|
||||
|
||||
//LoRa Configuration
|
||||
#define SCK 5
|
||||
|
@ -4,12 +4,6 @@
|
||||
#define DBG(a)
|
||||
#endif
|
||||
|
||||
#if defined (ESP32)
|
||||
#define UART_IF Serial1
|
||||
#else
|
||||
#define UART_IF Serial
|
||||
#endif
|
||||
|
||||
#ifdef GLOBALS
|
||||
#define FDRS_BAND GLOBAL_BAND
|
||||
#define FDRS_SF GLOBAL_SF
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define DEBUG
|
||||
#define CREDENTIALS
|
||||
|
||||
#include <fdrs_globals.h>
|
||||
#include "fdrs_config.h"
|
||||
|
||||
#ifdef ESP8266
|
||||
|
@ -18,9 +18,9 @@
|
||||
#define USE_LORA
|
||||
//#define USE_WIFI //Used only for MQTT gateway
|
||||
|
||||
//#define WIFI_SSID "Your SSID"
|
||||
//#define WIFI_PASS "Your Password"
|
||||
//#define MQTT_ADDR "192.168.0.8"
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
#define MQTT_ADDR "192.168.0.8"
|
||||
|
||||
// Peer addresses
|
||||
#define ESPNOW1_PEER 0x04 // ESPNOW1 Address
|
||||
@ -34,9 +34,13 @@
|
||||
#define LORA1_ACT
|
||||
#define LORA2_ACT
|
||||
|
||||
//Pins for UART data interface (ESP32 only)
|
||||
#if defined (ESP32)
|
||||
#define RXD2 14
|
||||
#define TXD2 15
|
||||
#define UART_IF Serial2
|
||||
#else
|
||||
#define UART_IF Serial
|
||||
#endif
|
||||
|
||||
//LoRa Configuration -- Needed only if using LoRa
|
||||
#define SCK 5
|
||||
|
@ -10,13 +10,13 @@
|
||||
//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 ESPNOWG_ACT sendSerial();
|
||||
#define SERIAL_ACT //sendMQTT();
|
||||
#define ESPNOWG_ACT
|
||||
#define SERIAL_ACT sendMQTT();
|
||||
#define MQTT_ACT
|
||||
#define LORAG_ACT sendSerial();
|
||||
#define LORAG_ACT
|
||||
|
||||
//#define USE_LORA
|
||||
//#define USE_WIFI //Used only for MQTT gateway
|
||||
#define USE_WIFI //Used only for MQTT gateway
|
||||
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
|
Loading…
Reference in New Issue
Block a user