working version?

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2023-11-19 22:45:17 +01:00
parent d79c4c3a20
commit 5fe0c22abb
4 changed files with 149 additions and 72 deletions

View File

@@ -14,7 +14,6 @@ void setup() {
// connect pin 3 to ^RE of Max485
// connect pin 4 to DE of Max485
// connect pin 5 to DI of Max485
}
void loop(){

View File

@@ -1,5 +1,7 @@
#include <SoftRS485.h>
int count = 0;
void setup() {
Serial.begin(115200);
Serial.println("This is SendAndReceive 0.1");
@@ -8,11 +10,11 @@ void setup() {
// connect pin 3 to ^RE of Max485
// connect pin 4 to DE of Max485
// connect pin 5 to DI of Max485
while (send485("Hello World!")) {}
}
void loop() {
// put your main code here, to run repeatedly:
if (available485()) Serial.println("Received "+get485message());
delay(5000);
count++;
String s = "Test "+String(count);
send485(s.c_str());
}

View File

@@ -0,0 +1,35 @@
#include <SoftRS485.h>
#include <SimpleDHT.h>
int pinDHT11 = 6;
int count = 0;
SimpleDHT11 dht11(pinDHT11);
void setup() {
Serial.begin(115200);
Serial.println("This is TempSend 0.1");
init485(2,3,4,5); // library initialization:
// connect pin 2 to RO of Max485
// connect pin 3 to ^RE of Max485
// connect pin 4 to DE of Max485
// connect pin 5 to DI of Max485
while (!send485("Hello world!")) {}
}
void loop() {
// read without samples.
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print("Read DHT11 failed, err="); Serial.print(SimpleDHTErrCode(err));
Serial.print(","); Serial.println(SimpleDHTErrDuration(err)); delay(1000);
return;
}
count++;
String s = String(count)+" - Sample OK: "+ String(temperature)+" *C, "+String(humidity)+"% rel";
send485(s.c_str());
delay(5000);
}