Das was ich feststellen konnte sind diese beiden abschnitte die ich einfügen müste .
Leider sind meine kentnisse zuwenig
Code: Alles auswählen
#include <sensors/Opt3001.h>
typedef MotionChannel<Hal, PEERS_PER_CHANNEL, List0, Opt3001<> > MChannel;
Moderator: Co-Administratoren
Code: Alles auswählen
#include <sensors/Opt3001.h>
typedef MotionChannel<Hal, PEERS_PER_CHANNEL, List0, Opt3001<> > MChannel;
Code: Alles auswählen
class analogBrightness : public Brightness {
public:
analogBrightness () {}
void init () {
_present = true;
pinMode(A6, INPUT);
}
void measure (__attribute__((unused)) bool async=false) {
_brightness = analogRead(A6);
}
};
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0,analogBrightness > MChannel;
Code: Alles auswählen
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// ci-test=yes board=328p aes=no
//- -----------------------------------------------------------------------------------------------------------------------
#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>
#include <Register.h>
#include <MultiChannelDevice.h>
#include <Motion.h>
#define LED_PIN 8
#define CONFIG_BUTTON_PIN 0
// WMDO Bewegungsmelder Aussen
#define PIR_PIN 14
// WMD Bewegungsmelder Innen
//#define PIR_PIN1 17
//#define PIR_PIN2 14
#define PEERS_PER_CHANNEL 10
#define BAT_VOLT_LOW 34 // 3.4V low voltage threshold
#define BAT_VOLT_CRITICAL 29 // 2.9V critical voltage threshold, puts AVR into sleep-forever mode
#define BAT_SENSOR BatterySensor
// all library classes are placed in the namespace 'as'
using namespace as;
// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
{0x56,0x78,0x68}, // Device ID
"papa222268", // 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,BAT_SENSOR,RadioType,Brightness> Hal;
class analogBrightness : public Brightness {
public:
analogBrightness () {}
void init () {
_present = true;
pinMode(A6, INPUT);
}
void measure (__attribute__((unused)) bool async=false) {
_brightness = analogRead(A6);
}
};
typedef MotionChannel<Hal,PEERS_PER_CHANNEL,List0,analogBrightness> MChannel;
typedef MultiChannelDevice<Hal,MChannel,1> MotionType;
Hal hal;
MotionType sdev(devinfo,0x20);
ConfigButton<MotionType> cfgBtn(sdev);
void setup () {
DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
sdev.init(hal);
buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
// WMDO Bewegungsmelder Aussen
motionISR(sdev,1,PIR_PIN);
// WMD Bewegungsmelder Innen
//motionISR(sdev,1,PIR_PIN1);
//motionISR(sdev,2,PIR_PIN2);
hal.initBattery(60UL*60,BAT_VOLT_LOW,BAT_VOLT_CRITICAL); // Measure Battery every 1h
sdev.initDone();
pinMode(4,OUTPUT);
}
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);
}
digitalWrite(4,HIGH);
}
Ist das normalerweise bei den Bewegungsmeldern nicht genau umgekehrt? 0 bei Dunkelheit und 255 wenn es hell ist?recep hat geschrieben:
werte für Helligkeit wird bei Bewegung übermittelt
255 Bei Dunkelheit
0 Bei Taschenlampe