@@ -4,3 +4,7 @@ Arduino
|
||||
MySensors Arduino Library v1.5
|
||||
|
||||
Please visit www.mysensors.org for more information
|
||||
|
||||
Current build status of master branch: [](http://ci.mysensors.org/job/MySensorsArduino/branch/master/)
|
||||
|
||||
Current build status of development branch: [](http://ci.mysensors.org/job/MySensorsArduino/branch/development/)
|
||||
|
||||
@@ -11,17 +11,23 @@ version=1.6.0
|
||||
# AVR compile variables
|
||||
# ---------------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall
|
||||
compiler.warning_flags.all=-Wall -Wextra
|
||||
|
||||
# Default "compiler.path" is correct, change only if you want to overidde the initial value
|
||||
compiler.path={runtime.tools.avr-gcc.path}/bin/
|
||||
compiler.c.cmd=avr-gcc
|
||||
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
|
||||
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD
|
||||
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
|
||||
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
|
||||
compiler.c.elf.flags=-w -Os -Wl,--gc-sections
|
||||
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
|
||||
compiler.c.elf.cmd=avr-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp
|
||||
compiler.cpp.cmd=avr-g++
|
||||
compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
||||
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
||||
compiler.ar.cmd=avr-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=avr-objcopy
|
||||
|
||||
@@ -18,7 +18,7 @@ Bounce::Bounce() {
|
||||
void Bounce::attach(int pin) {
|
||||
this->pin = pin;
|
||||
debouncedState = unstableState = digitalRead(pin);
|
||||
#ifdef BOUNCE_LOCK-OUT
|
||||
#ifdef BOUNCE_LOCK_OUT
|
||||
previous_millis = 0;
|
||||
#else
|
||||
previous_millis = millis();
|
||||
@@ -37,7 +37,7 @@ void Bounce::interval(unsigned long interval_millis)
|
||||
bool Bounce::update()
|
||||
{
|
||||
|
||||
#ifdef BOUNCE_LOCK-OUT
|
||||
#ifdef BOUNCE_LOCK_OUT
|
||||
stateChanged = false;
|
||||
// Ignore everything if we are locked out
|
||||
if (millis() - previous_millis >= interval_millis) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
// Uncomment the following line for "LOCK-OUT" debounce method
|
||||
//#define BOUNCE_LOCK-OUT
|
||||
//#define BOUNCE_LOCK_OUT
|
||||
|
||||
|
||||
#ifndef Bounce2_h
|
||||
|
||||
@@ -142,9 +142,9 @@ void DHT::readSensor()
|
||||
// - Then 40 bits: RISING and then a FALLING edge per bit
|
||||
// To keep our code simple, we accept any HIGH or LOW reading if it's max 85 usecs long
|
||||
|
||||
word rawHumidity;
|
||||
word rawTemperature;
|
||||
word data;
|
||||
word rawHumidity = 0;
|
||||
word rawTemperature = 0;
|
||||
word data = 0;
|
||||
|
||||
for ( int8_t i = -3 ; i < 2 * 40; i++ ) {
|
||||
byte age;
|
||||
|
||||
@@ -700,6 +700,7 @@ void DallasTemperature::setAlarmHandler(AlarmHandler *handler)
|
||||
// The default alarm handler
|
||||
void DallasTemperature::defaultAlarmHandler(const uint8_t* deviceAddress)
|
||||
{
|
||||
(void)deviceAddress;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
*/
|
||||
bool I2cMasterBase::transfer(uint8_t addrRW,
|
||||
void *buf, size_t nbytes, uint8_t option) {
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(buf);
|
||||
if (_state != STATE_REP_START) {
|
||||
start();
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class SoftI2cMaster : public I2cMasterBase {
|
||||
//----------------------------------------------------------------------------
|
||||
void sclDelay(uint8_t n) {_delay_loop_1(n);}
|
||||
//----------------------------------------------------------------------------
|
||||
bool writeScl(bool value) {
|
||||
void writeScl(bool value) {
|
||||
uint8_t s = SREG;
|
||||
noInterrupts();
|
||||
if (value == LOW) {
|
||||
@@ -145,7 +145,7 @@ class SoftI2cMaster : public I2cMasterBase {
|
||||
SREG = s;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool writeSda(bool value) {
|
||||
void writeSda(bool value) {
|
||||
uint8_t s = SREG;
|
||||
noInterrupts();
|
||||
if (value == LOW) {
|
||||
|
||||
@@ -649,7 +649,7 @@ bool IRdecodeRC6::decode(void) {
|
||||
* Hopefully this code is unique for each button.
|
||||
*/
|
||||
#define FNV_PRIME_32 16777619
|
||||
#define FNV_BASIS_32 2166136261
|
||||
#define FNV_BASIS_32 2166136261UL
|
||||
// Compare two tick values, returning 0 if newval is shorter,
|
||||
// 1 if newval is equal, and 2 if newval is longer
|
||||
int IRdecodeHash::compare(unsigned int oldval, unsigned int newval) {
|
||||
@@ -730,12 +730,12 @@ void IRrecvBase::resume() {
|
||||
bool IRrecvLoop::GetResults(IRdecodeBase *decoder) {
|
||||
bool Finished=false;
|
||||
byte OldState=HIGH;byte NewState;
|
||||
unsigned long StartTime, DeltaTime, EndTime;
|
||||
unsigned long StartTime, DeltaTime=0, EndTime=0;
|
||||
StartTime=micros();
|
||||
while(irparams.rawlen<RAWBUF) { //While the buffer not overflowing
|
||||
while(OldState==(NewState=digitalRead(irparams.recvpin))) { //While the pin hasn't changed
|
||||
if( (DeltaTime = (EndTime=micros()) - StartTime) > 10000) { //If it's a very long wait
|
||||
if(Finished=irparams.rawlen) break; //finished unless it's the opening gap
|
||||
if((Finished=irparams.rawlen)) break; //finished unless it's the opening gap
|
||||
}
|
||||
}
|
||||
if(Finished) break;
|
||||
@@ -798,6 +798,9 @@ void IRrecvPCI_Handler(){
|
||||
case STATE_IDLE:
|
||||
if(digitalRead(irparams.recvpin)) return; else irparams.rcvstate=STATE_RUNNING;
|
||||
break;
|
||||
default:
|
||||
// what of STATE_UNKNOWN, STATE_MARK and STATE_SPACE?
|
||||
break;
|
||||
};
|
||||
irparams.rawbuf[irparams.rawlen]=DeltaTime;
|
||||
irparams.timer=ChangeTime;
|
||||
@@ -982,6 +985,9 @@ ISR(TIMER_INTR_NAME)
|
||||
irparams.timer = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// what of STATE_UNKNOWN and STATE_RUNNING?
|
||||
break;
|
||||
}
|
||||
do_Blink();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
#define RAWBUF 100 // Length of raw duration buffer (cannot exceed 255)
|
||||
|
||||
typedef char IRTYPES; //formerly was an enum
|
||||
typedef unsigned char IRTYPES; //formerly was an enum
|
||||
#define UNKNOWN 0
|
||||
#define NEC 1
|
||||
#define SONY 2
|
||||
|
||||
@@ -90,6 +90,8 @@ inline static void waitUsec ( uint16_t uSec )
|
||||
{
|
||||
#ifndef FAST_MODE
|
||||
delayMicroseconds ( uSec );
|
||||
#else
|
||||
(void)uSec;
|
||||
#endif // FAST_MODE
|
||||
}
|
||||
|
||||
@@ -481,7 +483,7 @@ public:
|
||||
@param value: pin associated to backlight control.
|
||||
@param pol: backlight polarity control (POSITIVE, NEGATIVE)
|
||||
*/
|
||||
virtual void setBacklightPin ( uint8_t value, t_backlighPol pol ) { };
|
||||
virtual void setBacklightPin ( uint8_t /*value*/, t_backlighPol /*pol*/ ) { };
|
||||
|
||||
/*!
|
||||
@function
|
||||
@@ -500,7 +502,7 @@ public:
|
||||
BACKLIGHT_OFF will be interpreted as off and BACKLIGHT_ON will drive the
|
||||
backlight on.
|
||||
*/
|
||||
virtual void setBacklight ( uint8_t value ) { };
|
||||
virtual void setBacklight ( uint8_t /*value*/ ) { };
|
||||
|
||||
/*!
|
||||
@function
|
||||
@@ -514,9 +516,9 @@ public:
|
||||
@param value[in] Value to write to the LCD.
|
||||
*/
|
||||
#if (ARDUINO < 100)
|
||||
virtual void write(uint8_t value);
|
||||
virtual void write(uint8_t /*value*/);
|
||||
#else
|
||||
virtual size_t write(uint8_t value);
|
||||
virtual size_t write(uint8_t /*value*/);
|
||||
#endif
|
||||
|
||||
#if (ARDUINO < 100)
|
||||
@@ -566,9 +568,9 @@ private:
|
||||
the LCD.
|
||||
*/
|
||||
#if (ARDUINO < 100)
|
||||
virtual void send(uint8_t value, uint8_t mode) { };
|
||||
virtual void send(uint8_t /*value*/, uint8_t /*mode*/) { };
|
||||
#else
|
||||
virtual void send(uint8_t value, uint8_t mode) = 0;
|
||||
virtual void send(uint8_t /*value*/, uint8_t /*mode*/) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
LiquidCrystal_I2C_ByVac::LiquidCrystal_I2C_ByVac( uint8_t lcd_Addr )
|
||||
{
|
||||
_Addr = lcd_Addr;
|
||||
_polarity == NEGATIVE;
|
||||
_polarity = NEGATIVE;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
|
||||
@@ -110,6 +110,8 @@ LiquidCrystal_SR::LiquidCrystal_SR (uint8_t srdata, uint8_t srclock,
|
||||
void LiquidCrystal_SR::init(uint8_t srdata, uint8_t srclock, uint8_t enable,
|
||||
uint8_t lines, uint8_t font)
|
||||
{
|
||||
(void)lines;
|
||||
(void)font;
|
||||
// Initialise private variables
|
||||
_two_wire = 0;
|
||||
|
||||
@@ -200,10 +202,10 @@ void LiquidCrystal_SR::send(uint8_t value, uint8_t mode)
|
||||
//
|
||||
// setBacklightPin
|
||||
void LiquidCrystal_SR::setBacklightPin ( uint8_t pin, t_backlighPol pol )
|
||||
{ }
|
||||
{ (void)pin; (void)pol; }
|
||||
|
||||
//
|
||||
// setBacklight
|
||||
void LiquidCrystal_SR::setBacklight ( uint8_t mode )
|
||||
{ }
|
||||
{ (void)mode; }
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ LiquidCrystal_SR1W::LiquidCrystal_SR1W (uint8_t srdata, t_sr1w_circuitType circu
|
||||
// init
|
||||
void LiquidCrystal_SR1W::init(uint8_t srdata, t_sr1w_circuitType circuitType, t_backlighPol blpol, uint8_t lines, uint8_t font)
|
||||
{
|
||||
(void)lines;
|
||||
(void)font;
|
||||
_srRegister = fio_pinToOutputRegister(srdata);
|
||||
_srMask = fio_pinToBit(srdata);
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
// | | | / | 1k
|
||||
// | +--8-|GND Q'H|--9-----+ |
|
||||
// | | +---------+ | | (GND)--(LCD RW)
|
||||
// | | 0.1uF | \
|
||||
/* | | 0.1uF | \ */
|
||||
// | (GND)-----||----(VCC) +------)--------------(LCD EN)
|
||||
// | | /
|
||||
// |----|<|----+--[ Resistor ]--| |
|
||||
|
||||
@@ -47,6 +47,8 @@ LiquidCrystal_SR2W::LiquidCrystal_SR2W (uint8_t srdata, uint8_t srclock, t_backl
|
||||
// init
|
||||
void LiquidCrystal_SR2W::init(uint8_t srdata, uint8_t srclock, t_backlighPol blpol, uint8_t lines, uint8_t font)
|
||||
{
|
||||
(void)lines;
|
||||
(void)font;
|
||||
_srDataRegister = fio_pinToOutputRegister(srdata);
|
||||
_srDataMask = fio_pinToBit(srdata);
|
||||
_srClockRegister = fio_pinToOutputRegister(srclock);
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
// but now can be used in any sensor node. Also the LEDs can now be
|
||||
// disabled in the gateway.
|
||||
|
||||
//#define WITH_LEDS_BLINKING
|
||||
// #define WITH_LEDS_BLINKING
|
||||
|
||||
// The following setting allows you to inverse the blinking feature WITH_LEDS_BLINKING
|
||||
// When WITH_LEDS_BLINKING_INVERSE is enabled LEDSs are normally turned on and switches
|
||||
@@ -103,7 +103,6 @@
|
||||
// Key to use for HMAC calculation in MySigningAtsha204Soft (32 bytes)
|
||||
#define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
|
||||
|
||||
/**********************************
|
||||
* NRF24L01 Driver Defaults
|
||||
***********************************/
|
||||
|
||||
@@ -58,7 +58,7 @@ typedef enum {
|
||||
S_UV, // Uv sensor, V_UV
|
||||
S_WEIGHT, // Personal scale sensor, V_WEIGHT, V_IMPEDANCE
|
||||
S_POWER, // Power meter, V_WATT, V_KWH
|
||||
S_HEATER, // Header device, V_HVAC_SETPOINT_HEAT, V_HVAC_FLOW_STATE
|
||||
S_HEATER, // Header device, V_HVAC_SETPOINT_HEAT, V_HVAC_FLOW_STATE, V_TEMP
|
||||
S_DISTANCE, // Distance sensor, V_DISTANCE
|
||||
S_LIGHT_LEVEL, // Light level sensor, V_LIGHT_LEVEL (uncalibrated in percentage), V_LEVEL (light level in lux)
|
||||
S_ARDUINO_NODE, // Used (internally) for presenting a non-repeating Arduino node
|
||||
@@ -73,7 +73,7 @@ typedef enum {
|
||||
S_RGB_LIGHT, // RGB light. Send color component data using V_RGB. Also supports V_WATT
|
||||
S_RGBW_LIGHT, // RGB light with an additional White component. Send data using V_RGBW. Also supports V_WATT
|
||||
S_COLOR_SENSOR, // Color sensor, send color information using V_RGB
|
||||
S_HVAC, // Thermostat/HVAC device. V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COLD, V_HVAC_FLOW_STATE, V_HVAC_FLOW_MODE
|
||||
S_HVAC, // Thermostat/HVAC device. V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COLD, V_HVAC_FLOW_STATE, V_HVAC_FLOW_MODE, V_TEMP
|
||||
S_MULTIMETER, // Multimeter device, V_VOLTAGE, V_CURRENT, V_IMPEDANCE
|
||||
S_SPRINKLER, // Sprinkler, V_STATUS (turn on/off), V_TRIPPED (if fire detecting device)
|
||||
S_WATER_LEAK, // Water leak sensor, V_TRIPPED, V_ARMED
|
||||
@@ -84,42 +84,42 @@ typedef enum {
|
||||
|
||||
// Type of sensor data (for set/req/ack messages)
|
||||
typedef enum {
|
||||
V_TEMP, // S_TEMP
|
||||
V_HUM, // S_HUM
|
||||
V_STATUS, // S_LIGHT, S_DIMMER, S_SPRINKLER, S_HVAC, S_HEATER. Used for setting binary (on/off) status. 1=on, 0=off
|
||||
V_TEMP, // S_TEMP. Temperature S_TEMP, S_HEATER, S_HVAC
|
||||
V_HUM, // S_HUM. Humidity
|
||||
V_STATUS, // S_LIGHT, S_DIMMER, S_SPRINKLER, S_HVAC, S_HEATER. Used for setting/reporting binary (on/off) status. 1=on, 0=off
|
||||
V_LIGHT=2, // Same as V_STATUS
|
||||
V_PERCENTAGE, // S_DIMMER. Used for sending a percentage value (0-100).
|
||||
V_PERCENTAGE, // S_DIMMER. Used for sending a percentage value 0-100 (%).
|
||||
V_DIMMER=3, // S_DIMMER. Same as V_PERCENTAGE.
|
||||
V_PRESSURE, // S_BARO
|
||||
V_FORECAST, // S_BARO
|
||||
V_RAIN, // S_RAIN
|
||||
V_RAINRATE, // S_RAIN
|
||||
V_WIND, // S_WIND
|
||||
V_GUST, // S_WIND
|
||||
V_DIRECTION, // S_WIND
|
||||
V_UV, // S_UV
|
||||
V_WEIGHT, // S_WEIGHT
|
||||
V_DISTANCE, // S_DISTANCE
|
||||
V_IMPEDANCE, // S_MULTIMETER, S_WEIGHT
|
||||
V_ARMED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER
|
||||
V_TRIPPED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER (for sprinklers with fire detection)
|
||||
V_WATT, // S_POWER, S_LIGHT, S_DIMMER
|
||||
V_KWH, // S_POWER
|
||||
V_SCENE_ON, // S_SCENE_CONTROLLER
|
||||
V_SCENE_OFF, // S_SCENE_CONTROLLER
|
||||
V_PRESSURE, // S_BARO. Atmospheric Pressure
|
||||
V_FORECAST, // S_BARO. Whether forecast. string of "stable", "sunny", "cloudy", "unstable", "thunderstorm" or "unknown"
|
||||
V_RAIN, // S_RAIN. Amount of rain
|
||||
V_RAINRATE, // S_RAIN. Rate of rain
|
||||
V_WIND, // S_WIND. Wind speed
|
||||
V_GUST, // S_WIND. Gust
|
||||
V_DIRECTION, // S_WIND. Wind direction 0-360 (degrees)
|
||||
V_UV, // S_UV. UV light level
|
||||
V_WEIGHT, // S_WEIGHT. Weight(for scales etc)
|
||||
V_DISTANCE, // S_DISTANCE. Distance
|
||||
V_IMPEDANCE, // S_MULTIMETER, S_WEIGHT. Impedance value
|
||||
V_ARMED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER. Armed status of a security sensor. 1 = Armed, 0 = Bypassed
|
||||
V_TRIPPED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER, S_WATER_LEAK, S_SOUND, S_VIBRATION, S_MOISTURE. Tripped status of a security sensor. 1 = Tripped, 0
|
||||
V_WATT, // S_POWER, S_LIGHT, S_DIMMER, S_RGB, S_RGBW. Watt value for power meters
|
||||
V_KWH, // S_POWER. Accumulated number of KWH for a power meter
|
||||
V_SCENE_ON, // S_SCENE_CONTROLLER. Turn on a scene
|
||||
V_SCENE_OFF, // S_SCENE_CONTROLLER. Turn of a scene
|
||||
V_HEATER, // Deprecated. Use V_HVAC_FLOW_STATE instead.
|
||||
V_HVAC_FLOW_STATE=21, // HVAC flow state ("Off", "HeatOn", "CoolOn", or "AutoChangeOver"). S_HEATER, S_HVAC
|
||||
V_HVAC_SPEED, // HVAC/Heater fan speed ("Min", "Normal", "Max", "Auto")
|
||||
V_LIGHT_LEVEL, // Used for sending light level in uncalibrated percentage. See also V_LEVEL (light level in lux). S_LIGHT_LEVEL
|
||||
V_HVAC_FLOW_STATE=21, // S_HEATER, S_HVAC. HVAC flow state ("Off", "HeatOn", "CoolOn", or "AutoChangeOver")
|
||||
V_HVAC_SPEED, // S_HVAC, S_HEATER. HVAC/Heater fan speed ("Min", "Normal", "Max", "Auto")
|
||||
V_LIGHT_LEVEL, // S_LIGHT_LEVEL. Uncalibrated light level. 0-100%. Use V_LEVEL for light level in lux
|
||||
V_VAR1, V_VAR2, V_VAR3, V_VAR4, V_VAR5,
|
||||
V_UP, // S_COVER
|
||||
V_DOWN, // S_COVER
|
||||
V_STOP, // S_COVER
|
||||
V_IR_SEND, // S_IR
|
||||
V_IR_RECEIVE, // S_IR
|
||||
V_FLOW, // S_WATER
|
||||
V_VOLUME, // S_WATER
|
||||
V_LOCK_STATUS, // S_LOCK
|
||||
V_UP, // S_COVER. Window covering. Up
|
||||
V_DOWN, // S_COVER. Window covering. Down
|
||||
V_STOP, // S_COVER. Window covering. Stop
|
||||
V_IR_SEND, // S_IR. Send out an IR-command
|
||||
V_IR_RECEIVE, // S_IR. This message contains a received IR-command
|
||||
V_FLOW, // S_WATER. Flow of water (in meter)
|
||||
V_VOLUME, // S_WATER. Water volume
|
||||
V_LOCK_STATUS, // S_LOCK. Set or get lock status. 1=Locked, 0=Unlocked
|
||||
V_LEVEL, // S_DUST, S_AIR_QUALITY, S_SOUND (dB), S_VIBRATION (hz), S_LIGHT_LEVEL (lux)
|
||||
V_VOLTAGE, // S_MULTIMETER
|
||||
V_CURRENT, // S_MULTIMETER
|
||||
@@ -128,15 +128,16 @@ typedef enum {
|
||||
// Sent as ASCII hex: RRGGBB (RR=red, GG=green, BB=blue component)
|
||||
V_RGBW, // S_RGBW_LIGHT
|
||||
// Used for sending color information to multi color LED lighting.
|
||||
// Sent as ASCII hex: RRGGBBWW (WW=while component)
|
||||
// Sent as ASCII hex: RRGGBBWW (WW=white component)
|
||||
V_ID, // S_TEMP
|
||||
// Used for sending in sensors hardware ids (i.e. OneWire DS1820b).
|
||||
V_UNIT_PREFIX, // Allows sensors to send in a string representing the
|
||||
// unit prefix to be displayed in GUI, not parsed by controller! E.g. cm, m, km, inch.
|
||||
// Can be used for S_DISTANCE or gas concentration (S_DUST, S_AIR_QUALITY)
|
||||
V_HVAC_SETPOINT_COOL, // HVAC cool setpoint (Integer between 0-100). S_HVAC
|
||||
V_HVAC_SETPOINT_HEAT, // HVAC/Heater setpoint (Integer between 0-100). S_HEATER, S_HVAC
|
||||
V_HVAC_FLOW_MODE, // Flow mode for HVAC ("Auto", "ContinuousOn", "PeriodicOn"). S_HVAC
|
||||
V_UNIT_PREFIX, // S_DUST, S_AIR_QUALITY
|
||||
// Allows sensors to send in a string representing the
|
||||
// unit prefix to be displayed in GUI, not parsed by controller! E.g. cm, m, km, inch.
|
||||
// Can be used for S_DISTANCE or gas concentration
|
||||
V_HVAC_SETPOINT_COOL, // S_HVAC. HVAC cool setpoint (Integer between 0-100)
|
||||
V_HVAC_SETPOINT_HEAT, // S_HEATER, S_HVAC. HVAC/Heater setpoint (Integer between 0-100)
|
||||
V_HVAC_FLOW_MODE, // S_HVAC. Flow mode for HVAC ("Auto", "ContinuousOn", "PeriodicOn")
|
||||
|
||||
} mysensor_data;
|
||||
|
||||
|
||||
@@ -555,6 +555,7 @@ boolean MySensor::process() {
|
||||
#endif
|
||||
|
||||
uint8_t len = radio.receive((uint8_t *)&msg);
|
||||
(void)len; //until somebody makes use of 'len'
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
rxBlink(1);
|
||||
#endif
|
||||
|
||||
@@ -349,11 +349,6 @@ class MySensor
|
||||
|
||||
MyMessage msg; // Buffer for incoming messages.
|
||||
MyMessage tmpMsg ; // Buffer for temporary messages (acks and nonces among others).
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
uint16_t doSign[16]; // Bitfield indicating which sensors require signed communication
|
||||
MyMessage msgSign; // Buffer for message to sign.
|
||||
MySigning& signer;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
uint8_t pinRx; // Rx led pin
|
||||
@@ -370,6 +365,11 @@ class MySensor
|
||||
#endif
|
||||
|
||||
MyTransport& radio;
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
uint16_t doSign[16]; // Bitfield indicating which sensors require signed communication
|
||||
MyMessage msgSign; // Buffer for message to sign.
|
||||
MySigning& signer;
|
||||
#endif
|
||||
MyHw& hw;
|
||||
|
||||
boolean sendWrite(uint8_t dest, MyMessage &message);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "MySigning.h"
|
||||
#include "MySigningAtsha204.h"
|
||||
|
||||
#define SIGNING_IDENTIFIER (1)
|
||||
|
||||
// Uncomment this to get some useful serial debug info (Serial.print and Serial.println expected)
|
||||
//#define DEBUG_SIGNING
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include "utility/ATSHA204.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define SIGNING_IDENTIFIER (1)
|
||||
|
||||
#ifdef MY_SECURE_NODE_WHITELISTING
|
||||
typedef struct {
|
||||
uint8_t nodeId;
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "MySigningAtsha204Soft.h"
|
||||
#include "utility/sha256.h"
|
||||
|
||||
#define SIGNING_IDENTIFIER (1)
|
||||
|
||||
// Uncomment this to get some useful serial debug info (Serial.print and Serial.println expected)
|
||||
//#define DEBUG_SIGNING
|
||||
|
||||
@@ -72,15 +74,14 @@ MySigningAtsha204Soft::MySigningAtsha204Soft(bool requestSignatures,
|
||||
uint8_t randomseedPin)
|
||||
:
|
||||
MySigning(requestSignatures),
|
||||
rndPin(randomseedPin),
|
||||
#ifdef MY_SECURE_NODE_WHITELISTING
|
||||
whitlist_sz(nof_whitelist_entries),
|
||||
whitelist(the_whitelist),
|
||||
node_serial_info(the_serial),
|
||||
#endif
|
||||
Sha256(),
|
||||
verification_ongoing(false),
|
||||
Sha256()
|
||||
|
||||
rndPin(randomseedPin)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
#include "utility/sha256.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define SIGNING_IDENTIFIER (1)
|
||||
|
||||
#ifdef MY_SECURE_NODE_WHITELISTING
|
||||
typedef struct {
|
||||
uint8_t nodeId;
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "MySigning.h"
|
||||
#include "MySigningNone.h"
|
||||
|
||||
#define SIGNING_IDENTIFIER (0)
|
||||
|
||||
// Uncomment this to get some useful serial debug info (Serial.print and Serial.println expected)
|
||||
//#define DEBUG_SIGNING
|
||||
|
||||
@@ -61,6 +63,7 @@ MySigningNone::MySigningNone() : MySigning() {
|
||||
}
|
||||
|
||||
bool MySigningNone::getNonce(MyMessage &msg) {
|
||||
(void)msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,6 +72,7 @@ bool MySigningNone::checkTimer() {
|
||||
}
|
||||
|
||||
bool MySigningNone::putNonce(MyMessage &msg) {
|
||||
(void)msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include "MySigning.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define SIGNING_IDENTIFIER (0)
|
||||
|
||||
// The "none" signing driver that can be used for nodes
|
||||
// not requiring signing
|
||||
// It does check SIGNING_IDENTIFIER byte to avoid illegal mixing of signing back-ends in
|
||||
|
||||
@@ -74,6 +74,7 @@ bool MyTransportNRF24::send(uint8_t to, const void* data, uint8_t len) {
|
||||
bool MyTransportNRF24::available(uint8_t *to) {
|
||||
uint8_t pipe = 255;
|
||||
boolean avail = rf24.available(&pipe);
|
||||
(void)avail; //until somebody makes use of 'avail'
|
||||
if (pipe == CURRENT_NODE_PIPE)
|
||||
*to = _address;
|
||||
else if (pipe == BROADCAST_PIPE)
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <SPI.h>
|
||||
#include <MySensor.h>
|
||||
|
||||
#define DEBUG 1 // Debug enables Serial.print 1 = Yes 0 = No
|
||||
|
||||
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
||||
|
||||
MySensor gw;
|
||||
@@ -41,7 +39,11 @@ int oldBatteryPcnt = 0;
|
||||
void setup()
|
||||
{
|
||||
// use the 1.1 V internal reference
|
||||
#if defined(__AVR_ATmega2560__)
|
||||
analogReference(INTERNAL1V1);
|
||||
#else
|
||||
analogReference(INTERNAL);
|
||||
#endif
|
||||
gw.begin();
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
@@ -52,7 +54,7 @@ void loop()
|
||||
{
|
||||
// get the battery Voltage
|
||||
int sensorValue = analogRead(BATTERY_SENSE_PIN);
|
||||
#if DEBUG > 0
|
||||
#ifdef DEBUG
|
||||
Serial.println(sensorValue);
|
||||
#endif
|
||||
|
||||
@@ -63,7 +65,7 @@ void loop()
|
||||
float batteryV = sensorValue * 0.003363075;
|
||||
int batteryPcnt = sensorValue / 10;
|
||||
|
||||
#if DEBUG > 0
|
||||
#ifdef DEBUG
|
||||
Serial.print("Battery Voltage: ");
|
||||
Serial.print(batteryV);
|
||||
Serial.println(" V");
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* MH-Z14 CO2 sensor
|
||||
*
|
||||
* Wiring:
|
||||
* Pad 1, Pad 5: Vin (Voltage input 4.5V-6V)
|
||||
* Pad 2, Pad 3, Pad 12: GND
|
||||
* Pad 6: PWM output ==> pin 6
|
||||
*
|
||||
* From: http://davidegironi.blogspot.fr/2014/01/co2-meter-using-ndir-infrared-mh-z14.html
|
||||
* MH-Z14 has a PWM output, with a sensitivity range of 0ppm to 2000ppm CO2, an accurancy of ±200ppm.
|
||||
* The cycle is 1004ms±5%, given the duty cicle Th (pulse high), Tl is 1004-Th, we can convert it to CO2 value using the formula:
|
||||
* CO2ppm = 2000 * (Th - 2ms) /(Th + Tl - 4ms)
|
||||
* From: http://airqualityegg.wikispaces.com/Sensor+Tests
|
||||
* - response time is less than 30 s
|
||||
* - 3 minute warm up time
|
||||
* datasheet: http://www.futurlec.com/Datasheet/Sensor/MH-Z14.pdf
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#define CHILD_ID_AIQ 0
|
||||
#define AIQ_SENSOR_ANALOG_PIN 6
|
||||
|
||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
float valAIQ =0.0;
|
||||
float lastAIQ =0.0;
|
||||
|
||||
MySensor gw;
|
||||
MyMessage msg(CHILD_ID_AIQ, V_LEVEL);
|
||||
MyMessage msg2(CHILD_ID_AIQ, V_UNIT_PREFIX);
|
||||
|
||||
void setup()
|
||||
{
|
||||
gw.begin();
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
gw.sendSketchInfo("AIQ Sensor CO2 MH-Z14", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
gw.present(CHILD_ID_AIQ, S_AIR_QUALITY);
|
||||
gw.send(msg2.set("ppm"));
|
||||
|
||||
gw.sleep(SLEEP_TIME);
|
||||
|
||||
pinMode(AIQ_SENSOR_ANALOG_PIN, INPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//unsigned long duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
||||
while(digitalRead(AIQ_SENSOR_ANALOG_PIN) == HIGH) {;}
|
||||
//wait for the pin to go HIGH and measure HIGH time
|
||||
unsigned long duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
||||
|
||||
//Serial.print(duration/1000); Serial.println(" ms ");
|
||||
//from datasheet
|
||||
//CO2 ppm = 2000 * (Th - 2ms) / (Th + Tl - 4ms)
|
||||
// given Tl + Th = 1004
|
||||
// Tl = 1004 - Th
|
||||
// = 2000 * (Th - 2ms) / (Th + 1004 - Th -4ms)
|
||||
// = 2000 * (Th - 2ms) / 1000 = 2 * (Th - 2ms)
|
||||
long co2ppm = 2 * ((duration/1000) - 2);
|
||||
//Serial.print(co2ppm);
|
||||
if ((co2ppm != lastAIQ)&&(abs(co2ppm-lastAIQ)>=10)) {
|
||||
gw.send(msg.set((long)ceil(co2ppm)));
|
||||
lastAIQ = ceil(co2ppm);
|
||||
}
|
||||
|
||||
//Serial.println();
|
||||
|
||||
// Power down the radio. Note that the radio will get powered back up
|
||||
// on the next write() call.
|
||||
gw.sleep(SLEEP_TIME); //sleep for: sleepTime
|
||||
}
|
||||
+1
-1
@@ -133,7 +133,7 @@ void incomingMessage(const MyMessage &message)
|
||||
newLevel = loadLevelState(EEPROM_DIM_LEVEL_SAVE);
|
||||
}
|
||||
// Send dimmer level back to controller with ack enabled
|
||||
gw.send(dimmerMsg.set(0), true);
|
||||
gw.send(dimmerMsg.set(newLevel), true);
|
||||
// We do not change any levels here until ack comes back from gateway
|
||||
return;
|
||||
} else if (message.type == V_DIMMER) {
|
||||
|
||||
@@ -51,7 +51,7 @@ void setup()
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.present(CHILD_ID, S_DISTANCE);
|
||||
boolean metric = gw.getConfig().isMetric;
|
||||
metric = gw.getConfig().isMetric;
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Dust Sensor for SamYoung DSM501
|
||||
* connect the sensor as follows :
|
||||
* Pin 2 of dust sensor PM1 -> Digital 3 (PMW)
|
||||
* Pin 3 of dust sensor -> +5V
|
||||
* Pin 4 of dust sensor PM2.5 -> Digital 6 (PWM)
|
||||
* Pin 5 of dust sensor -> Ground
|
||||
* Datasheet: http://www.samyoungsnc.com/products/3-1%20Specification%20DSM501.pdf
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#define CHILD_ID_DUST_PM10 0
|
||||
#define CHILD_ID_DUST_PM25 1
|
||||
#define DUST_SENSOR_DIGITAL_PIN_PM10 6
|
||||
#define DUST_SENSOR_DIGITAL_PIN_PM25 3
|
||||
|
||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||
//VARIABLES
|
||||
int val = 0; // variable to store the value coming from the sensor
|
||||
float valDUSTPM25 =0.0;
|
||||
float lastDUSTPM25 =0.0;
|
||||
float valDUSTPM10 =0.0;
|
||||
float lastDUSTPM10 =0.0;
|
||||
unsigned long duration;
|
||||
unsigned long starttime;
|
||||
unsigned long endtime;
|
||||
unsigned long sampletime_ms = 30000;
|
||||
unsigned long lowpulseoccupancy = 0;
|
||||
float ratio = 0;
|
||||
long concentrationPM25 = 0;
|
||||
long concentrationPM10 = 0;
|
||||
|
||||
MySensor gw;
|
||||
MyMessage dustMsgPM10(CHILD_ID_DUST_PM10, V_LEVEL);
|
||||
MyMessage msgPM10(CHILD_ID_DUST_PM10, V_UNIT_PREFIX);
|
||||
MyMessage dustMsgPM25(CHILD_ID_DUST_PM25, V_LEVEL);
|
||||
MyMessage msgPM25(CHILD_ID_DUST_PM25, V_UNIT_PREFIX);
|
||||
|
||||
void setup()
|
||||
{
|
||||
gw.begin();
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
gw.sendSketchInfo("Dust Sensor DSM501", "1.4");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
gw.present(CHILD_ID_DUST_PM10, S_DUST);
|
||||
gw.send(msgPM10.set("ppm"));
|
||||
gw.present(CHILD_ID_DUST_PM25, S_DUST);
|
||||
gw.send(msgPM25.set("ppm"));
|
||||
|
||||
pinMode(DUST_SENSOR_DIGITAL_PIN_PM10,INPUT);
|
||||
pinMode(DUST_SENSOR_DIGITAL_PIN_PM25,INPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
//get PM 2.5 density of particles over 2.5 μm.
|
||||
concentrationPM25=(long)getPM(DUST_SENSOR_DIGITAL_PIN_PM25);
|
||||
Serial.print("PM25: ");
|
||||
Serial.println(concentrationPM25);
|
||||
Serial.print("\n");
|
||||
|
||||
if ((concentrationPM25 != lastDUSTPM25)&&(concentrationPM25>0)) {
|
||||
gw.send(dustMsgPM25.set((long)ceil(concentrationPM25)));
|
||||
lastDUSTPM25 = ceil(concentrationPM25);
|
||||
}
|
||||
//get PM 1.0 - density of particles over 1 μm.
|
||||
concentrationPM10=getPM(DUST_SENSOR_DIGITAL_PIN_PM10);
|
||||
Serial.print("PM10: ");
|
||||
Serial.println(concentrationPM10);
|
||||
Serial.print("\n");
|
||||
//ppmv=mg/m3 * (0.08205*Tmp)/Molecular_mass
|
||||
//0.08205 = Universal gas constant in atm·m3/(kmol·K)
|
||||
int temp=20; //external temperature, if you can replace this with a DHT11 or better
|
||||
long ppmv=(concentrationPM10*0.0283168/100/1000) * (0.08205*temp)/0.01;
|
||||
|
||||
if ((ceil(concentrationPM10) != lastDUSTPM10)&&((long)concentrationPM10>0)) {
|
||||
gw.send(dustMsgPM10.set((long)ppmv));
|
||||
lastDUSTPM10 = ceil(concentrationPM10);
|
||||
}
|
||||
|
||||
//sleep to save on radio
|
||||
gw.sleep(SLEEP_TIME);
|
||||
|
||||
}
|
||||
|
||||
|
||||
long getPM(int DUST_SENSOR_DIGITAL_PIN) {
|
||||
|
||||
starttime = millis();
|
||||
|
||||
while (1) {
|
||||
|
||||
duration = pulseIn(DUST_SENSOR_DIGITAL_PIN, LOW);
|
||||
lowpulseoccupancy += duration;
|
||||
endtime = millis();
|
||||
|
||||
if ((endtime-starttime) > sampletime_ms)
|
||||
{
|
||||
ratio = (lowpulseoccupancy-endtime+starttime)/(sampletime_ms*10.0); // Integer percentage 0=>100
|
||||
long concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
|
||||
//Serial.print("lowpulseoccupancy:");
|
||||
//Serial.print(lowpulseoccupancy);
|
||||
//Serial.print("\n");
|
||||
//Serial.print("ratio:");
|
||||
//Serial.print(ratio);
|
||||
//Serial.print("\n");
|
||||
//Serial.print("DSM501A:");
|
||||
//Serial.println(concentration);
|
||||
//Serial.print("\n");
|
||||
|
||||
lowpulseoccupancy = 0;
|
||||
return(concentration);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void setup()
|
||||
//check for saved date in EEPROM
|
||||
DEBUG_PRINTLN(F("Checking EEPROM for stored date:"));
|
||||
delay(500);
|
||||
if (gw.loadState(0) == 0xFF); // EEPROM flag
|
||||
if (gw.loadState(0) == 0xFF) // EEPROM flag
|
||||
{
|
||||
DEBUG_PRINTLN(F("Retreiving last run time from EEPROM..."));
|
||||
for (int i = 0; i < 4 ; i++)
|
||||
@@ -439,7 +439,7 @@ void loop()
|
||||
state = STAND_BY_ALL_OFF;
|
||||
}
|
||||
}
|
||||
else if (state = ZONE_SELECT_MENU)
|
||||
else if (state == ZONE_SELECT_MENU)
|
||||
{
|
||||
displayMenu();
|
||||
}
|
||||
@@ -771,6 +771,9 @@ void updateDisplay()
|
||||
lcd.print(totalTimeRan);
|
||||
lcd.print(" Minutes ");
|
||||
}
|
||||
default:
|
||||
// what of ZONE_SELECT_MENU?
|
||||
break;
|
||||
}
|
||||
lastUpdateTime = millis();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ void setup()
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.present(CHILD_ID_DISTANCE, S_DISTANCE);
|
||||
gw.present(CHILD_ID_INTENSITY, S_CUSTOM);
|
||||
boolean metric = gw.getConfig().isMetric;
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.println("Playing With Fusion: AS3935 Lightning Sensor, SEN-39001");
|
||||
@@ -118,4 +117,4 @@ void loop()
|
||||
void AS3935_ISR()
|
||||
{
|
||||
AS3935_ISR_Trig = 1;
|
||||
}␍
|
||||
}
|
||||
|
||||
@@ -279,6 +279,7 @@ void processMQTTMessage(char *inputString, uint8_t inputPos) {
|
||||
uint8_t i = 0;
|
||||
buffer[0]= 0;
|
||||
buffsize = 0;
|
||||
(void)inputPos;
|
||||
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTCONNECT) {
|
||||
buffer[buffsize++] = MQTTCONNACK << 4;
|
||||
@@ -336,7 +337,7 @@ void processMQTTMessage(char *inputString, uint8_t inputPos) {
|
||||
} else if (i==2) {
|
||||
msg.sensor = atoi(str); //SensorID
|
||||
} else if (i==3) {
|
||||
char match=255; //SensorType
|
||||
unsigned char match=255; //SensorType
|
||||
#ifdef MQTT_TRANSLATE_TYPES
|
||||
|
||||
for (uint8_t j=0; strcpy_P(convBuf, (char*)pgm_read_word(&(vType[j]))) ; j++) {
|
||||
@@ -348,7 +349,7 @@ void processMQTTMessage(char *inputString, uint8_t inputPos) {
|
||||
}
|
||||
|
||||
#endif
|
||||
if ( atoi(str)!=0 || str=="0" ) {
|
||||
if ( atoi(str)!=0 || (str[0]=='0' && str[1] =='\0') ) {
|
||||
match=atoi(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* MockMySensors
|
||||
* FakeMySensors
|
||||
*
|
||||
* This skecth is intended to crate fake sensors which register and respond to the controller
|
||||
*
|
||||
* Barduino 2015
|
||||
* Barduino, GizMoCuz 2015
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
|
||||
// SPI Pins
|
||||
#define CE_PIN 9
|
||||
@@ -18,14 +18,7 @@
|
||||
#define SHORT_WAIT 50
|
||||
|
||||
#define SKETCH_NAME "FakeMySensors "
|
||||
#define SKETCH_VERSION "v0.2"
|
||||
|
||||
// Define Sensors ids
|
||||
/* S_DOOR, S_MOTION, S_SMOKE, S_LIGHT, S_DIMMER, S_COVER, S_TEMP, S_HUM, S_BARO, S_WIND,
|
||||
S_RAIN, S_UV, S_WEIGHT, S_POWER, S_HEATER, S_DISTANCE, S_LIGHT_LEVEL, S_ARDUINO_NODE,
|
||||
S_ARDUINO_REPEATER_NODE, S_LOCK, S_IR, S_WATER, S_AIR_QUALITY, S_CUSTOM, S_DUST,
|
||||
S_SCENE_CONTROLLER
|
||||
*/
|
||||
#define SKETCH_VERSION "v0.3"
|
||||
|
||||
////#define ID_S_ARDUINO_NODE //auto defined in initialization
|
||||
////#define ID_S_ARDUINO_REPEATER_NODE //auto defined in initialization
|
||||
@@ -40,29 +33,28 @@
|
||||
//#define ID_S_HUM 8
|
||||
//#define ID_S_BARO 9
|
||||
//#define ID_S_WIND 10
|
||||
//#define ID_S_RAIN 11
|
||||
//#define ID_S_RAIN 11
|
||||
//#define ID_S_UV 12
|
||||
//#define ID_S_WEIGHT 13
|
||||
#define ID_S_POWER 14
|
||||
#define ID_S_HEATER 15
|
||||
#define ID_S_DISTANCE 16
|
||||
#define ID_S_LIGHT_LEVEL 17
|
||||
#define ID_S_LOCK 18
|
||||
#define ID_S_IR 19
|
||||
#define ID_S_WATER 20
|
||||
#define ID_S_AIR_QUALITY 21
|
||||
#define ID_S_DUST 22
|
||||
#define ID_S_SCENE_CONTROLLER 23
|
||||
|
||||
#define ID_S_CUSTOM 24
|
||||
//#define ID_S_POWER 14
|
||||
//#define ID_S_HEATER 15 <<-- not correctly implemented (1.5 API)
|
||||
//#define ID_S_DISTANCE 16
|
||||
//#define ID_S_LIGHT_LEVEL 17
|
||||
//#define ID_S_LOCK 18
|
||||
//#define ID_S_IR 19
|
||||
//#define ID_S_WATER 20
|
||||
//#define ID_S_AIR_QUALITY 21
|
||||
//#define ID_S_DUST 22
|
||||
//#define ID_S_SCENE_CONTROLLER 23
|
||||
//#define ID_S_CUSTOM 24
|
||||
|
||||
// Global Vars
|
||||
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
|
||||
unsigned long SLEEP_TIME = 12000; // Sleep time between reads (in milliseconds)
|
||||
boolean metric = true;
|
||||
long randNumber;
|
||||
|
||||
// Instanciate MySersors Gateway
|
||||
MySensor gw(CE_PIN,CS_PIN);
|
||||
MySensor gw;
|
||||
|
||||
//Instanciate Messages objects
|
||||
|
||||
@@ -134,8 +126,10 @@ MySensor gw(CE_PIN,CS_PIN);
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_HEATER
|
||||
MyMessage msg_S_HEATER_M(ID_S_HEATER,V_HEATER);
|
||||
MyMessage msg_S_HEATER_S(ID_S_HEATER,V_HEATER_SW);
|
||||
float current_set_point=21.5;
|
||||
MyMessage msg_S_HEATER_SP(ID_S_HEATER,V_HVAC_SETPOINT_HEAT);
|
||||
MyMessage msg_S_HEATER_F(ID_S_HEATER,V_HVAC_SETPOINT_HEAT);
|
||||
MyMessage msg_S_HEATER_T(ID_S_HEATER,V_TEMP);
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_DISTANCE
|
||||
@@ -161,11 +155,11 @@ MySensor gw(CE_PIN,CS_PIN);
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_AIR_QUALITY
|
||||
MyMessage msg_S_AIR_QUALITY(ID_S_AIR_QUALITY,V_VAR1);
|
||||
MyMessage msg_S_AIR_QUALITY(ID_S_AIR_QUALITY,V_LEVEL);
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_DUST
|
||||
MyMessage msg_S_DUST(ID_S_DUST,V_DUST_LEVEL);
|
||||
MyMessage msg_S_DUST(ID_S_DUST,V_LEVEL);
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_SCENE_CONTROLLER
|
||||
@@ -241,13 +235,13 @@ void setup()
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_COVER
|
||||
Serial.println(" S_COVER";
|
||||
Serial.println(" S_COVER");
|
||||
gw.present(ID_S_COVER,S_COVER);
|
||||
gw.wait(SHORT_WAIT);
|
||||
#endif
|
||||
|
||||
#ifdef ID_S_TEMP
|
||||
Serial.println(" S_TMEP");
|
||||
Serial.println(" S_TEMP");
|
||||
gw.present(ID_S_TEMP,S_TEMP);
|
||||
gw.wait(SHORT_WAIT);
|
||||
#endif
|
||||
@@ -381,7 +375,7 @@ void loop()
|
||||
gw.wait(LONG_WAIT);
|
||||
|
||||
//Read Sensors
|
||||
#ifdef S_ID_DOOR
|
||||
#ifdef ID_S_DOOR
|
||||
door();
|
||||
#endif
|
||||
|
||||
@@ -492,9 +486,7 @@ void receiveTime(unsigned long controllerTime) {
|
||||
|
||||
}
|
||||
|
||||
//void door(){}
|
||||
|
||||
#ifdef S_ID_DOOR
|
||||
#ifdef ID_S_DOOR
|
||||
void door(){
|
||||
|
||||
Serial.print("Door is: " );
|
||||
@@ -623,7 +615,7 @@ void hum(){
|
||||
void baro(){
|
||||
|
||||
const char *weather[] = {"stable","sunny","cloudy","unstable","thunderstorm","unknown"};
|
||||
long pressure = map(randNumber,1,100,87000,108600);
|
||||
long pressure = map(randNumber,1,100,900,1200);
|
||||
int forecast = map(randNumber,1,100,0,5);
|
||||
|
||||
Serial.print("Atmosferic Pressure is: " );
|
||||
@@ -726,8 +718,9 @@ void power(){
|
||||
|
||||
#ifdef ID_S_HEATER
|
||||
void heater(){
|
||||
int heater_mode = gw.loadState(ID_S_HEATER);
|
||||
bool heater_switch = gw.loadState(ID_S_HEATER+1);
|
||||
int heater_set_point = gw.loadState(ID_S_HEATER);
|
||||
int heater_flow_state = gw.loadState(ID_S_HEATER+1);
|
||||
int heater_temp = gw.loadState(ID_S_HEATER+2);
|
||||
|
||||
Serial.print("Heater mode is: " );
|
||||
|
||||
@@ -754,6 +747,11 @@ void heater(){
|
||||
Serial.println(heater_switch?"On":"Off");
|
||||
|
||||
gw.send(msg_S_HEATER_S.set(heater_switch));
|
||||
|
||||
Serial.print("Heater Temperature is: " );
|
||||
Serial.println(map(randNumber,1,100,0,45));
|
||||
|
||||
gw.send(msg_S_HEATER_T.set(map(randNumber,1,100,0,45)));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@ Arduino sketch to fake sensor for the MySensors Library
|
||||
|
||||
This skecth is intended to crate fake sensors which register and respond to the controller
|
||||
|
||||
Barduino 2015
|
||||
Barduino, GizMoCuz 2015
|
||||
-----------------
|
||||
|
||||
Comment/Uncomment the sensors you would like to test
|
||||
@@ -12,4 +12,4 @@ Arduino Uno R3 can support about 12 sensors before it runs out of memory.
|
||||
You probably need to turn of the MySensor Lib debug to save some memory
|
||||
|
||||
Nest step will be to remove the read/write to the eprom
|
||||
and extend to support the v1.5 sensors
|
||||
and extend 'ID_S_HEATER' to support the v1.5 API
|
||||
|
||||
@@ -68,16 +68,16 @@ NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and
|
||||
MySensor gw;
|
||||
MyMessage msg(CHILD_ID,V_TRIPPED);
|
||||
int oldParkedStatus=-1;
|
||||
int sendInterval = 5000; // Send park status at maximum every 5 second.
|
||||
unsigned long sendInterval = 5000; // Send park status at maximum every 5 second.
|
||||
unsigned long lastSend;
|
||||
#endif
|
||||
|
||||
int blinkInterval = 100; // blink interval (milliseconds)
|
||||
unsigned long blinkInterval = 100; // blink interval (milliseconds)
|
||||
unsigned long lastBlinkPeriod;
|
||||
bool blinkColor = true;
|
||||
|
||||
// To make a fading motion on the led ring/tape we only move one pixel/distDebounce time
|
||||
int distDebounce = 30;
|
||||
unsigned long distDebounce = 30;
|
||||
unsigned long lastDebouncePeriod;
|
||||
int numLightPixels=0;
|
||||
int skipZero=0;
|
||||
@@ -161,4 +161,4 @@ void loop() {
|
||||
}
|
||||
pixels.show(); // This sends the updated pixel color to the hardware.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Created by vil1driver
|
||||
*
|
||||
* DESCRIPTION
|
||||
* RGB led strip controled with three dimmers + one On/Off for run/stop rgb color cycle :p
|
||||
*
|
||||
*/
|
||||
|
||||
#define SN "RGB Led strip 3D"
|
||||
#define SV "v1"
|
||||
|
||||
// Load mysensors library
|
||||
#include <MySensor.h>
|
||||
// Load Serial Peripheral Interface library
|
||||
#include <SPI.h>
|
||||
|
||||
// Arduino pin attached to MOSFET Gate pin
|
||||
#define RED_PIN 3
|
||||
#define GREEN_PIN 5
|
||||
#define BLUE_PIN 6
|
||||
|
||||
MySensor gw;
|
||||
|
||||
// Define message name and type to send sensor info
|
||||
MyMessage RedStatus(RED_PIN, V_DIMMER);
|
||||
MyMessage GreenStatus(GREEN_PIN, V_DIMMER);
|
||||
MyMessage BlueStatus(BLUE_PIN, V_DIMMER);
|
||||
MyMessage Status(1, V_DIMMER);
|
||||
MyMessage rgbShowState(0, V_LIGHT);
|
||||
|
||||
// Serial.print translate sensor id to sensor name
|
||||
char color[][6] = {"","","","RED","","GREEN","BLUE"};
|
||||
|
||||
// Vars for rgbShow function
|
||||
int redval = 0;
|
||||
int greenval = 0;
|
||||
int blueval = 0;
|
||||
long time=0;
|
||||
int isShow;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initializes the sensor node (Callback function for incoming messages, node id, is repeater)
|
||||
gw.begin(incomingMessage, 31, true);
|
||||
|
||||
// Present sketch (name, version)
|
||||
gw.sendSketchInfo(SN, SV);
|
||||
|
||||
// Register sensors (id, type, description, ack back)
|
||||
gw.present(RED_PIN, S_DIMMER, "present RED light", false);
|
||||
gw.present(GREEN_PIN, S_DIMMER, "present GREEN light", false);
|
||||
gw.present(BLUE_PIN, S_DIMMER, "present BLUE light", false);
|
||||
gw.present(0, S_LIGHT, "present Show button", false);
|
||||
|
||||
// Define pin mode (pin number, type)
|
||||
pinMode(RED_PIN, OUTPUT);
|
||||
pinMode(GREEN_PIN, OUTPUT);
|
||||
pinMode(BLUE_PIN, OUTPUT);
|
||||
|
||||
// Correct saved RGB value for first start
|
||||
gw.saveState(RED_PIN, constrain((int8_t)gw.loadState(RED_PIN), 0, 100));
|
||||
gw.saveState(GREEN_PIN, constrain((int8_t)gw.loadState(GREEN_PIN), 0, 100));
|
||||
gw.saveState(BLUE_PIN, constrain((int8_t)gw.loadState(BLUE_PIN), 0, 100));
|
||||
|
||||
// Get value from eeprom and write to output
|
||||
analogWrite(RED_PIN, 255 * gw.loadState(RED_PIN) / 100);
|
||||
analogWrite(GREEN_PIN, 255 * gw.loadState(GREEN_PIN) / 100);
|
||||
analogWrite(BLUE_PIN, 255 * gw.loadState(BLUE_PIN) / 100);
|
||||
|
||||
// Write some debug info
|
||||
Serial.print("Load from eeprom RED: ");
|
||||
Serial.print(gw.loadState(RED_PIN));
|
||||
Serial.println("%");
|
||||
Serial.print("Load from eeprom GREEN: ");
|
||||
Serial.print(gw.loadState(GREEN_PIN));
|
||||
Serial.println("%");
|
||||
Serial.print("Load from eeprom BLUE: ");
|
||||
Serial.print(gw.loadState(BLUE_PIN));
|
||||
Serial.println("%");
|
||||
|
||||
// Send RGB value to controler (request ack back: true/false)
|
||||
Serial.println("Send eeprom value to controler");
|
||||
gw.send( RedStatus.set(gw.loadState(RED_PIN)), false );
|
||||
gw.send( GreenStatus.set(gw.loadState(GREEN_PIN)), false );
|
||||
gw.send( BlueStatus.set(gw.loadState(BLUE_PIN)), false );
|
||||
|
||||
// Correct RGB show state for first start and load it (set to 'On' at first start)
|
||||
gw.saveState(0, constrain((int8_t)gw.loadState(0), 0, 1));
|
||||
isShow=gw.loadState(0);
|
||||
|
||||
// Send RGB show state to controler (request ack back: true/false)
|
||||
gw.send( rgbShowState.set(isShow), false);
|
||||
|
||||
if (isShow==1){Serial.println("RGB show running..."); }
|
||||
Serial.println("Ready to receive messages...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Process incoming messages (like config and light state from controller)
|
||||
gw.process();
|
||||
|
||||
// Run RGB show if is set
|
||||
if (isShow==1)
|
||||
{
|
||||
rgbShow();
|
||||
analogWrite(RED_PIN, redval);
|
||||
analogWrite(GREEN_PIN, greenval);
|
||||
analogWrite(BLUE_PIN, blueval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void incomingMessage(const MyMessage &message)
|
||||
{
|
||||
if (message.isAck())
|
||||
{
|
||||
Serial.println("Got ack from gateway");
|
||||
}
|
||||
if (message.type == V_LIGHT)
|
||||
{
|
||||
// Incoming on/off command sent from controller ("1" or "0")
|
||||
int lightState = message.getString()[0] == '1';
|
||||
|
||||
// if receive RGB Show On commands, start the show
|
||||
if (message.sensor==0 && lightState==1){ rgbShowOn(); }
|
||||
// if receive RGB Show Off commands, stop the show
|
||||
else if (message.sensor==0 && lightState==0){ rgbShowOff(); }
|
||||
|
||||
// if receive RGB switch On command
|
||||
else if (lightState==1)
|
||||
{
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for ");
|
||||
Serial.print(color[message.sensor]);
|
||||
Serial.println(": On");
|
||||
Serial.print("Load from eeprom: ");
|
||||
|
||||
if ( gw.loadState(message.sensor) == 0)
|
||||
{
|
||||
// Pick up last saved dimmer level from the eeprom
|
||||
analogWrite(message.sensor, 255 * gw.loadState(10*message.sensor) / 100);
|
||||
// Save loaded value to current
|
||||
gw.saveState(message.sensor, gw.loadState(10*message.sensor));
|
||||
Serial.print(gw.loadState(10*message.sensor));
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
gw.send(Status.setSensor(message.sensor).set(gw.loadState(10*message.sensor)),false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pick up last saved dimmer level from the eeprom
|
||||
analogWrite(message.sensor, 255 * gw.loadState(message.sensor) / 100);
|
||||
Serial.print(gw.loadState(message.sensor));
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
gw.send(Status.setSensor(message.sensor).set(gw.loadState(message.sensor)),false);
|
||||
}
|
||||
// Stop the show if it's running
|
||||
if (isShow==1){ rgbShowStop(message.sensor); }
|
||||
}
|
||||
// if recieve switch Off command
|
||||
else if (lightState==0)
|
||||
{
|
||||
// Write output to 0 (Off)
|
||||
analogWrite(message.sensor, 0);
|
||||
// Save old value to eeprom if it'was not zero
|
||||
if ( gw.loadState(message.sensor) != 0 )
|
||||
{
|
||||
gw.saveState(10*message.sensor, constrain((int8_t)gw.loadState(message.sensor), 0, 100));
|
||||
}
|
||||
// Save new value to eeprom
|
||||
gw.saveState(message.sensor, 0);
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for ");
|
||||
Serial.print(color[message.sensor]);
|
||||
Serial.print(": ");
|
||||
Serial.println("Off");
|
||||
Serial.print("Store old value: ");
|
||||
Serial.print(gw.loadState(10*message.sensor));
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
gw.send(Status.setSensor(message.sensor).set(gw.loadState(message.sensor)),false);
|
||||
// Stop the show if it's running
|
||||
if (isShow==1){ rgbShowStop(message.sensor); }
|
||||
}
|
||||
}
|
||||
else if (message.type == V_DIMMER)
|
||||
{
|
||||
uint8_t incomingDimmerStatus = message.getByte();
|
||||
// limits range of sensor values to between 0 and 100
|
||||
incomingDimmerStatus = constrain((int8_t)incomingDimmerStatus, 0, 100);
|
||||
// Change Dimmer level
|
||||
analogWrite(message.sensor, 255 * incomingDimmerStatus / 100);
|
||||
//Save value to eeprom
|
||||
gw.saveState(message.sensor, incomingDimmerStatus);
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for ");
|
||||
Serial.print(color[message.sensor]);
|
||||
Serial.print(": ");
|
||||
Serial.print(incomingDimmerStatus);
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
gw.send(Status.setSensor(message.sensor).set(gw.loadState(message.sensor)),false);
|
||||
// Stop the show if it's running
|
||||
if (isShow==1){ rgbShowStop(message.sensor); }
|
||||
}
|
||||
}
|
||||
|
||||
void rgbShow()
|
||||
{
|
||||
time = millis();
|
||||
redval = 128+250*cos(2*PI/300000*time);
|
||||
greenval = 128+250*cos(2*PI/300000*time-222);
|
||||
blueval = 128+250*cos(2*PI/300000*time-111);
|
||||
// limits range of sensor values to between 0 and 255
|
||||
redval = constrain(redval, 0, 255);
|
||||
greenval = constrain(greenval, 0, 255);
|
||||
blueval = constrain(blueval, 0, 255);
|
||||
}
|
||||
|
||||
void rgbShowOn()
|
||||
{
|
||||
// define show On
|
||||
isShow=1;
|
||||
// Save state
|
||||
gw.saveState(0, 1);
|
||||
// Write some debug info
|
||||
Serial.println("Show must go on");
|
||||
}
|
||||
|
||||
void rgbShowOff()
|
||||
{
|
||||
// define show Off
|
||||
isShow=0;
|
||||
// Save state
|
||||
gw.saveState(0, 0);
|
||||
// Save RGB value to eeprom
|
||||
gw.saveState(RED_PIN, 100 * redval / 255);
|
||||
gw.saveState(GREEN_PIN, 100 * greenval / 255);
|
||||
gw.saveState(BLUE_PIN, 100 * blueval / 255);
|
||||
// Write some debug info
|
||||
Serial.println("Stop the show");
|
||||
// Send actual RGB value and state to controler and request ack back (true/false)
|
||||
Serial.println("Send eeprom value to controler");
|
||||
gw.send( RedStatus.set(gw.loadState(RED_PIN)), false );
|
||||
gw.send( GreenStatus.set(gw.loadState(GREEN_PIN)), false );
|
||||
gw.send( BlueStatus.set(gw.loadState(BLUE_PIN)), false );
|
||||
gw.send( rgbShowState.set(0), false);
|
||||
}
|
||||
|
||||
void rgbShowStop(int sensor)
|
||||
{
|
||||
// define show Off
|
||||
isShow=0;
|
||||
// Save state
|
||||
gw.saveState(0, 0);
|
||||
// Write some debug info
|
||||
Serial.println("Stop the show");
|
||||
// Send actual RGB value and state to controler and request ack back (true/false)
|
||||
Serial.println("Send eeprom value to controler");
|
||||
if (sensor != RED_PIN)
|
||||
{
|
||||
gw.saveState(RED_PIN, 100 * redval / 255);
|
||||
gw.send( RedStatus.set(gw.loadState(RED_PIN)), false );
|
||||
}
|
||||
if (sensor != GREEN_PIN)
|
||||
{
|
||||
gw.saveState(GREEN_PIN, 100 * greenval / 255);
|
||||
gw.send( GreenStatus.set(gw.loadState(GREEN_PIN)), false );
|
||||
}
|
||||
if (sensor != BLUE_PIN)
|
||||
{
|
||||
gw.saveState(BLUE_PIN, 100 * blueval / 255);
|
||||
gw.send( BlueStatus.set(gw.loadState(BLUE_PIN)), false );
|
||||
}
|
||||
gw.send( rgbShowState.set(0), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ volatile int wasTippedBuffer = 0;
|
||||
int rainSensorThreshold = 50; //default rain sensor sensitivity in hundredths. Will be overwritten with msgTrippedVar2.
|
||||
byte state = 0;
|
||||
byte oldState = -1;
|
||||
int lastRainRate = 0;
|
||||
unsigned int lastRainRate = 0;
|
||||
int lastMeasure = 0;
|
||||
boolean gotTime = false;
|
||||
byte lastHour;
|
||||
|
||||
+2
-2
@@ -88,8 +88,8 @@ void loop()
|
||||
|
||||
// If no time has been received yet, request it every 10 second from controller
|
||||
// When time has been received, request update every hour
|
||||
if ((!timeReceived && now-lastRequest > 10*1000)
|
||||
|| (timeReceived && now-lastRequest > 60*1000*60)) {
|
||||
if ((!timeReceived && (now-lastRequest) > (10UL*1000UL))
|
||||
|| (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) {
|
||||
// Request time from controller.
|
||||
Serial.println("requesting time");
|
||||
gw.requestTime(receiveTime);
|
||||
|
||||
@@ -298,7 +298,6 @@ boolean validateKnock(){
|
||||
// reads the secret knock from EEPROM. (if any.)
|
||||
void readSecretKnock(){
|
||||
byte reading;
|
||||
int i;
|
||||
reading = gw.loadState(1);
|
||||
if (reading == eepromValid){ // only read EEPROM if the signature byte is correct.
|
||||
for (int i=0; i < maximumKnocks ;i++){
|
||||
|
||||
@@ -71,7 +71,7 @@ MySigningAtsha204 signer;
|
||||
#endif
|
||||
MySensor gw(radio, hw, signer);
|
||||
#else
|
||||
#error SecureActuator cannot possibly be secure without signing enabled
|
||||
// WARNING! SecureActuator cannot possibly be secure without signing enabled
|
||||
MySensor gw(radio, hw);
|
||||
#endif
|
||||
|
||||
@@ -85,7 +85,7 @@ void setup()
|
||||
// Fetch lock status
|
||||
for (int lock=1, pin=LOCK_1; lock<=NOF_LOCKS;lock++, pin++) {
|
||||
// Register all locks to gw (they will be created as child devices)
|
||||
gw.present(lock, S_LOCK, false);
|
||||
gw.present(lock, S_LOCK, "SecureActuator", false);
|
||||
// Then set lock pins in output mode
|
||||
pinMode(pin, OUTPUT);
|
||||
// Set lock to last known state (using eeprom storage)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
#include "utility/SPIFlash.h"
|
||||
|
||||
#define SketchName "Sensebender Blink"
|
||||
#define SketchVersion "20150721"
|
||||
|
||||
@@ -237,7 +237,6 @@ void write_key(uint8_t* key)
|
||||
|
||||
void dump_configuration()
|
||||
{
|
||||
uint8_t config_word[4];
|
||||
uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
|
||||
uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
|
||||
uint8_t ret_code;
|
||||
@@ -682,6 +681,8 @@ void setup()
|
||||
uint8_t lockConfig = 0;
|
||||
uint8_t lockValue = 0;
|
||||
uint16_t crc;
|
||||
(void)crc;
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println(F("ATSHA204 personalization sketch for MySensors usage."));
|
||||
|
||||
@@ -18,48 +18,168 @@
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch sending soil moisture alarm to controller
|
||||
* http://www.mysensors.org/build/moisture
|
||||
*/
|
||||
|
||||
*
|
||||
* Arduino soil moisture based on gypsum sensor/resistive sensor to avoid electric catalyse in soil
|
||||
* Required to interface the sensor: 2 * 4.7kOhm + 2 * 1N4148
|
||||
*
|
||||
* Gypsum sensor and calibration:
|
||||
* DIY: See http://vanderleevineyard.com/1/category/vinduino/1.html
|
||||
* Built: Davis / Watermark 200SS
|
||||
* http://www.cooking-hacks.com/watermark-soil-moisture-sensor?_bksrc=item2item&_bkloc=product
|
||||
* http://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf
|
||||
* cb (centibar) http://www.irrometer.com/basics.html
|
||||
* 0-10 Saturated Soil. Occurs for a day or two after irrigation
|
||||
* 10-20 Soil is adequately wet (except coarse sands which are drying out at this range)
|
||||
* 30-60 Usual range to irrigate or water (except heavy clay soils).
|
||||
* 60-100 Usual range to irrigate heavy clay soils
|
||||
* 100-200 Soil is becoming dangerously dry for maximum production. Proceed with caution.
|
||||
*
|
||||
* Connection:
|
||||
* D6, D7: alternative powering to avoid sensor degradation
|
||||
* A0, A1: alternative resistance mesuring
|
||||
*
|
||||
* Based on:
|
||||
* "Vinduino" portable soil moisture sensor code V3.00
|
||||
* Date December 31, 2012
|
||||
* Reinier van der Lee and Theodore Kaskalis
|
||||
* www.vanderleevineyard.com
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
// Copyright (C) 2015, Reinier van der Lee
|
||||
// www.vanderleevineyard.com
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
#include <math.h> // Conversion equation from resistance to %
|
||||
#include <SPI.h>
|
||||
#include <MySensor.h>
|
||||
#include <MySensor.h>
|
||||
|
||||
#define DIGITAL_INPUT_SOIL_SENSOR 3 // Digital input did you attach your soil sensor.
|
||||
#define INTERRUPT DIGITAL_INPUT_SOIL_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 0 // Id of the sensor child
|
||||
// Setting up format for reading 3 soil sensors
|
||||
#define NUM_READS 10 // Number of sensor reads for filtering
|
||||
#define CHILD_ID 0
|
||||
|
||||
MySensor gw;
|
||||
MyMessage msg(CHILD_ID, V_TRIPPED);
|
||||
int lastSoilValue = -1;
|
||||
MySensor gw; // Arduino initialization
|
||||
MyMessage msg(CHILD_ID, V_LEVEL);
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
void setup()
|
||||
{
|
||||
long buffer[NUM_READS];
|
||||
int index;
|
||||
|
||||
typedef struct { // Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
|
||||
int moisture;
|
||||
long resistance;
|
||||
} values;
|
||||
|
||||
const long knownResistor = 4700; // Constant value of known resistor in Ohms
|
||||
|
||||
int supplyVoltage; // Measured supply voltage
|
||||
int sensorVoltage; // Measured sensor voltage
|
||||
|
||||
values valueOf[NUM_READS]; // Calculated moisture percentages and resistances to be sorted and filtered
|
||||
|
||||
int i; // Simple index variable
|
||||
|
||||
void setup() {
|
||||
// initialize serial communications at 9600 bps:
|
||||
Serial.begin(115200);
|
||||
gw.begin();
|
||||
gw.sendSketchInfo("Soil Moisture Sensor Reverse Polarity", "1.0");
|
||||
gw.present(CHILD_ID, S_HUM);
|
||||
// initialize the digital pins as an output.
|
||||
// Pin 6,7 is for sensor 1
|
||||
// initialize the digital pin as an output.
|
||||
// Pin 6 is sense resistor voltage supply 1
|
||||
pinMode(6, OUTPUT);
|
||||
|
||||
// initialize the digital pin as an output.
|
||||
// Pin 7 is sense resistor voltage supply 2
|
||||
pinMode(7, OUTPUT);
|
||||
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
gw.sendSketchInfo("Soil Moisture Sensor", "1.0");
|
||||
// sets the soil sensor digital pin as input
|
||||
pinMode(DIGITAL_INPUT_SOIL_SENSOR, INPUT);
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.present(CHILD_ID, S_MOTION);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Read digital soil value
|
||||
int soilValue = digitalRead(DIGITAL_INPUT_SOIL_SENSOR); // 1 = Not triggered, 0 = In soil with water
|
||||
if (soilValue != lastSoilValue) {
|
||||
Serial.println(soilValue);
|
||||
gw.send(msg.set(soilValue==0?1:0)); // Send the inverse to gw as tripped should be when no water in soil
|
||||
lastSoilValue = soilValue;
|
||||
|
||||
void loop() {
|
||||
|
||||
measure(6,7,1);
|
||||
Serial.print ("\t");
|
||||
Serial.println (average());
|
||||
long read1 = average();
|
||||
|
||||
measure(7,6,0);
|
||||
Serial.print ("\t");
|
||||
Serial.println (average());
|
||||
long read2= average();
|
||||
|
||||
long sensor1 = (read1 + read2)/2;
|
||||
|
||||
Serial.print ("resistance bias =" );
|
||||
Serial.println (read1-read2);
|
||||
Serial.print ("sensor bias compensated value = ");
|
||||
Serial.println (sensor1);
|
||||
Serial.println ();
|
||||
|
||||
//send back the values
|
||||
gw.send(msg.set((long int)ceil(sensor1)));
|
||||
// delay until next measurement (msec)
|
||||
gw.sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
void measure (int phase_b, int phase_a, int analog_input)
|
||||
{
|
||||
// read sensor, filter, and calculate resistance value
|
||||
// Noise filter: median filter
|
||||
|
||||
for (i=0; i<NUM_READS; i++) {
|
||||
|
||||
// Read 1 pair of voltage values
|
||||
digitalWrite(phase_a, HIGH); // set the voltage supply on
|
||||
delayMicroseconds(25);
|
||||
supplyVoltage = analogRead(analog_input); // read the supply voltage
|
||||
delayMicroseconds(25);
|
||||
digitalWrite(phase_a, LOW); // set the voltage supply off
|
||||
delay(1);
|
||||
|
||||
digitalWrite(phase_b, HIGH); // set the voltage supply on
|
||||
delayMicroseconds(25);
|
||||
sensorVoltage = analogRead(analog_input); // read the sensor voltage
|
||||
delayMicroseconds(25);
|
||||
digitalWrite(phase_b, LOW); // set the voltage supply off
|
||||
|
||||
// Calculate resistance
|
||||
// the 0.5 add-term is used to round to the nearest integer
|
||||
// Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
|
||||
long resistance = (knownResistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ;
|
||||
|
||||
delay(1);
|
||||
addReading(resistance);
|
||||
Serial.print (resistance);
|
||||
Serial.print ("\t");
|
||||
}
|
||||
// Power down the radio and arduino until digital input changes.
|
||||
gw.sleep(INTERRUPT,CHANGE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Averaging algorithm
|
||||
void addReading(long resistance){
|
||||
buffer[index] = resistance;
|
||||
index++;
|
||||
if (index >= NUM_READS) index = 0;
|
||||
}
|
||||
|
||||
long average(){
|
||||
long sum = 0;
|
||||
for (int i = 0; i < NUM_READS; i++){
|
||||
sum += buffer[i];
|
||||
}
|
||||
return (long)(sum / NUM_READS);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ void loop()
|
||||
|
||||
// If no time has been received yet, request it every 10 second from controller
|
||||
// When time has been received, request update every hour
|
||||
if ((!timeReceived && now-lastRequest > 10*1000)
|
||||
|| (timeReceived && now-lastRequest > 60*1000*60)) {
|
||||
if ((!timeReceived && (now-lastRequest) > (10UL*1000UL))
|
||||
|| (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) {
|
||||
// Request time from controller.
|
||||
Serial.println("requesting time");
|
||||
gw.requestTime(receiveTime);
|
||||
|
||||
+11
-10
@@ -77,17 +77,19 @@ int RESEND_DEBOUNCE = 2000; // Number of millisecons interval between sending of
|
||||
|
||||
// Add your buttons here. Max is 5 if you still want time at the top.
|
||||
char *buttons[] = {
|
||||
"Good Morning",
|
||||
"Clean Up!",
|
||||
"All Lights Off",
|
||||
"Music On/Off"
|
||||
(char *)"Good Morning",
|
||||
(char *)"Clean Up!",
|
||||
(char *)"All Lights Off",
|
||||
(char *)"Music On/Off"
|
||||
};
|
||||
|
||||
const int buttonCount = sizeof(buttons)/sizeof(char *);
|
||||
const int padding = 10;
|
||||
const int topBarHeight = 60;
|
||||
|
||||
MySensor gw(17,18);
|
||||
MyTransportNRF24 radio; // NRFRF24L01 radio driver
|
||||
MyHwATMega328 hw; // Select AtMega328 hardware profile
|
||||
MySensor gw(radio, hw);
|
||||
MyMessage on(CHILD_ID, V_SCENE_ON);
|
||||
MyMessage off(CHILD_ID, V_SCENE_OFF);
|
||||
|
||||
@@ -142,13 +144,12 @@ void loop()
|
||||
unsigned long now = millis();
|
||||
|
||||
if (myTouch.dataAvailable()) {
|
||||
unsigned long startPress = millis();
|
||||
int pressedButton = myButtons.checkButtons();
|
||||
|
||||
if (pressedButton>=0) {
|
||||
bool longPress = millis()-now>LONG_PRESS;
|
||||
bool longPress = millis()-now>(unsigned long)LONG_PRESS;
|
||||
|
||||
if (pressedButton != lastPressedButton || now-lastPressedButtonTime > RESEND_DEBOUNCE) {
|
||||
if (pressedButton != lastPressedButton || now-lastPressedButtonTime > (unsigned long)RESEND_DEBOUNCE) {
|
||||
if (longPress) {
|
||||
gw.send(off.set(pressedButton));
|
||||
Serial.print("Long pressed: ");
|
||||
@@ -165,8 +166,8 @@ void loop()
|
||||
|
||||
// If no time has been received yet, request it every 10 second from controller
|
||||
// When time has been received, request update every hour
|
||||
if ((!timeReceived && now-lastRequest > 10*1000)
|
||||
|| (timeReceived && now-lastRequest > 60*1000*60)) {
|
||||
if ((!timeReceived && now-lastRequest > (unsigned long)10*1000)
|
||||
|| (timeReceived && now-lastRequest > (unsigned long)60*1000*60)) {
|
||||
// Request time from controller.
|
||||
Serial.println("requesting time");
|
||||
gw.requestTime(receiveTime);
|
||||
|
||||
@@ -53,7 +53,7 @@ MyMessage uvMsg(CHILD_ID_UV, V_UV);
|
||||
unsigned long lastSend =0;
|
||||
float uvIndex;
|
||||
float lastUV = -1;
|
||||
int uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
|
||||
uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
|
||||
|
||||
void setup()
|
||||
{
|
||||
@@ -98,7 +98,7 @@ void loop()
|
||||
//Serial.println(uvIndex,2);
|
||||
|
||||
//Send value to gateway if changed, or at least every 5 minutes
|
||||
if ((uvIndex != lastUV)||(currentTime-lastSend >= 5*60*1000)) {
|
||||
if ((uvIndex != lastUV)||(currentTime-lastSend >= 5UL*60UL*1000UL)) {
|
||||
lastSend=currentTime;
|
||||
gw.send(uvMsg.set(uvIndex,2));
|
||||
lastUV = uvIndex;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Vibration Sensor
|
||||
*
|
||||
* connect the sensor as follows :
|
||||
*
|
||||
* VCC >>> 5V
|
||||
* S >>> D3
|
||||
* GND >>> GND
|
||||
*
|
||||
* Based on: http://www.dfrobot.com/wiki/index.php/DFRobot_Digital_Vibration_Sensor_V2_SKU:DFR0027
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#define CHILD_ID_VIBRATION 0
|
||||
#define VIBRATION_SENSOR_DIGITAL_PIN 3
|
||||
#define SensorLED 13
|
||||
|
||||
unsigned long SLEEP_TIME = 10*1000; // Sleep time between reads (in seconds)
|
||||
|
||||
//VARIABLES
|
||||
int val = 0; // variable to store the value coming from the sensor
|
||||
float valVIBRATION =0.0;
|
||||
float lastVIBRATION =0.0;
|
||||
unsigned char state = 0;
|
||||
|
||||
MySensor gw;
|
||||
MyMessage vibrationMsg(CHILD_ID_VIBRATION, V_LEVEL);
|
||||
|
||||
void setup()
|
||||
{
|
||||
gw.begin();
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
gw.sendSketchInfo("VIBRATION Sensor", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
gw.present(CHILD_ID_VIBRATION, S_VIBRATION);
|
||||
|
||||
|
||||
pinMode(VIBRATION_SENSOR_DIGITAL_PIN, INPUT);
|
||||
attachInterrupt(1, blink, FALLING);// Trigger the blink function when the falling edge is detected
|
||||
pinMode(SensorLED, OUTPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if(state>=40){ // basically below 40 so ignire basic level
|
||||
gw.send(vibrationMsg.set(int(state)));
|
||||
state = 0;
|
||||
digitalWrite(SensorLED,HIGH);
|
||||
} else {
|
||||
state = 0;
|
||||
digitalWrite(SensorLED,LOW);
|
||||
}
|
||||
|
||||
|
||||
// Power down the radio. Note that the radio will get powered back up
|
||||
// on the next write() call.
|
||||
delay(1000); //delay to allow serial to fully print before sleep
|
||||
|
||||
gw.sleep(SLEEP_TIME); //sleep for: sleepTime
|
||||
}
|
||||
|
||||
void blink()//Interrupts function
|
||||
{
|
||||
state++;
|
||||
}
|
||||
@@ -463,7 +463,8 @@ uint8_t ATSHA204Class::sha204m_execute(uint8_t op_code, uint8_t param1, uint16_t
|
||||
uint8_t poll_delay, poll_timeout, response_size;
|
||||
uint8_t *p_buffer;
|
||||
uint8_t len;
|
||||
|
||||
(void)tx_size;
|
||||
|
||||
// Supply delays and response size.
|
||||
switch (op_code)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ void RF24::csn(bool mode)
|
||||
delayMicroseconds(11); // allow csn to settle
|
||||
}
|
||||
}
|
||||
#else if !defined (__arm__) || defined (CORE_TEENSY)
|
||||
#elif !defined (__arm__) || defined (CORE_TEENSY)
|
||||
digitalWrite(csn_pin,mode);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -55,9 +55,9 @@ bool RFM69::initialize(byte freqBand, byte nodeID, byte networkID)
|
||||
/* 0x05 */ { REG_FDEVMSB, RF_FDEVMSB_50000}, //default:5khz, (FDEV + BitRate/2 <= 500Khz)
|
||||
/* 0x06 */ { REG_FDEVLSB, RF_FDEVLSB_50000},
|
||||
|
||||
/* 0x07 */ { REG_FRFMSB, (freqBand==RF69_315MHZ ? RF_FRFMSB_315 : (freqBand==RF69_433MHZ ? RF_FRFMSB_433 : (freqBand==RF69_868MHZ ? RF_FRFMSB_868 : RF_FRFMSB_915))) },
|
||||
/* 0x08 */ { REG_FRFMID, (freqBand==RF69_315MHZ ? RF_FRFMID_315 : (freqBand==RF69_433MHZ ? RF_FRFMID_433 : (freqBand==RF69_868MHZ ? RF_FRFMID_868 : RF_FRFMID_915))) },
|
||||
/* 0x09 */ { REG_FRFLSB, (freqBand==RF69_315MHZ ? RF_FRFLSB_315 : (freqBand==RF69_433MHZ ? RF_FRFLSB_433 : (freqBand==RF69_868MHZ ? RF_FRFLSB_868 : RF_FRFLSB_915))) },
|
||||
/* 0x07 */ { REG_FRFMSB, (freqBand==RF69_315MHZ ? (const byte)RF_FRFMSB_315 : (freqBand==RF69_433MHZ ? (const byte)RF_FRFMSB_433 : (freqBand==RF69_868MHZ ? (const byte)RF_FRFMSB_868 : (const byte)RF_FRFMSB_915))) },
|
||||
/* 0x08 */ { REG_FRFMID, (freqBand==RF69_315MHZ ? (const byte)RF_FRFMID_315 : (freqBand==RF69_433MHZ ? (const byte)RF_FRFMID_433 : (freqBand==RF69_868MHZ ? (const byte)RF_FRFMID_868 : (const byte)RF_FRFMID_915))) },
|
||||
/* 0x09 */ { REG_FRFLSB, (freqBand==RF69_315MHZ ? (const byte)RF_FRFLSB_315 : (freqBand==RF69_433MHZ ? (const byte)RF_FRFLSB_433 : (freqBand==RF69_868MHZ ? (const byte)RF_FRFLSB_868 : (const byte)RF_FRFLSB_915))) },
|
||||
|
||||
// looks like PA1 and PA2 are not implemented on RFM69W, hence the max output power is 13dBm
|
||||
// +17dBm and +20dBm are possible on RFM69HW
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
||||
#define RF69_IRQ_PIN 2
|
||||
#define RF69_IRQ_NUM 0
|
||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega2560__)
|
||||
#define RF69_IRQ_PIN 2
|
||||
#define RF69_IRQ_NUM 2
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
|
||||
@@ -61,6 +61,7 @@ void PN532::begin()
|
||||
/**************************************************************************/
|
||||
void PN532::PrintHex(const uint8_t *data, const uint32_t numBytes)
|
||||
{
|
||||
(void)data;
|
||||
for (uint8_t i = 0; i < numBytes; i++) {
|
||||
DMSG("0x");
|
||||
DMSG_HEX(data[i]);
|
||||
@@ -86,11 +87,11 @@ void PN532::PrintHexChar(const uint8_t *data, const uint32_t numBytes)
|
||||
}
|
||||
DMSG(" ");
|
||||
for (uint8_t i = 0; i < numBytes; i++) {
|
||||
char c = data[i];
|
||||
uint8_t c = data[i];
|
||||
if (c <= 0x1f || c > 0x7f) {
|
||||
DMSG('.');
|
||||
} else {
|
||||
DMSG(c);
|
||||
DMSG((char)c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,7 +549,7 @@ uint8_t PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber, uint8_t uriIden
|
||||
// in NDEF records
|
||||
|
||||
// Setup the sector buffer (w/pre-formatted TLV wrapper and NDEF message)
|
||||
uint8_t sectorbuffer1[16] = {0x00, 0x00, 0x03, len + 5, 0xD1, 0x01, len + 1, 0x55, uriIdentifier, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t sectorbuffer1[16] = {0x00, 0x00, 0x03, (uint8_t)(len + 5), 0xD1, 0x01, (uint8_t)(len + 1), 0x55, uriIdentifier, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F, 0x07, 0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
@@ -653,6 +654,7 @@ uint8_t PN532::mifareultralight_ReadPage (uint8_t page, uint8_t *buffer)
|
||||
bool PN532::inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response, uint8_t *responseLength)
|
||||
{
|
||||
uint8_t i;
|
||||
(void)i;
|
||||
|
||||
pn532_packetbuffer[0] = 0x40; // PN532_COMMAND_INDATAEXCHANGE;
|
||||
pn532_packetbuffer[1] = inListedTag;
|
||||
|
||||
@@ -37,6 +37,7 @@ int8_t LLCP::activate(uint16_t timeout)
|
||||
int8_t LLCP::waitForConnection(uint16_t timeout)
|
||||
{
|
||||
uint8_t type;
|
||||
(void)timeout;
|
||||
|
||||
sequence = 0;
|
||||
|
||||
@@ -76,6 +77,7 @@ int8_t LLCP::waitForConnection(uint16_t timeout)
|
||||
int8_t LLCP::waitForDisconnection(uint16_t timeout)
|
||||
{
|
||||
uint8_t type;
|
||||
(void)timeout;
|
||||
|
||||
// Get DISC PDU
|
||||
DMSG("wait for a DISC PDU\n");
|
||||
@@ -113,6 +115,7 @@ int8_t LLCP::waitForDisconnection(uint16_t timeout)
|
||||
int8_t LLCP::connect(uint16_t timeout)
|
||||
{
|
||||
uint8_t type;
|
||||
(void)timeout;
|
||||
|
||||
sequence = 0;
|
||||
|
||||
@@ -165,6 +168,7 @@ int8_t LLCP::connect(uint16_t timeout)
|
||||
int8_t LLCP::disconnect(uint16_t timeout)
|
||||
{
|
||||
uint8_t type;
|
||||
(void)timeout;
|
||||
|
||||
// try to get a SYMM PDU
|
||||
if (2 > link.read(headerBuf, headerBufLen)) {
|
||||
@@ -207,7 +211,6 @@ int8_t LLCP::disconnect(uint16_t timeout)
|
||||
|
||||
bool LLCP::write(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen)
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t buf[3];
|
||||
|
||||
if (2 != link.read(buf, sizeof(buf))) {
|
||||
|
||||
@@ -79,7 +79,7 @@ int16_t SNEP::read(uint8_t *buf, uint8_t len, uint16_t timeout)
|
||||
}
|
||||
|
||||
// check message's length
|
||||
uint32_t length = (buf[2] << 24) + (buf[3] << 16) + (buf[4] << 8) + buf[5];
|
||||
uint32_t length = ((uint32_t)buf[2] << 24) + ((uint32_t)buf[3] << 16) + (buf[4] << 8) + buf[5];
|
||||
// length should not be more than 244 (header + body < 255, header = 6 + 3 + 2)
|
||||
if (length > (status - 6)) {
|
||||
DMSG("The SNEP message is too large\n");
|
||||
|
||||
@@ -78,15 +78,8 @@ uint8_t PWF_AS3935::_sing_reg_read(uint8_t RegAdd)
|
||||
|
||||
void PWF_AS3935::_sing_reg_write(uint8_t RegAdd, uint8_t DataMask, uint8_t RegData)
|
||||
{
|
||||
// start by reading original register data (only modifying what we need to)
|
||||
uint8_t OrigRegData = _sing_reg_read(RegAdd);
|
||||
|
||||
// calculate new register data... 'delete' old targeted data, replace with new data
|
||||
// note: 'DataMask' must be bits targeted for replacement
|
||||
// add'l note: this function does NOT shift values into the proper place... they need to be there already
|
||||
uint8_t NewRegData = ((OrigRegData & ~DataMask) | (RegData & DataMask));
|
||||
|
||||
// now configure and write the updated register value
|
||||
(void)DataMask;
|
||||
// Configure and write the updated register value
|
||||
digitalWrite(_cs, LOW); // set pin low to start talking to IC
|
||||
// next pack command byte, send AS3935.... structure is shown below
|
||||
// MODE Register Address/Direct Cmd
|
||||
@@ -228,7 +221,7 @@ uint32_t PWF_AS3935::AS3935_GetStrikeEnergyRaw(void)
|
||||
{
|
||||
uint32_t nrgy_raw = ((_sing_reg_read(0x06) & 0x1F) << 8); // MMSB, shift 8 bits left, make room for MSB
|
||||
nrgy_raw |= _sing_reg_read(0x05); // read MSB
|
||||
nrgy_raw <= 8; // shift 8 bits left, make room for LSB
|
||||
nrgy_raw <<= 8; // shift 8 bits left, make room for LSB
|
||||
nrgy_raw |= _sing_reg_read(0x04); // read LSB, add to others
|
||||
|
||||
return nrgy_raw;
|
||||
|
||||
@@ -474,7 +474,8 @@ void PCintPort::detachInterrupt(uint8_t arduinoPin)
|
||||
// there isn't really a good way to back-map ports and masks to pins.
|
||||
void PCintPort::PCint() {
|
||||
uint8_t thisChangedPin; //MIKE
|
||||
|
||||
(void)thisChangedPin;
|
||||
|
||||
#ifdef FLASH
|
||||
if (*led_port & led_mask) *led_port&=not_led_mask;
|
||||
else *led_port|=led_mask;
|
||||
|
||||
@@ -230,6 +230,7 @@ unsigned long KaKuTransmitter::getTelegram(char address, byte device, boolean on
|
||||
}
|
||||
|
||||
void KaKuTransmitter::sendSignal(char address, byte group, byte device, boolean on) {
|
||||
(void)device;
|
||||
sendTelegram(getTelegram(address, group, on), _pin);
|
||||
}
|
||||
|
||||
|
||||
@@ -854,8 +854,8 @@ void UTFT::printChar(byte c, int x, int y)
|
||||
{
|
||||
setXY(x,y,x+cfont.x_size-1,y+cfont.y_size-1);
|
||||
|
||||
temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
|
||||
for(j=0;j<((cfont.x_size/8)*cfont.y_size);j++)
|
||||
temp=(word)((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
|
||||
for(j=0;j<(word)((cfont.x_size/8)*cfont.y_size);j++)
|
||||
{
|
||||
ch=pgm_read_byte(&cfont.font[temp]);
|
||||
for(i=0;i<8;i++)
|
||||
@@ -876,7 +876,7 @@ void UTFT::printChar(byte c, int x, int y)
|
||||
{
|
||||
temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
|
||||
|
||||
for(j=0;j<((cfont.x_size/8)*cfont.y_size);j+=(cfont.x_size/8))
|
||||
for(j=0;j<(word)((cfont.x_size/8)*cfont.y_size);j+=(cfont.x_size/8))
|
||||
{
|
||||
setXY(x,y+(j/(cfont.x_size/8)),x+cfont.x_size-1,y+(j/(cfont.x_size/8)));
|
||||
for (int zz=(cfont.x_size/8)-1; zz>=0; zz--)
|
||||
@@ -1080,7 +1080,7 @@ void UTFT::printNumF(double num, byte dec, int x, int y, char divider, int lengt
|
||||
|
||||
if (divider != '.')
|
||||
{
|
||||
for (int i=0; i<sizeof(st); i++)
|
||||
for (unsigned int i=0; i<sizeof(st); i++)
|
||||
if (st[i]=='.')
|
||||
st[i]=divider;
|
||||
}
|
||||
@@ -1090,13 +1090,13 @@ void UTFT::printNumF(double num, byte dec, int x, int y, char divider, int lengt
|
||||
if (neg)
|
||||
{
|
||||
st[0]='-';
|
||||
for (int i=1; i<sizeof(st); i++)
|
||||
for (unsigned int i=1; i<sizeof(st); i++)
|
||||
if ((st[i]==' ') || (st[i]=='-'))
|
||||
st[i]=filler;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<sizeof(st); i++)
|
||||
for (unsigned int i=0; i<sizeof(st); i++)
|
||||
if (st[i]==' ')
|
||||
st[i]=filler;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void UTFT_Buttons::deleteAllButtons()
|
||||
buttons[i].width=0;
|
||||
buttons[i].height=0;
|
||||
buttons[i].flags=BUTTON_UNUSED;
|
||||
buttons[i].label="";
|
||||
buttons[i].label[0]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ int UTFT_Buttons::checkButtons()
|
||||
{
|
||||
if (((buttons[i].flags & BUTTON_UNUSED) == 0) and ((buttons[i].flags & BUTTON_DISABLED) == 0) and (result == -1))
|
||||
{
|
||||
if ((touch_x >= buttons[i].pos_x) and (touch_x <= (buttons[i].pos_x + buttons[i].width)) and (touch_y >= buttons[i].pos_y) and (touch_y <= (buttons[i].pos_y + buttons[i].height)))
|
||||
if ((touch_x >= (int)buttons[i].pos_x) and (touch_x <= (int)(buttons[i].pos_x + buttons[i].width)) and (touch_y >= (int)buttons[i].pos_y) and (touch_y <= (int)(buttons[i].pos_y + buttons[i].height)))
|
||||
result = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,6 +791,19 @@ uint8_t atsha204Class::sha204m_check_parameters(uint8_t op_code, uint8_t param1,
|
||||
return SHA204_SUCCESS;
|
||||
|
||||
#else
|
||||
(void)rx_size;
|
||||
(void)tx_size;
|
||||
(void)tx_buffer;
|
||||
(void)rx_buffer;
|
||||
(void)param1;
|
||||
(void)param2;
|
||||
(void)data1;
|
||||
(void)data2;
|
||||
(void)data3;
|
||||
(void)datalen1;
|
||||
(void)datalen2;
|
||||
(void)datalen3;
|
||||
(void)op_code;
|
||||
return SHA204_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user