AskSin++ Library

Begonnen von papa, 08 September 2016, 11:11:25

Vorheriges Thema - Nächstes Thema

rvideobaer

Hallo,

ich versuche einen Temp Sensor zu bauen. Das AskSin++ Library Thema habe ich durchgelesen, aber wenn ich ehrlich bin: Ich habe keine Ahnung von der C++.
Mit dem Beispiel zur DHT.h und dem HM-WDS10-TH-O Sketch habe ich versucht es in gang zu bekommen. Aber es gelingt mir nicht. Vielleicht könnte mal jemand der Ahnung hat über den Code schauen. Ich weiß noch nichtmal ob der Pin für den DHT22 den ich angegeben habe der richtige ist.

//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

// define all device properties
#define DEVICE_ID HMID(0x34,0x56,0x78)
#define DEVICE_SERIAL "papa111111"
#define DEVICE_MODEL  0x00,0x3d
#define DEVICE_FIRMWARE 0x10
#define DEVICE_TYPE DeviceType::THSensor
#define DEVICE_INFO 0x01,0x01,0x00

#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <TimerOne.h>
#include <LowPower.h>

#include <MultiChannelDevice.h>
#include "DHT.h"

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED_PIN 4
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8
#define DHTPIN 6     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

// number of available peers per channel
#define PEERS_PER_CHANNEL 6


// all library classes are placed in the namespace 'as'
using namespace as;

/**
* Configure the used hardware
*/
typedef AvrSPI<10,11,12,13> SPIType;
typedef Radio<SPIType,2> RadioType;
typedef StatusLed<4> LedType;
typedef AskSin<LedType,BatterySensor,RadioType> BaseHal;
class Hal : public BaseHal {
public:
  void init (const HMID& id) {
    BaseHal::init(id);
    // init real time clock - 1 tick per second
    rtc.init();
    // measure battery every 1h
    battery.init(60UL*60,rtc);
    battery.low(22);
    battery.critical(19);
  }

  bool runready () {
    return rtc.runready() || BaseHal::runready();
  }
} hal;

class WeatherEventMsg : public Message {
public:
  void init(uint8_t msgcnt,uint8_t temp,uint8_t humidity, bool batlow) {
    uint8_t t1 = (temp >> 8) & 0x7f;
    uint8_t t2 = temp & 0xff;
    if( batlow == true ) {
      t1 |= 0x80; // set bat low bit
    }
    Message::init(0xc,msgcnt,0x70,BIDI,t1,t2);
    pload[0] = humidity;
  }
};

class WeatherChannel : public Channel<Hal,List1,EmptyList,List4,PEERS_PER_CHANNEL>, public Alarm {

  WeatherEventMsg msg;
  int16_t         temp;
  uint8_t         humidity;
  uint16_t        millis;

public:
  WeatherChannel () : Channel(), Alarm(5), temp(0), humidity(0), millis(0) {}
  virtual ~WeatherChannel () {}

  virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) {
    // wait also for the millis
    if( millis != 0 ) {
      tick = millis2ticks(millis);
      millis = 0; // reset millis
      sysclock.add(*this); // millis with sysclock
    }
    else {
      uint8_t msgcnt = device().nextcount();
      measure();
      msg.init(msgcnt,temp,humidity,device().battery().low());
      device().sendPeerEvent(msg,*this);
//      device().send(msg,device().getMasterID());

      // reactivate for next measure
      HMID id;
      device().getDeviceID(id);
      uint32_t nextsend = delay(id,msgcnt);
      tick = nextsend / 1000; // seconds to wait
      millis = nextsend % 1000; // millis to wait
      rtc.add(*this);
    }
  }

  // here we do the measurement
  void measure () {
    temp = dht.readTemperature();
    humidity = dht.readHumidity();
  }
//  void measure () {
//    DPRINT("Measure...\n");
//    uint8_t;
//        float h = dht.readHumidity();
//  // Read temperature as Celsius (the default)
//  float t = dht.readTemperature();
//  temp = t;
//  humidity = h;
// 
//  }

  // here we calc when to send next value
  uint32_t delay (const HMID& id,uint8_t msgcnt) {
    uint32_t value = ((uint32_t)id) << 8 | msgcnt;
    value = (value * 1103515245 + 12345) >> 16;
    value = (value & 0xFF) + 480;
    value *= 250;

    DDEC(value / 1000);DPRINT(".");DDECLN(value % 1000);

    return value;
  }

  void setup(Device<Hal>* dev,uint8_t number,uint16_t addr) {
    Channel::setup(dev,number,addr);
    rtc.add(*this);
  Serial.begin(9600); //Serielle Verbindung starten
  dht.begin(); //DHT22 Sensor starten
  }

  uint8_t status () const {
    return 0;
  }

  uint8_t flags () const {
    return 0;
  }

};


typedef MultiChannelDevice<Hal,WeatherChannel,1> WeatherType;
WeatherType sdev(0x20);

ConfigButton<WeatherType> cfgBtn(sdev);

void setup () {
  DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
  sdev.init(hal);
  buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
}

void loop() {
  bool worked = hal.runready();
  bool poll = sdev.pollRadio();
  if( worked == false && poll == false ) {
    hal.activity.savePower<SleepRTC>(hal);
  }
}


Auf einem Arduino habe ich über die Serielle Konsole mit dem Beispiel zur DHT.h eine Temp Ausgabe bekommen. Das war schon fast mein größter Erfolg.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

papa

Zitat von: rvideobaer am 28 August 2017, 21:14:24
Hallo,

ich versuche einen Temp Sensor zu bauen. Das AskSin++ Library Thema habe ich durchgelesen, aber wenn ich ehrlich bin: Ich habe keine Ahnung von der C++.
Mit dem Beispiel zur DHT.h und dem HM-WDS10-TH-O Sketch habe ich versucht es in gang zu bekommen. Aber es gelingt mir nicht. Vielleicht könnte mal jemand der Ahnung hat über den Code schauen. Ich weiß noch nichtmal ob der Pin für den DHT22 den ich angegeben habe der richtige ist.

//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

// define all device properties
#define DEVICE_ID HMID(0x34,0x56,0x78)
#define DEVICE_SERIAL "papa111111"
#define DEVICE_MODEL  0x00,0x3d
#define DEVICE_FIRMWARE 0x10
#define DEVICE_TYPE DeviceType::THSensor
#define DEVICE_INFO 0x01,0x01,0x00

#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <TimerOne.h>
#include <LowPower.h>

#include <MultiChannelDevice.h>
#include "DHT.h"

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED_PIN 4
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8
#define DHTPIN 6     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

// number of available peers per channel
#define PEERS_PER_CHANNEL 6


// all library classes are placed in the namespace 'as'
using namespace as;

/**
* Configure the used hardware
*/
typedef AvrSPI<10,11,12,13> SPIType;
typedef Radio<SPIType,2> RadioType;
typedef StatusLed<4> LedType;
typedef AskSin<LedType,BatterySensor,RadioType> BaseHal;
class Hal : public BaseHal {
public:
  void init (const HMID& id) {
    BaseHal::init(id);
    // init real time clock - 1 tick per second
    rtc.init();
    // measure battery every 1h
    battery.init(60UL*60,rtc);
    battery.low(22);
    battery.critical(19);
  }

  bool runready () {
    return rtc.runready() || BaseHal::runready();
  }
} hal;

class WeatherEventMsg : public Message {
public:
  void init(uint8_t msgcnt,uint8_t temp,uint8_t humidity, bool batlow) {
    uint8_t t1 = (temp >> 8) & 0x7f;
    uint8_t t2 = temp & 0xff;
    if( batlow == true ) {
      t1 |= 0x80; // set bat low bit
    }
    Message::init(0xc,msgcnt,0x70,BIDI,t1,t2);
    pload[0] = humidity;
  }
};

class WeatherChannel : public Channel<Hal,List1,EmptyList,List4,PEERS_PER_CHANNEL>, public Alarm {

  WeatherEventMsg msg;
  int16_t         temp;
  uint8_t         humidity;
  uint16_t        millis;

public:
  WeatherChannel () : Channel(), Alarm(5), temp(0), humidity(0), millis(0) {}
  virtual ~WeatherChannel () {}

  virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) {
    // wait also for the millis
    if( millis != 0 ) {
      tick = millis2ticks(millis);
      millis = 0; // reset millis
      sysclock.add(*this); // millis with sysclock
    }
    else {
      uint8_t msgcnt = device().nextcount();
      measure();
      msg.init(msgcnt,temp,humidity,device().battery().low());
      device().sendPeerEvent(msg,*this);
//      device().send(msg,device().getMasterID());

      // reactivate for next measure
      HMID id;
      device().getDeviceID(id);
      uint32_t nextsend = delay(id,msgcnt);
      tick = nextsend / 1000; // seconds to wait
      millis = nextsend % 1000; // millis to wait
      rtc.add(*this);
    }
  }

  // here we do the measurement
  void measure () {
    temp = dht.readTemperature();
    humidity = dht.readHumidity();
  }
//  void measure () {
//    DPRINT("Measure...\n");
//    uint8_t;
//        float h = dht.readHumidity();
//  // Read temperature as Celsius (the default)
//  float t = dht.readTemperature();
//  temp = t;
//  humidity = h;
// 
//  }

  // here we calc when to send next value
  uint32_t delay (const HMID& id,uint8_t msgcnt) {
    uint32_t value = ((uint32_t)id) << 8 | msgcnt;
    value = (value * 1103515245 + 12345) >> 16;
    value = (value & 0xFF) + 480;
    value *= 250;

    DDEC(value / 1000);DPRINT(".");DDECLN(value % 1000);

    return value;
  }

  void setup(Device<Hal>* dev,uint8_t number,uint16_t addr) {
    Channel::setup(dev,number,addr);
    rtc.add(*this);
  Serial.begin(9600); //Serielle Verbindung starten
  dht.begin(); //DHT22 Sensor starten
  }

  uint8_t status () const {
    return 0;
  }

  uint8_t flags () const {
    return 0;
  }

};


typedef MultiChannelDevice<Hal,WeatherChannel,1> WeatherType;
WeatherType sdev(0x20);

ConfigButton<WeatherType> cfgBtn(sdev);

void setup () {
  DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
  sdev.init(hal);
  buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
}

void loop() {
  bool worked = hal.runready();
  bool poll = sdev.pollRadio();
  if( worked == false && poll == false ) {
    hal.activity.savePower<SleepRTC>(hal);
  }
}


Auf einem Arduino habe ich über die Serielle Konsole mit dem Beispiel zur DHT.h eine Temp Ausgabe bekommen. Das war schon fast mein größter Erfolg.

Ohne C++ Kenntinisse wird es natürlich schwer.
Ohne jetzt zu wissen, wie Deine Hardware aussieht, ist es schwer zu helfen. Vor allem wenn es um die Pinbelegung geht.

Aber das Example setzt einen externen 32,768kHz Quarz voraus, um damit das genaue Timing für die Nachrichten zu berechnen. Ich nehme mal an, der ist bei Dir nicht vorhanden. Es müssen somit alle "rtc" Objecte durch "sysclock" ersetzt werden. Sonst wäre es auch sehr praktisch, die Ausgaben der Serial-Console zu sehen.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

papa

Zitat von: Xent am 26 August 2017, 07:35:07
Moin,
wie schauts mit meinen Änderungen aus?
Konntest du schon weiter testen?

Ich kann nur berichten, dass es seitdem 1a läuft  ;D

Ich habe jetzt mal Deine Radio.h eingespielt. Sieht erst mal soweit ganz gut aus. Lasse das mal ein paar Tage laufen. Dann muss ich noch prüfen (also den Stromverbrauch messen), ob das Funkmodul noch ordentlich in den Sleep geht.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

rvideobaer

Hallo,

ich verwende die Platine des Fensterdrehgriffkontaktes und einen DHT22 Temp Sensor. Der Sensor ist an D6 der Platine angeschlossen, erstmal nur auf einem Steckbrett.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

papa

Zitat von: rvideobaer am 28 August 2017, 21:37:55
ich verwende die Platine des Fensterdrehgriffkontaktes und einen DHT22 Temp Sensor. Der Sensor ist an D6 der Platine angeschlossen, erstmal nur auf einem Steckbrett.

Wenn das der extra Quarz nicht bestücjt ist, muss rtc durch sysclock ausgetauscht werden.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Xent

Das ist doch schön zu hören.
An dem Sleepteil war ich aber glaub ich garnicht dran.
Da ging es eher darum, was passiert, wenn der CC1101 wieder aufgeweckt wird, weil alle Test-Register im Sleep ihren Wert verlieren und wieder neu geschrieben werden müssen.
Das einzige was man beim Sleep optimieren könnte, währe das flushen des RX da dies eh beim Sleep passiert.
Die Homematic Geräte warten ca 900ms vom Idle-Befehl zum Sleep-Befehl.

papa

Zitat von: Xent am 28 August 2017, 22:01:43
Das ist doch schön zu hören.
An dem Sleepteil war ich aber glaub ich garnicht dran.
Da ging es eher darum, was passiert, wenn der CC1101 wieder aufgeweckt wird, weil alle Test-Register im Sleep ihren Wert verlieren und wieder neu geschrieben werden müssen.
Das einzige was man beim Sleep optimieren könnte, währe das flushen des RX da dies eh beim Sleep passiert.
Die Homematic Geräte warten ca 900ms vom Idle-Befehl zum Sleep-Befehl.

Naja - die Konfig-Register haben sich ja auch geändert. Und da weiss man dann nie, was da so noch passiert  :)
Auf jeden Fall lief gestern alles stabil. Muss ,a sehen, wann ich zum Messen komme.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

papa

Zitat von: rvideobaer am 28 August 2017, 21:37:55
ich verwende die Platine des Fensterdrehgriffkontaktes und einen DHT22 Temp Sensor. Der Sensor ist an D6 der Platine angeschlossen, erstmal nur auf einem Steckbrett.

Du könntest aber auch das HM-WDS100-C6-O als Basis nehmen. Das hat ja auch Temperaturmessung und nutzt nur den "normalen" Timer.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

rvideobaer

Hallo,

ich habe jetzt die Platine mit dem Quartz und den 2 Kondensatoren bestückt so das er diesen benutzen kann (ich hoffe der Funktioniert, kann man das irgendwie testen)
Ein list des Gerätes habe ich mal mit angehangen. Ca. alle 2,5 Min werden battery, state und temperature aktualisiert leider die beiden letzteren nur mit Wert 0.

Internals:
   CFGFN
   DEF        345678
   IODev      myHmUART
   LASTInputDev myHmUART
   MSGCNT     1292
   NAME       HM_345678
   NOTIFYDEV  global
   NR         7770
   STATE      T: 0.0
   TYPE       CUL_HM
   lastMsg    No:07 - t:70 s:345678 d:190465 000000
   myHmUART_MSGCNT 1292
   myHmUART_RAWMSG 0501003D07A070345678190465000000
   myHmUART_RSSI -61
   myHmUART_TIME 2017-08-29 14:47:27
   protLastRcv 2017-08-29 14:47:27
   protResnd  1 last_at:2017-08-26 00:06:20
   protSnd    1244 last_at:2017-08-29 14:47:27
   protState  CMDs_done
   rssi_at_myHmUART avg:-52.85 cnt:1288 lst:-61 min:-81 max:-43
   READINGS:
     2017-08-29 14:36:04   Activity        alive
     2017-08-28 22:12:04   CommandAccepted yes
     2017-08-29 14:36:04   D-firmware      1.0
     2017-08-29 14:36:04   D-serialNr      papa111111
     2017-08-29 14:36:05   PairedTo        0x190465
     2017-08-28 22:12:04   R-pairCentral   0x190465
     2017-08-29 14:36:05   RegL_00.          02:01 0A:19 0B:04 0C:65 00:00
     2017-08-29 14:47:27   battery         ok
     2017-08-29 14:47:27   state           T: 0.0
     2017-08-29 14:47:27   temperature     0.0
   helper:
     HM_CMDNR   7
     PONtest    1
     cSnd       0119046534567800040000000000,011904653456780103
     mId        003D
     peerIDsRaw ,00000000
     rxType     140
     supp_Pair_Rep 0
     expert:
       def        1
       det        0
       raw        1
       tpl        0
     io:
       newChn     +345678,00,00,00
       nextSend   1504010848.03751
       prefIO
       rxt        2
       vccu
       p:
         345678
         00
         00
         00
     mRssi:
       mNo        07
       io:
         myHmUART   -59
     prt:
       bErr       0
       sProc      0
       sleeping   1
       try        1
       rspWait:
     q:
       qReqConf
       qReqStat
     role:
       chn        1
       dev        1
     rpt:
       IO         myHmUART
       flg        A
       ts         1504010847.74873
       ack:
         HASH(0x447f748)
         07800219046534567800
     rssi:
       at_myHmUART:
         avg        -52.8594720496894
         cnt        1288
         lst        -61
         max        -43
         min        -81
     shadowReg:
     tmpl:
Attributes:
   IODev      myHmUART
   IOgrp      vccu:myHmUART
   actCycle   000:10
   actStatus  alive
   autoReadReg 4_reqStatus
   expert     2_raw
   firmware   1.0
   model      HM-WDS10-TH-O
   peerIDs    00000000,
   room       CUL_HM
   serialNr   papa111111
   subType    THSensor


Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

papa

Also wenn ca. alle 2,5 min die Werte aktualisiert werden, scheint doch schon mal das Grundgerüst zu funktionieren. Ich kenne die DHT Library nicht und kann deshalb nur schelcht sagen, warum die Temperatur immer 0 ist. Mach doch mal ein paar Ausgaben direkt nach der Messung in den Code und prüfe mit der Serial-Console, ob die Messung funktioniert.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

rvideobaer

Hallo,

wie kann ich denn bei diesem Bord an die serielle Konsole kommen? wenn ich die in der Arduino IDE aufrufe bekomme ich nur folgende Meldung:
Das Board an /dev/cu.wchusbserial142140 ist nicht verfügbar

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

papa

An der linken, oberen Seite ist am ISP-Anschluß Tx & Rx sowie GND vorhanden.

Bei Dir im Code steht:

#define CONFIG_BUTTON_PIN 8
#define DHTPIN 6     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor


Hast Du auch den 10K Widerstand zwischen Data & Power ? Möglicherweise gibt es Probleme mit der Kommunikation.
Wie ist die Spannungsversorgung ?
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

rvideobaer

Hallo,

ich habe noch etwas probiert und eine Zeile die ich auskommentiert hatte wieder aktiviert.
DPRINT("Measure...\n");
jetzt kommen werte für temp und humidity aber bei der Temp zeigt er 2,5 grad wo es eher 25 sein sollten.
Den Widerstand habe ich und Spannung kommt vom Bord.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

papa

Zitat von: rvideobaer am 29 August 2017, 21:23:23
ich habe noch etwas probiert und eine Zeile die ich auskommentiert hatte wieder aktiviert.
DPRINT("Measure...\n");
jetzt kommen werte für temp und humidity aber bei der Temp zeigt er 2,5 grad wo es eher 25 sein sollten.
Den Widerstand habe ich und Spannung kommt vom Bord.

Das ist aber nur eine Debug-Ausgabe auf der Serial-Console. Vielleicht gibt es irgendein Timing-Problem.
Die Werte werden in 0,1° übertragen. Du musst also den gemessenen Wert noch mit 10 multiplizieren.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

rvideobaer

Hallo,

ich habe nun verschiedenes probiert, und bekomme Daten angezeigt. Aber immer wieder zwischendurch ist die Temp 0 in unregelmäßigen abständen.
Hier der jetzt verwendete Sketch.
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

// define all device properties
#define DEVICE_ID HMID(0x34,0x56,0x78)
#define DEVICE_SERIAL "papa111111"
#define DEVICE_MODEL  0x00,0x3d
#define DEVICE_FIRMWARE 0x10
#define DEVICE_TYPE DeviceType::THSensor
#define DEVICE_INFO 0x01,0x01,0x00

#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <TimerOne.h>
#include <LowPower.h>

#include <MultiChannelDevice.h>
#include "DHT.h"

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED_PIN 4
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8
#define DHTPIN 6     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

// number of available peers per channel
#define PEERS_PER_CHANNEL 6


// all library classes are placed in the namespace 'as'
using namespace as;

/**
* Configure the used hardware
*/
typedef AvrSPI<10,11,12,13> SPIType;
typedef Radio<SPIType,2> RadioType;
typedef StatusLed<4> LedType;
typedef AskSin<LedType,BatterySensor,RadioType> BaseHal;
class Hal : public BaseHal {
public:
  void init (const HMID& id) {
    BaseHal::init(id);
    // init real time clock - 1 tick per second
    rtc.init();
    // measure battery every 1h
    battery.init(60UL*60,rtc);
    battery.low(22);
    battery.critical(19);
  }

  bool runready () {
    return rtc.runready() || BaseHal::runready();
  }
} hal;

class WeatherEventMsg : public Message {
public:
  void init(uint8_t msgcnt,uint16_t temp,uint8_t humidity, bool batlow) {
    uint8_t t1 = (temp >> 8) & 0x7f;
    uint8_t t2 = temp & 0xff;
    if( batlow == true ) {
      t1 |= 0x80; // set bat low bit
    }
    Message::init(0xc,msgcnt,0x70,BIDI,t1,t2);
    pload[0] = humidity;
  }
};

class WeatherChannel : public Channel<Hal,List1,EmptyList,List4,PEERS_PER_CHANNEL>, public Alarm {

  WeatherEventMsg msg;
uint16_t        temp;
uint8_t         humidity;
  uint16_t        millis;

public:
  WeatherChannel () : Channel(), Alarm(5), temp(0), humidity(0), millis(0) {}
  virtual ~WeatherChannel () {}

  virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) {
    // wait also for the millis
    if( millis != 0 ) {
      tick = millis2ticks(millis);
      millis = 0; // reset millis
      sysclock.add(*this); // millis with sysclock
    }
    else {
      uint8_t msgcnt = device().nextcount();
      measure();
      msg.init(msgcnt,temp,humidity,device().battery().low());
      device().sendPeerEvent(msg,*this);
//      device().send(msg,device().getMasterID());

      // reactivate for next measure
      HMID id;
      device().getDeviceID(id);
      uint32_t nextsend = delay(id,msgcnt);
      tick = nextsend / 2000; // seconds to wait
      millis = nextsend % 1000; // millis to wait
      rtc.add(*this);
    }
  }

  // here we do the measurement
void measure () {
  Serial.begin(9600); //Serielle Verbindung starten
  dht.begin(); //DHT22 Sensor starten
    DPRINT("Measure...\n");
   float temperature = 0;
  float humidity = 0;
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
   if (isnan(h) || isnan(t)){
    Serial.println("Failed to read from DHT sensor!");
    float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
//    loop ();
  }
  temp = t*10;
  humidity = h;
}
  // here we calc when to send next value
  uint32_t delay (const HMID& id,uint8_t msgcnt) {
    uint32_t value = ((uint32_t)id) << 8 | msgcnt;
    value = (value * 1103515245 + 12345) >> 16;
    value = (value & 0xFF) + 480;
    value *= 250;

    DDEC(value / 1000);DPRINT(".");DDECLN(value % 1000);

    return value;
  }

  void setup(Device<Hal>* dev,uint8_t number,uint16_t addr) {
    Channel::setup(dev,number,addr);
    rtc.add(*this);
  }

  uint8_t status () const {
    return 0;
  }

  uint8_t flags () const {
    return 0;
  }

};


typedef MultiChannelDevice<Hal,WeatherChannel,1> WeatherType;
WeatherType sdev(0x20);

ConfigButton<WeatherType> cfgBtn(sdev);

void setup () {
  DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
  sdev.init(hal);
  buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
}

void loop() {
  bool worked = hal.runready();
  bool poll = sdev.pollRadio();
  if( worked == false && poll == false ) {
    hal.activity.savePower<SleepRTC>(hal);
  }

}


Bei der DHT.h Bibliotek ist zb. folgender Sketch als Beispiel dabei aus dem ich mich bedient habe.
// DHT Temperature & Humidity Sensor
// Unified Sensor Library Example
// Written by Tony DiCola for Adafruit Industries
// Released under an MIT license.

// Depends on the following Arduino libraries:
// - Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN            2         // Pin which is connected to the DHT sensor.

// Uncomment the type of sensor in use:
//#define DHTTYPE           DHT11     // DHT 11
#define DHTTYPE           DHT22     // DHT 22 (AM2302)
//#define DHTTYPE           DHT21     // DHT 21 (AM2301)

// See guide for details on sensor wiring and usage:
//   https://learn.adafruit.com/dht/overview

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup() {
  Serial.begin(9600);
  // Initialize device.
  dht.begin();
  Serial.println("DHTxx Unified Sensor Example");
  // Print temperature sensor details.
  sensor_t sensor;
  dht.temperature().getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.println("Temperature");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" *C");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" *C");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" *C"); 
  Serial.println("------------------------------------");
  // Print humidity sensor details.
  dht.humidity().getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.println("Humidity");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println("%");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println("%");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println("%"); 
  Serial.println("------------------------------------");
  // Set delay between sensor readings based on sensor details.
  delayMS = sensor.min_delay / 1000;
}

void loop() {
  // Delay between measurements.
  delay(delayMS);
  // Get temperature event and print its value.
  sensors_event_t event; 
  dht.temperature().getEvent(&event);
  if (isnan(event.temperature)) {
    Serial.println("Error reading temperature!");
  }
  else {
    Serial.print("Temperature: ");
    Serial.print(event.temperature);
    Serial.println(" *C");
  }
  // Get humidity event and print its value.
  dht.humidity().getEvent(&event);
  if (isnan(event.relative_humidity)) {
    Serial.println("Error reading humidity!");
  }
  else {
    Serial.print("Humidity: ");
    Serial.print(event.relative_humidity);
    Serial.println("%");
  }
}


Die Serielle Konsole habe ich noch nicht geprüft da ich noch auf den Bestellten Adapter warte.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr