From 40e785839be5f45abbe3da6207b2887f9418cc75 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Sat, 13 Apr 2024 16:14:48 +0200 Subject: [PATCH 1/4] implemented new code "SerialTransceiver" Signed-off-by: Stephan Richter --- .../SerialTransceiver/SerialTransceiver.ino | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Software/SerialTransceiver/SerialTransceiver.ino diff --git a/Software/SerialTransceiver/SerialTransceiver.ino b/Software/SerialTransceiver/SerialTransceiver.ino new file mode 100644 index 0000000..9d08222 --- /dev/null +++ b/Software/SerialTransceiver/SerialTransceiver.ino @@ -0,0 +1,39 @@ +/* + * Demonstrates how to use LCDisplay in conjunction with SoftRS485: + * + * The main _loop_ of this program listens on the RS485 bus. + * Whenever a message is received from the bus, it is displayed on the LCD. + */ + +// include the library code: +#include + +#define PROGRAM "RS485-Nano Rev 2.0 / Transceiver 1.0" + +#define Max485_RO 3 // read-output of Max485 +#define Max485_RE 5 // not-read-enable of Max485 +#define Max485_DE 9 // data enable of Max485 +#define Max485_DI 8 // data input of Max485 + +String message = ""; + +void setup() { + Serial.begin(115200); + init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization: +} + +void loop() { + if (available485()) { + Serial.println(get485message()); + } + if (Serial.available()) { + // get the new byte: + char c = (char)Serial.read(); + if (c == '\n') { + send485(message.c_str()); + message = ""; + } else { + message += c; + } + } +} From b4278a77af5c4da9bec7e4fcb5a13b00f0732527 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Sat, 13 Apr 2024 17:01:50 +0200 Subject: [PATCH 2/4] updated SerialTransceiver Signed-off-by: Stephan Richter --- Software/SerialTransceiver/SerialTransceiver.ino | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Software/SerialTransceiver/SerialTransceiver.ino b/Software/SerialTransceiver/SerialTransceiver.ino index 9d08222..d1360a3 100644 --- a/Software/SerialTransceiver/SerialTransceiver.ino +++ b/Software/SerialTransceiver/SerialTransceiver.ino @@ -8,27 +8,25 @@ // include the library code: #include -#define PROGRAM "RS485-Nano Rev 2.0 / Transceiver 1.0" - #define Max485_RO 3 // read-output of Max485 #define Max485_RE 5 // not-read-enable of Max485 #define Max485_DE 9 // data enable of Max485 #define Max485_DI 8 // data input of Max485 -String message = ""; +#define PROGRAM "{hw:RS485-Nano rev 2.0,firmware:Transceiver,version:1.0}" +String message = ""; +char c; void setup() { Serial.begin(115200); init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization: + send485(PROGRAM); } void loop() { - if (available485()) { - Serial.println(get485message()); - } + if (available485()) Serial.println(get485message()); if (Serial.available()) { - // get the new byte: - char c = (char)Serial.read(); + c = (char)Serial.read(); if (c == '\n') { send485(message.c_str()); message = ""; From 43558e27cea8b3f43c04e62d6591af4957ac7345 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 23 May 2024 21:43:39 +0200 Subject: [PATCH 3/4] bugfix in SerialTransceiver Signed-off-by: Stephan Richter --- Software/SerialTransceiver/SerialTransceiver.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/SerialTransceiver/SerialTransceiver.ino b/Software/SerialTransceiver/SerialTransceiver.ino index d1360a3..9122edf 100644 --- a/Software/SerialTransceiver/SerialTransceiver.ino +++ b/Software/SerialTransceiver/SerialTransceiver.ino @@ -25,7 +25,7 @@ void setup() { void loop() { if (available485()) Serial.println(get485message()); - if (Serial.available()) { + while (Serial.available()) { c = (char)Serial.read(); if (c == '\n') { send485(message.c_str()); From 10a52cdfd7bdb2042ff986a0305e482fc66cf3d2 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 23 May 2024 21:45:26 +0200 Subject: [PATCH 4/4] preparing code for Device 4 Signed-off-by: Stephan Richter --- Software/Sender/Sender.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Software/Sender/Sender.ino b/Software/Sender/Sender.ino index fee24fd..261fe53 100644 --- a/Software/Sender/Sender.ino +++ b/Software/Sender/Sender.ino @@ -18,11 +18,12 @@ #define Max485_DI 8 // data input of Max485 #define TRESHOLD 1024 -#define ID 0 +#define ID 4 // 0=Test // 1=Arbeitszimmer // 2=Küche // 3=Bad +// 4=Treppenhaus #define DEBUG #define LOG_TO_SERIAL