Udated configuration and light sensor
This commit is contained in:
parent
1dfaf781d2
commit
795893ea2e
8 changed files with 23 additions and 20 deletions
|
|
@ -3,26 +3,27 @@
|
||||||
|
|
||||||
//#define ENABLE_DEBUG // comment out to disable debug
|
//#define ENABLE_DEBUG // comment out to disable debug
|
||||||
|
|
||||||
#define TIMER_MILLISECOND 60*1000 // poling in minutes
|
|
||||||
#define INDICATOR_PIN 13 // diode
|
|
||||||
|
|
||||||
|
#define TIMER_MILLISECOND 60000 // poling in minutes
|
||||||
|
#define INDICATOR_PIN 13 // diode
|
||||||
|
#define DEVICE_BASE_ID 20
|
||||||
|
|
||||||
// POWER CONSUMPTION SENSOR
|
// POWER CONSUMPTION SENSOR
|
||||||
//#define POWERCON_ENABLED // comment out to disable sensor
|
//#define POWERCON_ENABLED // comment out to disable sensor
|
||||||
#define POWERCON_SENSOR SensorPhotocell()
|
#define POWERCON_SENSOR SensorPhotocell()
|
||||||
#define POWERCON_PROTOCOL ProtocolOregon(11, 186)
|
#define POWERCON_PROTOCOL ProtocolOregon(11, DEVICE_BASE_ID + 1)
|
||||||
#define POWER_TIMER_MULTIPLIER 1
|
#define POWER_TIMER_MULTIPLIER 1
|
||||||
|
|
||||||
// TEMPERATURE SENSOR
|
// TEMPERATURE SENSOR
|
||||||
#define TEMPERATURE_ENABLED // comment out to disable sensor
|
#define TEMPERATURE_ENABLED // comment out to disable sensor
|
||||||
#define TEMPERATURE_SENSOR SensorDHT(DHT22, 10)
|
#define TEMPERATURE_SENSOR SensorDHT(DHT11, 10)
|
||||||
#define TEMPERATURE_PROTOCOL ProtocolOregon(11, 100)
|
#define TEMPERATURE_PROTOCOL ProtocolOregon(11, DEVICE_BASE_ID + 2)
|
||||||
#define TEMPERATURE_TIMER_MULTIPLIER 10
|
#define TEMPERATURE_TIMER_MULTIPLIER 10
|
||||||
|
|
||||||
// LIGHT SENSOR
|
// LIGHT SENSOR
|
||||||
//#define LIGHT_ENABLED // comment out to disable sensor
|
#define LIGHT_ENABLED // comment out to disable sensor
|
||||||
#define LIGHT_SENSOR SensorDH1750()
|
#define LIGHT_SENSOR SensorBH1750()
|
||||||
#define LIGHT_PROTOCOL ?
|
#define LIGHT_PROTOCOL ProtocolOregon(11, DEVICE_BASE_ID + 3)
|
||||||
#define LIGHT_TIMER_MULTIPLIER 10
|
#define LIGHT_TIMER_MULTIPLIER 10
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ void loop()
|
||||||
{
|
{
|
||||||
static LightData lightData;
|
static LightData lightData;
|
||||||
lightSensor->read(lightData);
|
lightSensor->read(lightData);
|
||||||
DEBUG("Read LIGHT_SENSOR= lumen:%d", lightData.lumen);
|
DEBUGF("Read LIGHT_SENSOR= lumen:%d", lightData.lumen);
|
||||||
lightProtocol->send(lightData);
|
lightProtocol->send(lightData);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#include "Interrupt.h"
|
#include "Interrupt.h"
|
||||||
#include <Arduino.h>
|
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#include <avr/sleep.h>
|
#include <avr/sleep.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
@ -107,7 +106,7 @@ ISR(WDT_vect)
|
||||||
Interrupt::handleWatchDogInterrupt();
|
Interrupt::handleWatchDogInterrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interrupt::setupWatchDogInterrupt(uint16_t milliseconds)
|
void Interrupt::setupWatchDogInterrupt(int32_t milliseconds)
|
||||||
{
|
{
|
||||||
wdtTimeLeft = wdtTime = milliseconds;
|
wdtTimeLeft = wdtTime = milliseconds;
|
||||||
setupWatchDogInterrupt();
|
setupWatchDogInterrupt();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef INTERRUPT_H
|
#ifndef INTERRUPT_H
|
||||||
#define INTERRUPT_H
|
#define INTERRUPT_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
typedef void (*InterruptFunction) ();
|
typedef void (*InterruptFunction) ();
|
||||||
|
|
||||||
|
|
@ -10,7 +11,7 @@ public:
|
||||||
static void wakeUp() { wakeUpNow = true; };
|
static void wakeUp() { wakeUpNow = true; };
|
||||||
static void sleep();
|
static void sleep();
|
||||||
static void setupPinInterrupt(int pin);
|
static void setupPinInterrupt(int pin);
|
||||||
static void setupWatchDogInterrupt(unsigned int milliseconds);
|
static void setupWatchDogInterrupt(int32_t milliseconds);
|
||||||
//static void setupTimerInterrupt(unsigned int milliseconds);
|
//static void setupTimerInterrupt(unsigned int milliseconds);
|
||||||
|
|
||||||
static void setPinCallback(InterruptFunction callback){ Interrupt::pinCallback = callback;}
|
static void setPinCallback(InterruptFunction callback){ Interrupt::pinCallback = callback;}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,13 @@ void ProtocolOregon::send(const TemperatureData& data)
|
||||||
send(data.temperature, data.humidity);
|
send(data.temperature, data.humidity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProtocolOregon::send(const LightData& data)
|
||||||
|
{
|
||||||
|
send(data.lumen, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProtocolOregon::send(float temperature, short humidity)
|
void ProtocolOregon::send(float temperature, short humidity)
|
||||||
{
|
{
|
||||||
byte buffer[9];
|
byte buffer[9];
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "HalInterfaces.h"
|
#include "HalInterfaces.h"
|
||||||
|
|
||||||
|
|
||||||
class ProtocolOregon : public ProtocolTemperature, public ProtocolPowerConsumption
|
class ProtocolOregon : public ProtocolTemperature, public ProtocolPowerConsumption, public ProtocolLight
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProtocolOregon(short pin, unsigned char address) : txPin(pin), address(address){};
|
ProtocolOregon(short pin, unsigned char address) : txPin(pin), address(address){};
|
||||||
|
|
@ -13,6 +13,7 @@ public:
|
||||||
virtual void setup();
|
virtual void setup();
|
||||||
virtual void send(const TemperatureData& data);
|
virtual void send(const TemperatureData& data);
|
||||||
virtual void send(const PowerData& data);
|
virtual void send(const PowerData& data);
|
||||||
|
virtual void send(const LightData& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
short txPin;
|
short txPin;
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,6 @@ void SensorBH1750::configure(uint8_t mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorBH1750::read(PowerData& data)
|
|
||||||
{
|
|
||||||
data.consumption = pulses;
|
|
||||||
pulses = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SensorBH1750::read(LightData& data) {
|
void SensorBH1750::read(LightData& data) {
|
||||||
uint16_t level;
|
uint16_t level;
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,9 @@
|
||||||
#include "HalInterfaces.h"
|
#include "HalInterfaces.h"
|
||||||
|
|
||||||
|
|
||||||
class SensorBH1750 : public SensorPowerConsumption, public SensorLight{
|
class SensorBH1750 : public SensorLight{
|
||||||
public:
|
public:
|
||||||
virtual void setup();
|
virtual void setup();
|
||||||
virtual void read(PowerData& data);
|
|
||||||
virtual void read(LightData& data);
|
virtual void read(LightData& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue