mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-10 07:10:42 +00:00
commit
9cd5972b64
@ -49,7 +49,7 @@ void setup() {
|
||||
delay(500);
|
||||
}
|
||||
DBG("WiFi Connected");
|
||||
client.setServer(mqtt_server, 1883);
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
if (!client.connected()) {
|
||||
DBG("Connecting MQTT...");
|
||||
reconnect();
|
||||
|
@ -34,6 +34,13 @@
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
#define MQTT_ADDR "192.168.0.8"
|
||||
#define MQTT_PORT 1883 // Default MQTT port is 1883
|
||||
|
||||
//MQTT Credentials -- Needed only if MQTT broker requires authentication
|
||||
//#define MQTT_AUTH //uncomment to enable MQTT authentication
|
||||
#define MQTT_USER "Your MQTT Username"
|
||||
#define MQTT_PASS "Your MQTT Password"
|
||||
|
||||
// MQTT Topics
|
||||
#define TOPIC_DATA "fdrs/data"
|
||||
#define TOPIC_STATUS "fdrs/status"
|
||||
|
@ -14,16 +14,26 @@
|
||||
#define FDRS_WIFI_SSID GLOBAL_SSID
|
||||
#define FDRS_WIFI_PASS GLOBAL_PASS
|
||||
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
|
||||
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
|
||||
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
|
||||
#define FDRS_BAND GLOBAL_BAND
|
||||
#define FDRS_SF GLOBAL_SF
|
||||
#else
|
||||
#define FDRS_WIFI_SSID WIFI_SSID
|
||||
#define FDRS_WIFI_PASS WIFI_PASS
|
||||
#define FDRS_MQTT_ADDR MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT MQTT_PORT
|
||||
#define FDRS_MQTT_USER MQTT_USER
|
||||
#define FDRS_MQTT_PASS MQTT_PASS
|
||||
#define FDRS_BAND BAND
|
||||
#define FDRS_SF SF
|
||||
#endif
|
||||
|
||||
#if defined (MQTT_AUTH) || defined (GLOBAL_MQTT_AUTH)
|
||||
#define FDRS_MQTT_AUTH
|
||||
#endif
|
||||
|
||||
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE // Should only be changed if implementing multiple FDRS systems.
|
||||
|
||||
typedef struct __attribute__((packed)) DataReading {
|
||||
@ -100,8 +110,15 @@ PubSubClient client(espClient);
|
||||
const char* ssid = FDRS_WIFI_SSID;
|
||||
const char* password = FDRS_WIFI_PASS;
|
||||
const char* mqtt_server = FDRS_MQTT_ADDR;
|
||||
const int mqtt_port = FDRS_MQTT_PORT;
|
||||
#endif
|
||||
#ifdef FDRS_MQTT_AUTH
|
||||
const char* mqtt_user = FDRS_MQTT_USER;
|
||||
const char* mqtt_pass = FDRS_MQTT_PASS;
|
||||
#else
|
||||
const char* mqtt_user = NULL;
|
||||
const char* mqtt_pass = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
|
||||
#if defined(ESP8266)
|
||||
@ -482,7 +499,7 @@ void reconnect() {
|
||||
// Loop until reconnected
|
||||
while (!client.connected()) {
|
||||
// Attempt to connect
|
||||
if (client.connect("FDRS_GATEWAY")) {
|
||||
if (client.connect("FDRS_GATEWAY", mqtt_user, mqtt_pass)) {
|
||||
// Subscribe
|
||||
client.subscribe(TOPIC_COMMAND);
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ void setup() {
|
||||
delay(500);
|
||||
}
|
||||
DBG("WiFi Connected");
|
||||
client.setServer(mqtt_server, 1883);
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
if (!client.connected()) {
|
||||
DBG("Connecting MQTT...");
|
||||
reconnect();
|
||||
|
@ -34,6 +34,13 @@
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
#define MQTT_ADDR "192.168.0.8"
|
||||
#define MQTT_PORT 1883 // Default MQTT port is 1883
|
||||
|
||||
//MQTT Credentials -- Needed only if MQTT broker requires authentication
|
||||
//#define MQTT_AUTH //uncomment to enable MQTT authentication
|
||||
#define MQTT_USER "Your MQTT Username"
|
||||
#define MQTT_PASS "Your MQTT Password"
|
||||
|
||||
// MQTT Topics
|
||||
#define TOPIC_DATA "fdrs/data"
|
||||
#define TOPIC_STATUS "fdrs/status"
|
||||
|
@ -14,16 +14,26 @@
|
||||
#define FDRS_WIFI_SSID GLOBAL_SSID
|
||||
#define FDRS_WIFI_PASS GLOBAL_PASS
|
||||
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
|
||||
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
|
||||
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
|
||||
#define FDRS_BAND GLOBAL_BAND
|
||||
#define FDRS_SF GLOBAL_SF
|
||||
#else
|
||||
#define FDRS_WIFI_SSID WIFI_SSID
|
||||
#define FDRS_WIFI_PASS WIFI_PASS
|
||||
#define FDRS_MQTT_ADDR MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT MQTT_PORT
|
||||
#define FDRS_MQTT_USER MQTT_USER
|
||||
#define FDRS_MQTT_PASS MQTT_PASS
|
||||
#define FDRS_BAND BAND
|
||||
#define FDRS_SF SF
|
||||
#endif
|
||||
|
||||
#if defined (MQTT_AUTH) || defined (GLOBAL_MQTT_AUTH)
|
||||
#define FDRS_MQTT_AUTH
|
||||
#endif
|
||||
|
||||
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE // Should only be changed if implementing multiple FDRS systems.
|
||||
|
||||
typedef struct __attribute__((packed)) DataReading {
|
||||
@ -100,8 +110,15 @@ PubSubClient client(espClient);
|
||||
const char* ssid = FDRS_WIFI_SSID;
|
||||
const char* password = FDRS_WIFI_PASS;
|
||||
const char* mqtt_server = FDRS_MQTT_ADDR;
|
||||
const int mqtt_port = FDRS_MQTT_PORT;
|
||||
#endif
|
||||
#ifdef FDRS_MQTT_AUTH
|
||||
const char* mqtt_user = FDRS_MQTT_USER;
|
||||
const char* mqtt_pass = FDRS_MQTT_PASS;
|
||||
#else
|
||||
const char* mqtt_user = NULL;
|
||||
const char* mqtt_pass = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
|
||||
#if defined(ESP8266)
|
||||
@ -482,7 +499,7 @@ void reconnect() {
|
||||
// Loop until reconnected
|
||||
while (!client.connected()) {
|
||||
// Attempt to connect
|
||||
if (client.connect("FDRS_GATEWAY")) {
|
||||
if (client.connect("FDRS_GATEWAY", mqtt_user, mqtt_pass)) {
|
||||
// Subscribe
|
||||
client.subscribe(TOPIC_COMMAND);
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ void setup() {
|
||||
delay(500);
|
||||
}
|
||||
DBG("WiFi Connected");
|
||||
client.setServer(mqtt_server, 1883);
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
if (!client.connected()) {
|
||||
DBG("Connecting MQTT...");
|
||||
reconnect();
|
||||
|
@ -67,6 +67,13 @@
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
#define MQTT_ADDR "192.168.0.8"
|
||||
#define MQTT_PORT 1883 // Default MQTT port is 1883
|
||||
|
||||
//MQTT Credentials -- Needed only if MQTT broker requires authentication
|
||||
//#define MQTT_AUTH //uncomment to enable MQTT authentication
|
||||
#define MQTT_USER "Your MQTT Username"
|
||||
#define MQTT_PASS "Your MQTT Password"
|
||||
|
||||
// MQTT Topics
|
||||
#define TOPIC_DATA "fdrs/data"
|
||||
#define TOPIC_STATUS "fdrs/status"
|
||||
|
@ -14,16 +14,26 @@
|
||||
#define FDRS_WIFI_SSID GLOBAL_SSID
|
||||
#define FDRS_WIFI_PASS GLOBAL_PASS
|
||||
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
|
||||
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
|
||||
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
|
||||
#define FDRS_BAND GLOBAL_BAND
|
||||
#define FDRS_SF GLOBAL_SF
|
||||
#else
|
||||
#define FDRS_WIFI_SSID WIFI_SSID
|
||||
#define FDRS_WIFI_PASS WIFI_PASS
|
||||
#define FDRS_MQTT_ADDR MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT MQTT_PORT
|
||||
#define FDRS_MQTT_USER MQTT_USER
|
||||
#define FDRS_MQTT_PASS MQTT_PASS
|
||||
#define FDRS_BAND BAND
|
||||
#define FDRS_SF SF
|
||||
#endif
|
||||
|
||||
#if defined (MQTT_AUTH) || defined (GLOBAL_MQTT_AUTH)
|
||||
#define FDRS_MQTT_AUTH
|
||||
#endif
|
||||
|
||||
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE // Should only be changed if implementing multiple FDRS systems.
|
||||
|
||||
typedef struct __attribute__((packed)) DataReading {
|
||||
@ -100,8 +110,15 @@ PubSubClient client(espClient);
|
||||
const char* ssid = FDRS_WIFI_SSID;
|
||||
const char* password = FDRS_WIFI_PASS;
|
||||
const char* mqtt_server = FDRS_MQTT_ADDR;
|
||||
const int mqtt_port = FDRS_MQTT_PORT;
|
||||
#endif
|
||||
#ifdef FDRS_MQTT_AUTH
|
||||
const char* mqtt_user = FDRS_MQTT_USER;
|
||||
const char* mqtt_pass = FDRS_MQTT_PASS;
|
||||
#else
|
||||
const char* mqtt_user = NULL;
|
||||
const char* mqtt_pass = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
|
||||
#if defined(ESP8266)
|
||||
@ -482,7 +499,7 @@ void reconnect() {
|
||||
// Loop until reconnected
|
||||
while (!client.connected()) {
|
||||
// Attempt to connect
|
||||
if (client.connect("FDRS_GATEWAY")) {
|
||||
if (client.connect("FDRS_GATEWAY", mqtt_user, mqtt_pass)) {
|
||||
// Subscribe
|
||||
client.subscribe(TOPIC_COMMAND);
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ void setup() {
|
||||
delay(500);
|
||||
}
|
||||
DBG("WiFi Connected");
|
||||
client.setServer(mqtt_server, 1883);
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
if (!client.connected()) {
|
||||
DBG("Connecting MQTT...");
|
||||
reconnect();
|
||||
|
@ -67,6 +67,13 @@
|
||||
#define WIFI_SSID "Your SSID"
|
||||
#define WIFI_PASS "Your Password"
|
||||
#define MQTT_ADDR "192.168.0.8"
|
||||
#define MQTT_PORT 1883 // Default MQTT port is 1883
|
||||
|
||||
//MQTT Credentials -- Needed only if MQTT broker requires authentication
|
||||
//#define MQTT_AUTH //uncomment to enable MQTT authentication
|
||||
#define MQTT_USER "Your MQTT Username"
|
||||
#define MQTT_PASS "Your MQTT Password"
|
||||
|
||||
// MQTT Topics
|
||||
#define TOPIC_DATA "fdrs/data"
|
||||
#define TOPIC_STATUS "fdrs/status"
|
||||
|
@ -19,16 +19,26 @@
|
||||
#define FDRS_WIFI_SSID GLOBAL_SSID
|
||||
#define FDRS_WIFI_PASS GLOBAL_PASS
|
||||
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
|
||||
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
|
||||
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
|
||||
#define FDRS_BAND GLOBAL_BAND
|
||||
#define FDRS_SF GLOBAL_SF
|
||||
#else
|
||||
#define FDRS_WIFI_SSID WIFI_SSID
|
||||
#define FDRS_WIFI_PASS WIFI_PASS
|
||||
#define FDRS_MQTT_ADDR MQTT_ADDR
|
||||
#define FDRS_MQTT_PORT MQTT_PORT
|
||||
#define FDRS_MQTT_USER MQTT_USER
|
||||
#define FDRS_MQTT_PASS MQTT_PASS
|
||||
#define FDRS_BAND BAND
|
||||
#define FDRS_SF SF
|
||||
#endif
|
||||
|
||||
#if defined (MQTT_AUTH) || defined (GLOBAL_MQTT_AUTH)
|
||||
#define FDRS_MQTT_AUTH
|
||||
#endif
|
||||
|
||||
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE // Should only be changed if implementing multiple FDRS systems.
|
||||
|
||||
typedef struct __attribute__((packed)) DataReading {
|
||||
@ -105,8 +115,15 @@ PubSubClient client(espClient);
|
||||
const char* ssid = FDRS_WIFI_SSID;
|
||||
const char* password = FDRS_WIFI_PASS;
|
||||
const char* mqtt_server = FDRS_MQTT_ADDR;
|
||||
const int mqtt_port = FDRS_MQTT_PORT;
|
||||
#endif
|
||||
#ifdef FDRS_MQTT_AUTH
|
||||
const char* mqtt_user = FDRS_MQTT_USER;
|
||||
const char* mqtt_pass = FDRS_MQTT_PASS;
|
||||
#else
|
||||
const char* mqtt_user = NULL;
|
||||
const char* mqtt_pass = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
|
||||
#if defined(ESP8266)
|
||||
@ -487,7 +504,7 @@ void reconnect() {
|
||||
// Loop until reconnected
|
||||
while (!client.connected()) {
|
||||
// Attempt to connect
|
||||
if (client.connect("FDRS_GATEWAY")) {
|
||||
if (client.connect("FDRS_GATEWAY", mqtt_user, mqtt_pass)) {
|
||||
// Subscribe
|
||||
client.subscribe(TOPIC_COMMAND);
|
||||
} else {
|
||||
|
@ -2,6 +2,10 @@
|
||||
#define GLOBAL_PASS "Password"
|
||||
#define GLOBAL_MQTT_ADDR "192.168.0.8"
|
||||
|
||||
//#define GLOBAL_MQTT_AUTH //uncomment to enable MQTT authentication
|
||||
#define GLOBAL_MQTT_USER "Your MQTT Username"
|
||||
#define GLOBAL_MQTT_PASS "Your MQTT Password"
|
||||
|
||||
#define GLOBAL_BAND 915E6 //LoRa Frequency Band
|
||||
#define GLOBAL_SF 7 //LoRa Spreading Factor
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user