working version?
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
35
examples/TempSend/TempSend.ino
Normal file
35
examples/TempSend/TempSend.ino
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user