Hallo kann mir da jemand helfen,
ich habe an einem Arduino_uno einen DHT12 Sensor den ich via USB mit Fhem auslesen möchte.
Da ich leider kein Perl programmieren kann , habe ich mir das aus diesem Wiki Beitrag(https://wiki.fhem.de/wiki/ECMD) herauskopiert.
Aus dem FileLog
- 2021.05.24 13:41:55 5: Arduino_DHT12: Spontaneously received 123 (\061\062\063)
2021.05.24 13:41:55 5: Arduino_DHT12: dispatch 123
2021.05.24 13:41:55 5: Arduino_DHT12: merging partial message 1234 T20.00°C H48.00%RH\r\n (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122\110\015\012) and 123 (\061\062\063)
2021.05.24 13:41:55 5: Arduino_DHT12: 1234 T20.00°C H48.00%RH\r\n123 (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122\110\015\012\061\062\063) split into 2 parts
2021.05.24 13:41:55 5: Arduino_DHT12: trying to match message 1234 T20.00°C H48.00%RH\r\n (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122\110\015\012)
2021.05.24 13:41:55 5: Arduino_DHT12: trying to match message 123 (\061\062\063)
2021.05.24 13:41:55 5: Arduino_DHT12: partial message 123 (\061\062\063) kept
2021.05.24 13:41:55 5: Arduino_DHT12: Spontaneously received 4 T20.00 (\064\040\124\062\060\056\060\060)
2021.05.24 13:41:55 5: Arduino_DHT12: dispatch 4 T20.00
2021.05.24 13:41:55 5: Arduino_DHT12: merging partial message 123 (\061\062\063) and 4 T20.00 (\064\040\124\062\060\056\060\060)
2021.05.24 13:41:55 5: Arduino_DHT12: trying to match message 1234 T20.00 (\061\062\063\064\040\124\062\060\056\060\060)
2021.05.24 13:41:55 5: Arduino_DHT12: partial message 1234 T20.00 (\061\062\063\064\040\124\062\060\056\060\060) kept
2021.05.24 13:41:55 5: Arduino_DHT12: Spontaneously received °C H48. (\302\260\103\040\110\064\070\056)
2021.05.24 13:41:55 5: Arduino_DHT12: dispatch °C H48.
2021.05.24 13:41:55 5: Arduino_DHT12: merging partial message 1234 T20.00 (\061\062\063\064\040\124\062\060\056\060\060) and °C H48. (\302\260\103\040\110\064\070\056)
2021.05.24 13:41:55 5: Arduino_DHT12: trying to match message 1234 T20.00°C H48. (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056)
2021.05.24 13:41:55 5: Arduino_DHT12: partial message 1234 T20.00°C H48. (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056) kept
2021.05.24 13:41:55 5: Arduino_DHT12: Spontaneously received 00%R (\060\060\045\122)
2021.05.24 13:41:55 5: Arduino_DHT12: dispatch 00%R
2021.05.24 13:41:55 5: Arduino_DHT12: merging partial message 1234 T20.00°C H48. (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056) and 00%R (\060\060\045\122)
2021.05.24 13:41:55 5: Arduino_DHT12: trying to match message 1234 T20.00°C H48.00%R (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122)
2021.05.24 13:41:55 5: Arduino_DHT12: partial message 1234 T20.00°C H48.00%R (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122) kept
2021.05.24 13:41:55 5: Arduino_DHT12: Spontaneously received H\r\n (\110\015\012)
2021.05.24 13:41:55 5: Arduino_DHT12: dispatch H\r\n
2021.05.24 13:41:55 5: Arduino_DHT12: merging partial message 1234 T20.00°C H48.00%R (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122) and H\r\n (\110\015\012)
2021.05.24 13:41:55 5: Arduino_DHT12: trying to match message 1234 T20.00°C H48.00%RH\r\n (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122\110\015\012)
2021.05.24 13:41:55 5: Arduino_DHT12: partial message 1234 T20.00°C H48.00%RH\r\n (\061\062\063\064\040\124\062\060\056\060\060\302\260\103\040\110\064\070\056\060\060\045\122\110\015\012) kept
Mein Arduino Sketch sieht so aus
- //2018.6.28
#include <dht_nonblocking.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2 );
#define DHT_SENSOR_TYPE DHT_TYPE_11
//#define DHT_SENSOR_TYPE DHT_TYPE_21
//#define DHT_SENSOR_TYPE DHT_TYPE_22
static const int DHT_SENSOR_PIN = 8;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );
void setup( ){
lcd.begin (16, 2);
Serial.begin( 9600);
}
void loop( )
{
float temperature;
float humidity;
if(dht_sensor.measure(&temperature, &humidity)){
Serial.print("1234 ");
Serial.print( "T" );
Serial.print(temperature);
Serial.print( "°C " );
Serial.print( "H" );
Serial.print(humidity);
Serial.println( "%RH" );
delay (5000);
lcd. clear ();
lcd. setCursor(0, 0);
lcd. print ("Temperatur=");
lcd. print (temperature, 1 );
lcd. print ( "C" );
lcd. setCursor(0, 1);
lcd. print ("Feuchte = ");
lcd. print (humidity, 1 );
lcd. print ( " %," );
}
}
Und das ist meine classdev
- params devId1234
reading temperature match "%devId[^\n]+\n"
reading temperature postproc { /%devId[^T]+T([-+.,0-9]+).*/; $1 }
reading humidity match "%devId[^\n]+\n"
reading humidity postproc { /%devId[^H]+H([-+.,0-9]+).*/; $1 }
state humidity
Raw Definition
- defmod Arduino_DHT12 ECMD serial /dev/ttyACM1@9600
attr Arduino_DHT12 classdefs DHT12=opt/fhem/DHT12.classdef
attr Arduino_DHT12 partial 200
attr Arduino_DHT12 room Arduino
attr Arduino_DHT12 split \r\n
attr Arduino_DHT12 verbose 5
setstate Arduino_DHT12 opened
setstate Arduino_DHT12 2021-05-24 13:38:22 state opened
Und im Eventmonitor
steht ab und an
2021-05-24 13:44:34 ECMD Arduino_DHT12 UNKNOWNCODE
Kann mir da jemand weiterhelfen????
Gruß Arno