Selbstbauprojekt HM-SEC-MDIR-2

Begonnen von Billy3, 27 Februar 2019, 21:49:38

Vorheriges Thema - Nächstes Thema

Billy3

Hallo
Ich habe den Bewegungsmelder nachgebaut. Soweit funktioniert er auch. Zusätzlich habe ich jetzt den Helligkeitssensor TSL2561 angeschlossen. SDA an A4 und SCL an A5 leider wird mir aber keine Helligkeit in Homematic angezeigt. Kann es sein das der Sketch falsch ist? Hier nun der Sketch den ich Hochgeladen habe:
//- -----------------------------------------------------------------------------------------------------------------------
// 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 EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>
// uncomment the following 2 lines if you have a TSL2561 connected at address 0x29
#include <Wire.h>
#include <sensors/Tsl2561.h>

#include <MultiChannelDevice.h>
#include <Motion.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
// Arduino pin for the PIR
// A0 == PIN 14 on Pro Mini
#define PIR_PIN 14

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

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

// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
    {0x56,0x78,0x90},       // Device ID
    "papa222222",           // Device Serial
    {0x00,0x4a},            // Device Model
    0x16,                   // Firmware Version
    as::DeviceType::MotionDetector, // Device Type
    {0x01,0x00}             // Info Bytes
};

/**
* Configure the used hardware
*/
typedef AvrSPI<10,11,12,13> SPIType;
typedef Radio<SPIType,2> RadioType;
typedef StatusLed<LED_PIN> LedType;
typedef AskSin<LedType,BatterySensor,RadioType> BaseHal;
class Hal : public BaseHal {
public:
  void init (const HMID& id) {
    BaseHal::init(id);
    // set low voltage to 2.2V
    // measure battery every 1h
    battery.init(seconds2ticks(60UL*60),sysclock);
    battery.low(22);
    battery.critical(19);
  }
} hal;

#ifdef _TSL2561_H_
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0,Tsl2561<TSL2561_ADDR_FLOAT> > MChannel;
#else
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0> MChannel;
#endif

typedef MultiChannelDevice<Hal,MChannel,1> MotionType;
MotionType sdev(devinfo,0x20);

ConfigButton<MotionType> cfgBtn(sdev);

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

void loop() {
  bool worked = hal.runready();
  bool poll = sdev.pollRadio();
  if( worked == false && poll == false ) {
    // deep discharge protection
    // if we drop below critical battery level - switch off all and sleep forever
    if( hal.battery.critical() ) {
      // this call will never return
      hal.activity.sleepForever(hal);
    }
    // if nothing to do - go sleep
    hal.activity.savePower<Sleep<>>(hal);
  }
}

papa

Was ist denn auf der seriellen Console zu sehen ?
Wie ist der Aufbau genau? Sind die Pullup Widerstände am I2C vorhanden ?
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

Ich weis zwar wo ich den seriellen Monitor finde habe aber damit noch nicht gearbeitet.
Ich habe den Arduino Pro mini auf einer Lochrasterplanine gebaut. Die Pullup Widerstände sind am I2C nicht vorhanden. Wie groß sollten sie denn sein. Ich betreibe den Arduino mit 3V Batteriespannung.

papa

Zeig mal Deine Schaltung. Dann sehen wir weiter.
Die seriellen Ausgaben sind wichtig, um eventuelle Fehler zu finden. Bitte stelle sicher, dass Du die Debugausgaben in der IDE sehen kannst.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

So sieht meine Schaltung aus (siehe Bild im Anhang) Gelb und Grün gehen zum TSL2561.

papa

BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

So sieht mein Sensor TSL2561 aus Vcc an +, GND an -, SDA an A4, SCL an A5, L (L-Adresse) mit GND gebrückt und im Sketch in Zeile 67 LOW eingefügt. Funktioniert aber leider nicht.

papa

Ok - die I2c-Pullups sind auf dem Breakout-Board drauf. Wie sieht es mit den seriellen Ausgaben aus ? Hast Du da schon was ?
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

Das hat er mir gesendet:
AskSin++ V3.1.5 (Feb 25 2019 19:37:18)
Address Space: 32 - 76
CC init1
CC Version: 14
- ready
Bat: 33
Motion
<- 0D 01 A2 41 567890 55C73E 01 01 00 40  - 839
-> 0A 01 80 02 55C73E 567890 00  - 1097
waitAck: 01
minInterval End
Motion
<- 0D 02 A2 41 567890 55C73E 01 02 00 40  - 2041
-> 0A 02 80 02 55C73E 567890 00  - 2297
waitAck: 01
minInterval End
Motion
<- 0D 03 A2 41 567890 55C73E 01 03 00 40  - 3241
-> 0A 03 80 02 55C73E 567890 00  - 3500
waitAck: 01
minInterval End
Motion
<- 0D 04 A2 41 567890 55C73E 01 04 00 40  - 4444
-> 0A 04 80 02 55C73E 567890 00  - 4700
waitAck: 01
minInterval End
Motion
<- 0D 05 A2 41 567890 55C73E 01 05 00 40  - 5644
-> 0A 05 80 02 55C73E 567890 00  - 5900
waitAck: 01
minInterval End
Motion
<- 0D 06 A2 41 567890 55C73E 01 06 00 40  - 6844
-> 0A 06 80 02 55C73E 567890 00  - 7102
waitAck: 01
minInterval End
Motion
<- 0D 07 A2 41 567890 55C73E 01 07 00 40  - 8048
-> 0A 07 80 02 55C73E 567890 00  - 8304
waitAck: 01
minInterval End
Motion
<- 0D 08 A2 41 567890 55C73E 01 08 00 40  - 9256
-> 0F 6E 86 10 3C4BA9 000000 0A 98 C8 0F 0E 40  - 9342
-> 0A 08 80 02 55C73E 567890 00  - 9508
waitAck: 01
minInterval End
Motion
<- 0D 09 A2 41 567890 55C73E 01 09 00 40  - 10457
-> 0A 09 80 02 55C73E 567890 00  - 10715
waitAck: 01
ignore 0F 25 86 10 63A293 000000 0A 9C CE 0C 00 40  - 10885
minInterval End
Motion
<- 0D 0A A2 41 567890 55C73E 01 0A 00 40  - 11659
-> 0A 0A 80 02 55C73E 567890 00  - 11915
waitAck: 01
minInterval End
Motion
<- 0D 0B A2 41 567890 55C73E 01 0B 00 40  - 12861
-> 0A 0B 80 02 55C73E 567890 00  - 13119
waitAck: 01
minInterval End
Motion
<- 0D 0C A2 41 567890 55C73E 01 0C 00 40  - 14073
-> 0A 0C 80 02 55C73E 567890 00  - 14329
waitAck: 01


papa

Hm - sieht so aus, als würde der Sensor nicht eingebunden. Ändere mal
#ifdef _TSL2561_H_
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0,Tsl2561<TSL2561_ADDR_FLOAT> > MChannel;
#else
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0> MChannel;
#endif

in
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0,Tsl2561<TSL2561_ADDR_LOW> > MChannel;
um.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

Das hatte ich schon geändert von FLOAT in LOW habe den Sketch nochmal Hochgeladen sieht immer noch so aus:

AskSin++ V3.1.5 (Mar  2 2019 11:23:23)
Address Space: 32 - 76
CC init1
CC Version: 14
- ready
Bat: 33
Motion
<- 0D 01 A2 41 567890 55C73E 01 01 00 40  - 843
-> 0A 01 80 02 55C73E 567890 00  - 1099
waitAck: 01
minInterval End
Motion
<- 0D 02 A2 41 567890 55C73E 01 02 00 40  - 2048
-> 0A 02 80 02 55C73E 567890 00  - 2304
waitAck: 01
minInterval End
Motion
<- 0D 03 A2 41 567890 55C73E 01 03 00 40  - 3258
-> 0A 03 80 02 55C73E 567890 00  - 3514
waitAck: 01
minInterval End
Motion
<- 0D 04 A2 41 567890 55C73E 01 04 00 40  - 4468
-> 0A 04 80 02 55C73E 567890 00  - 4724
waitAck: 01
minInterval End
Motion
<- 0D 05 A2 41 567890 55C73E 01 05 00 40  - 5677
-> 0A 05 80 02 55C73E 567890 00  - 5933
waitAck: 01
minInterval End
Motion

papa

Nein - nicht nur das LOW. Alle 4 Zeilen durch die eine ersetzen.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

Ich habe den Sketch geändert und neu Hochgeladen. Jetzt sieht es so aus:

AskSin++ V3.1.5 (Mar  2 2019 14:10:25)
Address Space: 32 - 76
CC init1
CC Version: 14
- ready
Bat: 33
Motion
<- 0D 01 A2 41 567890 55C73E 01 01 00 40  - 843
-> 0A 01 80 02 55C73E 567890 00  - 1099
waitAck: 01
minInterval End
Motion
<- 0D 02 A2 41 567890 55C73E 01 02 00 40  - 2054
-> 0A 02 80 02 55C73E 567890 00  - 2312
waitAck: 01
minInterval End
Motion
<- 0D 03 A2 41 567890 55C73E 01 03 00 40  - 3268
-> 0A 03 80 02 55C73E 567890 00  - 3524
waitAck: 01
minInterval End
Motion
<- 0D 04 A2 41 567890 55C73E 01 04 00 40  - 4478
-> 0A 04 80 02 55C73E 567890 00  - 4734
waitAck: 01
minInterval End
Motion
<- 0D 05 A2 41 567890 55C73E 01 05 00 40  - 5687
-> 0A 05 80 02 55C73E 567890 00  - 5943
waitAck: 01
minInterval End
Motion
<- 0D 06 A2 41 567890 55C73E 01 06 00 40  - 6897
-> 0A 06 80 02 55C73E 567890 00  - 7155
waitAck: 01
minInterval End
Motion
<- 0D 07 A2 41 567890 55C73E 01 07 00 40  - 8108
-> 0A 07 80 02 55C73E 567890 00  - 8366
waitAck: 01
minInterval End
Motion
<- 0D 08 A2 41 567890 55C73E 01 08 00 40  - 9320
-> 0A 08 80 02 55C73E 567890 00  - 9576
waitAck: 01
minInterval End
Motion
<- 0D 09 A2 41 567890 55C73E 01 09 00 40  - 10532
-> 0A 09 80 02 55C73E 567890 00  - 10790
waitAck: 01
ignore 0F E7 86 10 569B1B 000000 0A 9C D4 09 00 00  - 11059
minInterval End
Motion
<- 0D 0A A2 41 567890 55C73E 01 0A 00 40  - 11741
-> 0A 0A 80 02 55C73E 567890 00  - 11999
waitAck: 01
minInterval End
Motion
<- 0D 0B A2 41 567890 55C73E 01 0B 00 40  - 12955
-> 0A 0B 80 02 55C73E 567890 00  - 13211
waitAck: 01
minInterval End
Motion
<- 0D 0C A2 41 567890 55C73E 01 0C 00 40  - 14163
-> 0A 0C 80 02 55C73E 567890 00  - 14419
waitAck: 01
minInterval End
Motion
<- 0D 0D A2 41 567890 55C73E 01 0D 00 40  - 15376
-> 0A 0D 80 02 55C73E 567890 00  - 15632
waitAck: 01
minInterval End
Motion
<- 0D 0E A2 41 567890 55C73E 01 0E 00 40  - 16584
-> 0A 0E 80 02 55C73E 567890 00  - 16840
waitAck: 01
minInterval End
Motion
<- 0D 0F A2 41 567890 55C73E 01 0F 00 40  - 17795
-> 0A 0F 80 02 55C73E 567890 00  - 18053
waitAck: 01
ignore 0D C0 A6 10 580E24 55C73E 06 01 00 00  - 18544
minInterval End
Motion
<- 0D 10 A2 41 567890 55C73E 01 10 00 40  - 19009
-> 0A 10 80 02 55C73E 567890 00  - 19265
waitAck: 01
minInterval End
Motion
<- 0D 11 A2 41 567890 55C73E 01 11 00 40  - 20219
-> 0A 11 80 02 55C73E 567890 00  - 20475
waitAck: 01
minInterval End
Motion
<- 0D 12 A2 41 567890 55C73E 01 12 00 40  - 21428
-> 0A 12 80 02 55C73E 567890 00  - 21684
waitAck: 01
minInterval End
Motion
<- 0D 13 A2 41 567890 55C73E 01 13 00 40  - 22638
-> 0A 13 80 02 55C73E 567890 00  - 22896
waitAck: 01

papa

Hm, da kommt irgendwie nichts. Hast Du mal einen Beispiel-Sketch der TSL2561-Library probiert ?
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Billy3

Ich hab mal ein Test durchlaufen lassen:

Starting Tsl2561 testing loop

Testing Tsl2561 at address 29: found
Chip has type 50 and revision 0
Chip is a T, FN or CL type package
Chip powered on at 6
New gain = 0, exposure = 0x02
Got luminosity after 790 ms. Full spectrum is 75 and IR only is 21
Chip powered on at 800
New gain = 1, exposure = 0x02
Got luminosity after 789 ms. Full spectrum is 1130 and IR only is 316
Chip powered on at 1593
New gain = 0, exposure = 0x01
Got luminosity after 207 ms. Full spectrum is 20 and IR only is 5
Chip powered on at 1802
New gain = 1, exposure = 0x01
Got luminosity after 207 ms. Full spectrum is 282 and IR only is 79
Chip powered on at 2011
New gain = 0, exposure = 0x00
Got luminosity after 37 ms. Full spectrum is 5 and IR only is 1
Chip powered on at 2050
New gain = 1, exposure = 0x00
Got luminosity after 36 ms. Full spectrum is 36 and IR only is 10

Kann man da was sehen?