Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b466f43538 | ||
|
f5f1b697a7 | ||
|
7ff8935a6a |
412
src/main.cpp
412
src/main.cpp
|
@ -1,143 +1,59 @@
|
||||||
//******************************************************************************************
|
|
||||||
// File: ST_Anything_Multiples_EthernetW5x00_MEGA.ino
|
|
||||||
// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
|
|
||||||
//
|
|
||||||
// Summary: This Arduino Sketch, along with the ST_Anything library and the
|
|
||||||
// revised SmartThings
|
|
||||||
// library, demonstrates the ability of one Arduino + Ethernet W5x00
|
|
||||||
// Shield to implement a multi input/output custom device for
|
|
||||||
// integration into SmartThings. The ST_Anything library takes care
|
|
||||||
// of all of the work to schedule device updates as well as all
|
|
||||||
// communications with the Ethernet W5x00 Shield.
|
|
||||||
//
|
|
||||||
// ST_Anything_Multiples implements the following ST Capabilities in
|
|
||||||
// multiples of 2 as a demo of what is possible with a single Arduino
|
|
||||||
// - 2 x Door Control devices (used typically for Garage Doors -
|
|
||||||
// input pin (contact sensor) and output pin (relay switch)
|
|
||||||
// - 2 x Contact Sensor devices (used to monitor magnetic door
|
|
||||||
// sensors)
|
|
||||||
// - 2 x Switch devices (used to turn on a digital output (e.g.
|
|
||||||
// LED, relay, etc...)
|
|
||||||
// - 2 x Water Sensor devices (using an analog input pin to measure
|
|
||||||
// voltage from a water detector board)
|
|
||||||
// - 2 x Illuminance Measurement devices (using a photoresitor
|
|
||||||
// attached to ananlog input)
|
|
||||||
// - 2 x Voltage Measurement devices (using a photoresitor attached
|
|
||||||
// to ananlog input)
|
|
||||||
// - 2 x Smoke Detector devices (using simple digital input)
|
|
||||||
// - 2 x Carbon Monoxide Detector devices (using simple digital
|
|
||||||
// input)
|
|
||||||
// - 2 x Motion devices (used to detect motion)
|
|
||||||
// - 2 x Temperature Measurement devices (Temperature from DHT22
|
|
||||||
// device)
|
|
||||||
// - 2 x Humidity Measurement devices (Humidity from DHT22 device)
|
|
||||||
// - 2 x Relay Switch devices (used to turn on a digital output for
|
|
||||||
// a set number of cycles And On/Off times (e.g.relay, etc...))
|
|
||||||
// - 2 x Button devices (sends "pushed" if held for less than 1
|
|
||||||
// second, else sends "held"
|
|
||||||
// - 2 x Alarm devices - 1 siren only, 1 siren and strobe (using
|
|
||||||
// simple digital outputs)
|
|
||||||
// - 2 x Dimmer Switch devices - uses 2 digital outputs, one for
|
|
||||||
// on/off and one for pwm level
|
|
||||||
// - 2 x MQ-2 Smoke Detector devices (using simple analog input
|
|
||||||
// compared to user defined limit)
|
|
||||||
//
|
|
||||||
// During the development of this re-usable library, it became
|
|
||||||
// apparent that the Arduino UNO R3's very limited 2K of SRAM was
|
|
||||||
// very limiting in the number of devices that could be implemented
|
|
||||||
// simultaneously. A tremendous amount of effort has gone into
|
|
||||||
// reducing the SRAM usage, including siginificant improvements to
|
|
||||||
// the SmartThings Arduino library.
|
|
||||||
//
|
|
||||||
// Note: This sketch was fully tested on an Arduino MEGA 2560 using
|
|
||||||
// the Ethernet W5x00 Shield.
|
|
||||||
//
|
|
||||||
// Change History:
|
|
||||||
//
|
|
||||||
// Date Who What
|
|
||||||
// ---- --- ----
|
|
||||||
// 2015-01-03 Dan & Daniel Original Creation
|
|
||||||
// 2017-02-12 Dan Ogorchock Revised to use the new SMartThings v2.0 library
|
|
||||||
// 2017-04-16 Dan Ogorchock New sketch to demonstrate multiple SmartThings
|
|
||||||
// Capabilties of each type 2017-04-22 Dan Ogorchock Added Voltage, Carbon
|
|
||||||
// Monoxide, and Alarm with Strobe 2017-07-04 Dan Ogorchock Added MQ-2
|
|
||||||
// based Smoke Detection
|
|
||||||
//
|
|
||||||
//******************************************************************************************
|
|
||||||
//******************************************************************************************
|
|
||||||
// SmartThings Library for Arduino Ethernet W5x00 Shield
|
|
||||||
//******************************************************************************************
|
|
||||||
#include <SmartThingsEthernetW5x00.h> //Library to provide API to the SmartThings Ethernet W5x00 Shield
|
|
||||||
|
|
||||||
//******************************************************************************************
|
#include <SmartThingsEthernetW5x00.h>
|
||||||
// ST_Anything Library
|
|
||||||
//******************************************************************************************
|
|
||||||
#include <Constants.h> //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library
|
|
||||||
#include <Device.h> //Generic Device Class, inherited by Sensor and Executor classes
|
|
||||||
#include <Everything.h> //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications
|
|
||||||
#include <Executor.h> //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch)
|
|
||||||
#include <InterruptSensor.h> //Generic Interrupt "Sensor" Class, waits for change of state on digital input
|
|
||||||
#include <PollingSensor.h> //Generic Polling "Sensor" Class, polls Arduino pins periodically
|
|
||||||
#include <Sensor.h> //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...)
|
|
||||||
|
|
||||||
#include <EX_Alarm.h> //Implements Executor (EX)as an Alarm capability with Siren and Strobe via digital outputs to relays
|
#include <Constants.h>
|
||||||
#include <EX_Switch.h> //Implements an Executor (EX) via a digital output to a relay
|
#include <Device.h>
|
||||||
#include <EX_Switch_Dim.h> //Implements an Executor (EX) for a switch (on/off) and pwm output (level) uses 2 digital output pins
|
#include <Everything.h>
|
||||||
#include <IS_Button.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin for button presses
|
#include <Executor.h>
|
||||||
#include <IS_CarbonMonoxide.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
|
#include <InterruptSensor.h>
|
||||||
#include <IS_Contact.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
|
#include <PollingSensor.h>
|
||||||
#include <IS_DoorControl.h> //Implements an Interrupt Sensor (IS) and Executor to monitor the status of a digital input pin and control a digital output pin
|
#include <Sensor.h>
|
||||||
#include <IS_Motion.h> //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor on a digital input pin
|
|
||||||
#include <IS_Smoke.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
|
|
||||||
#include <PS_Illuminance.h> //Implements a Polling Sensor (PS) to measure light levels via a photo resistor on an analog input pin
|
|
||||||
#include <PS_MQ2_Smoke.h> //Implements an Polling Sensor (PS) to monitor the status of an analog input pin from a MQ2 sensor
|
|
||||||
#include <PS_TemperatureHumidity.h> //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
|
|
||||||
#include <PS_Voltage.h> //Implements a Polling Sensor (PS) to measure voltage on an analog input pin
|
|
||||||
#include <PS_Water.h> //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector) on an analog input pin
|
|
||||||
#include <S_TimedRelay.h> //Implements a Sensor to control a digital output pin with timing/cycle repeat capabilities
|
|
||||||
|
|
||||||
//**********************************************************************************************************
|
#include <EX_Alarm.h>
|
||||||
// Define which Arduino Pins will be used for each device
|
#include <EX_Switch.h>
|
||||||
// Notes: Arduino communicates with both the W5x00 and SD card using the SPI
|
#include <EX_Switch_Dim.h>
|
||||||
// bus (through the ICSP header).
|
#include <IS_Button.h>
|
||||||
// This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50,
|
#include <IS_CarbonMonoxide.h>
|
||||||
// 51, and 52 on the Mega. On both boards, pin 10 is used to select the
|
#include <IS_Contact.h>
|
||||||
// W5x00 and pin 4 for the SD card. These pins cannot be used for
|
#include <IS_DoorControl.h>
|
||||||
// general I/O. On the Mega, the hardware SS pin, 53, is not used to
|
#include <IS_Motion.h>
|
||||||
// select either the W5x00 or the SD card, but it must be kept as an
|
#include <IS_Smoke.h>
|
||||||
// output or the SPI interface won't work. See
|
#include <PS_Illuminance.h>
|
||||||
// https://www.arduino.cc/en/Main/ArduinoEthernetShieldV1 for details on
|
#include <PS_MQ2_Smoke.h>
|
||||||
// the W5x00 Sield
|
#include <PS_TemperatureHumidity.h>
|
||||||
//**********************************************************************************************************
|
#include <PS_Voltage.h>
|
||||||
//"RESERVED" pins for W5x00 Ethernet Shield - best to avoid
|
#include <PS_Water.h>
|
||||||
#define PIN_4_RESERVED 4 // reserved by W5x00 Shield on both UNO and MEGA
|
#include <S_TimedRelay.h>
|
||||||
#define PIN_1O_RESERVED 10 // reserved by W5x00 Shield on both UNO and MEGA
|
|
||||||
#define PIN_11_RESERVED 11 // reserved by W5x00 Shield on UNO
|
#define PIN_4_RESERVED 4
|
||||||
#define PIN_12_RESERVED 12 // reserved by W5x00 Shield on UNO
|
#define PIN_1O_RESERVED 10
|
||||||
#define PIN_13_RESERVED 13 // reserved by W5x00 Shield on UNO
|
#define PIN_11_RESERVED 11
|
||||||
#define PIN_50_RESERVED 50 // reserved by W5x00 Shield on MEGA
|
#define PIN_12_RESERVED 12
|
||||||
#define PIN_51_RESERVED 51 // reserved by W5x00 Shield on MEGA
|
#define PIN_13_RESERVED 13
|
||||||
#define PIN_52_RESERVED 52 // reserved by W5x00 Shield on MEGA
|
#define PIN_50_RESERVED 50
|
||||||
#define PIN_53_RESERVED 53 // reserved by W5x00 Shield on MEGA
|
#define PIN_51_RESERVED 51
|
||||||
|
#define PIN_52_RESERVED 52
|
||||||
|
#define PIN_53_RESERVED 53
|
||||||
|
|
||||||
// WC
|
// WC
|
||||||
#define PIN_WC_LUC_1 24
|
#define PIN_WC_TIPKA_1 24
|
||||||
#define PIN_WC_LUC_2 25
|
#define PIN_WC_TIPKA_2 25
|
||||||
#define PIN_WC_ALARM 26
|
#define PIN_WC_ALARM 26
|
||||||
#define PIN_WC_TEMPHUM 27
|
#define PIN_WC_TEMPHUM 27
|
||||||
|
#define PIN_WC_LUC_1 28
|
||||||
|
|
||||||
// Hodnik
|
// Hodnik
|
||||||
#define PIN_HODNIK_VRATA 28
|
#define PIN_HODNIK_VRATA_VHOD 29
|
||||||
#define PIN_HODNIK_LUC_1 29
|
#define PIN_HODNIK_LUC_1 30
|
||||||
#define PIN_HODNIK_LUC_2 30
|
#define PIN_HODNIK_LUC_2 31
|
||||||
#define PIN_HODNIK_LUC_3 31
|
#define PIN_HODNIK_LUC_3 32
|
||||||
#define PIN_HODNIK_LUC_4 32
|
#define PIN_HODNIK_LUC_4 33
|
||||||
#define PIN_HODNIK_ZVONEC 33
|
#define PIN_HODNIK_ZVONEC_TIPKA 34
|
||||||
#define PIN_HODNIK_LED_OMARA 34
|
#define PIN_HODNIK_OMARE_LED 35
|
||||||
#define PIN_HODNIK_LED_STROP 35
|
#define PIN_HODNIK_STROP_LED 36
|
||||||
#define PIN_HODNIK_ZUNAJ_VHOD 36
|
#define PIN_ZUNAJ_LUC 37
|
||||||
#define PIN_HODNIK_SENZOR_STOPNISCE 37
|
#define PIN_HODNIK_STOPNISCE_SENZOR 38
|
||||||
#define PIN_HODNIK_SENZOR_VRATA 38
|
#define PIN_HODNIK_VRATA_SENZOR 39
|
||||||
|
|
||||||
// Jedilnica
|
// Jedilnica
|
||||||
#define PIN_JEDILNICA_TIPKA_1 40
|
#define PIN_JEDILNICA_TIPKA_1 40
|
||||||
|
@ -147,211 +63,147 @@
|
||||||
#define PIN_JEDILNICA_TIPKA_5 44
|
#define PIN_JEDILNICA_TIPKA_5 44
|
||||||
#define PIN_JEDILNICA_LUC_1 45
|
#define PIN_JEDILNICA_LUC_1 45
|
||||||
#define PIN_JEDILNICA_LUC_2 46
|
#define PIN_JEDILNICA_LUC_2 46
|
||||||
|
#define PIN_JEDILNICA_LED 47
|
||||||
|
|
||||||
// Dnevna
|
// Dnevna
|
||||||
#define PIN_DNEVNA_LUC_VTICNICA 48
|
#define PIN_DNEVNA_SOBA_LUC_VTICNICA 48
|
||||||
#define PIN_DNEVNA_TEMPHUM_PODSTREHA 49
|
#define PIN_PODSTREHA_TEMPVLAGA 49
|
||||||
#define PIN_DNEVNA_TEMPHUM 50
|
#define PIN_DNEVNA_SOBA_TEMPVLAGA 50
|
||||||
|
|
||||||
// Otroška soba
|
// Otroška soba
|
||||||
#define PIN_OTROSKA_LUC_1 51
|
#define PIN_OTROSKA_TIPKA_1 15
|
||||||
#define PIN_OTROSKA_LUC_2 52
|
#define PIN_OTROSKA_TIPKA_2 16
|
||||||
|
|
||||||
//******************************************************************************************
|
|
||||||
// W5x00 Ethernet Shield Information
|
|
||||||
//******************************************************************************************
|
|
||||||
|
|
||||||
// NOTE - If your shield came with a MAC address sticker - please use that MAC
|
|
||||||
// address!
|
|
||||||
|
|
||||||
// MAC address, leave first octet 0x06, change others to be unique
|
// MAC address, leave first octet 0x06, change others to be unique
|
||||||
byte mac[] = {0x06, 0x02, 0x03, 0x04, 0x05, 0x06};
|
byte mac[] = {0x06, 0x02, 0x03, 0x04, 0x05, 0x06};
|
||||||
|
|
||||||
// Arduino device IP Address
|
// Arduino device IP Address
|
||||||
IPAddress ip(10, 10, 0, 99);
|
IPAddress ip(192, 168, 88, 206);
|
||||||
|
|
||||||
// Router gateway
|
// Router gateway
|
||||||
IPAddress gateway(10, 10, 0, 1);
|
IPAddress gateway(192, 168, 88, 1);
|
||||||
|
|
||||||
// LAN subnet mask
|
// LAN subnet mask
|
||||||
IPAddress subnet(255, 255, 255, 0);
|
IPAddress subnet(255, 255, 255, 0);
|
||||||
|
|
||||||
// DNS server
|
// DNS server
|
||||||
IPAddress dnsserver(10, 10, 0, 1);
|
IPAddress dnsserver(192, 168, 88, 1);
|
||||||
|
|
||||||
// port to run the http server on
|
// port to run the http server on
|
||||||
const unsigned int serverPort = 8090;
|
const unsigned int serverPort = 8090;
|
||||||
|
|
||||||
// Smartthings Hub Information
|
|
||||||
// IPAddress hubIp(192, 168, 1, 149); // smartthings hub ip // <---You
|
|
||||||
// must edit this line! const unsigned int hubPort = 39500; // smartthings hub
|
|
||||||
// port
|
|
||||||
|
|
||||||
// Hubitat Hub Information
|
|
||||||
|
|
||||||
// hubitat hub ip
|
// hubitat hub ip
|
||||||
IPAddress hubIp(192, 168, 88, 251);
|
IPAddress hubIp(192, 168, 88, 251);
|
||||||
|
|
||||||
// hubitat hub port
|
// hubitat hub port
|
||||||
const unsigned int hubPort = 39501;
|
const unsigned int hubPort = 39501;
|
||||||
|
|
||||||
//******************************************************************************************
|
|
||||||
// st::Everything::callOnMsgSend() optional callback routine. This is a sniffer
|
|
||||||
// to monitor
|
|
||||||
// data being sent to ST. This allows a user to act on data changes locally
|
|
||||||
// within the Arduino sktech withotu having to rely on the ST Cloud for
|
|
||||||
// time-critical tasks.
|
|
||||||
//******************************************************************************************
|
|
||||||
void callback(const String &msg) {
|
|
||||||
// Uncomment if it weould be desirable to using this function
|
|
||||||
// Serial.print(F("ST_Anything_Miltiples Callback: Sniffed data = "));
|
|
||||||
// Serial.println(msg);
|
|
||||||
|
|
||||||
// TODO: Add local logic here to take action when a device's value/state is
|
|
||||||
// changed
|
|
||||||
|
|
||||||
// Masquerade as the ThingShield to send data to the Arduino, as if from the
|
|
||||||
// ST Cloud (uncomment and edit following line(s) as you see fit)
|
|
||||||
// st::receiveSmartString("Put your command here!"); //use same strings that
|
|
||||||
// the Device Handler would send
|
|
||||||
}
|
|
||||||
|
|
||||||
//******************************************************************************************
|
|
||||||
// Arduino Setup() routine
|
|
||||||
//******************************************************************************************
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//******************************************************************************************
|
|
||||||
// Declare each Device that is attached to the Arduino
|
|
||||||
// Notes: - For each device, there is typically a corresponding "tile"
|
|
||||||
// defined in your
|
|
||||||
// SmartThings Device Hanlder Groovy code, except when using new
|
|
||||||
// COMPOSITE Device Handler
|
|
||||||
// - For details on each device's constructor arguments below, please
|
|
||||||
// refer to the
|
|
||||||
// corresponding header (.h) and program (.cpp) files.
|
|
||||||
// - The name assigned to each device (1st argument below) must match
|
|
||||||
// the Groovy
|
|
||||||
// Device Handler names. (Note: "temphumid" below is the exception
|
|
||||||
// to this rule as the DHT sensors produce both "temperature" and
|
|
||||||
// "humidity". Data from that particular sensor is sent to the ST
|
|
||||||
// Hub in two separate updates, one for "temperature" and one for
|
|
||||||
// "humidity")
|
|
||||||
// - The new Composite Device Handler is comprised of a Parent DH and
|
|
||||||
// various Child
|
|
||||||
// DH's. The names used below MUST not be changed for the Automatic
|
|
||||||
// Creation of child devices to work properly. Simply increment the
|
|
||||||
// number by +1 for each duplicate device (e.g. contact1, contact2,
|
|
||||||
// contact3, etc...) You can rename the Child Devices to match your
|
|
||||||
// specific use case in the ST Phone Application.
|
|
||||||
//******************************************************************************************
|
|
||||||
// Polling Sensors
|
// Polling Sensors
|
||||||
static st::IS_Contact wcLuc1(F("tipka_wc_luc_1"), PIN_WC_LUC_1, LOW);
|
static st::IS_Button wcTipka1(F("button1"), PIN_WC_TIPKA_1);
|
||||||
static st::IS_Contact wcLuc2(F("tipka_wc_luc_2"), PIN_WC_LUC_2, LOW);
|
static st::IS_Button wcTipka2(F("button2"), PIN_WC_TIPKA_2);
|
||||||
static st::IS_Contact wcAlarm(F("tipka_wc_alarm"), PIN_WC_ALARM, LOW);
|
static st::IS_Motion wcAlarm(F("motion1"), PIN_WC_ALARM, HIGH, true);
|
||||||
static st::PS_TemperatureHumidity wcTempHum(
|
static st::PS_TemperatureHumidity wcTempVlaga(
|
||||||
F("wc_temp_hum"), 60, 40, PIN_WC_TEMPHUM,
|
F("temphumid1"), 60, 40, PIN_WC_TEMPHUM,
|
||||||
st::PS_TemperatureHumidity::DHT22, "wc_temp", "wc_hum");
|
st::PS_TemperatureHumidity::DHT22, "temperature1", "humidity1");
|
||||||
static st::IS_Contact hodnikZvonecTipkalo(F("hodnik_zvonec_tipkalo"),
|
|
||||||
PIN_HODNIK_ZVONEC, LOW);
|
static st::IS_Button hodnikZvonecTipka(F("button3"), PIN_HODNIK_ZVONEC_TIPKA);
|
||||||
static st::IS_Contact jedilnicaTipka1(F("jedilnica_tipka_1"),
|
static st::IS_Motion hodnikStopnisceSenzor(
|
||||||
PIN_JEDILNICA_TIPKA_1, LOW);
|
F("motion2"), PIN_HODNIK_STOPNISCE_SENZOR, LOW, true);
|
||||||
static st::IS_Contact jedilnicaTipka2(F("jedilnica_tipka_2"),
|
static st::IS_Motion hodnikVrataSenzor(F("motion3"), PIN_HODNIK_VRATA_SENZOR,
|
||||||
PIN_JEDILNICA_TIPKA_2, LOW);
|
LOW, true);
|
||||||
static st::IS_Contact jedilnicaTipka3(F("jedilnica_tipka_3"),
|
|
||||||
PIN_JEDILNICA_TIPKA_3, LOW);
|
static st::IS_Button jedilnicaTipka1(F("button4"), PIN_JEDILNICA_TIPKA_1);
|
||||||
static st::IS_Contact jedilnicaTipka4(F("jedilnica_tipka_4"),
|
static st::IS_Button jedilnicaTipka2(F("button5"), PIN_JEDILNICA_TIPKA_2);
|
||||||
PIN_JEDILNICA_TIPKA_4, LOW);
|
static st::IS_Button jedilnicaTipka3(F("button6"), PIN_JEDILNICA_TIPKA_3);
|
||||||
static st::IS_Contact jedilnicaTipka5(F("jedilnica_tipka_5"),
|
static st::IS_Button jedilnicaTipka4(F("button7"), PIN_JEDILNICA_TIPKA_4);
|
||||||
PIN_JEDILNICA_TIPKA_5, LOW);
|
static st::IS_Button jedilnicaTipka5(F("button8"), PIN_JEDILNICA_TIPKA_5);
|
||||||
static st::IS_Contact otroskaTipka1(F("otroska_tipka_1"), PIN_OTROSKA_LUC_1,
|
|
||||||
LOW);
|
static st::IS_Button otroskaSobaTipka1(F("button9"), PIN_OTROSKA_TIPKA_1);
|
||||||
static st::IS_Contact otroskaTipka2(F("jedilnica_tipka_5"), PIN_OTROSKA_LUC_2,
|
static st::IS_Button otroskaSobaTipka2(F("button10"), PIN_OTROSKA_TIPKA_2);
|
||||||
LOW);
|
|
||||||
|
static st::PS_TemperatureHumidity podstrehaTempVlaga(
|
||||||
|
F("temphumid2"), 60, 40, PIN_PODSTREHA_TEMPVLAGA,
|
||||||
|
st::PS_TemperatureHumidity::DHT22, "temperature2", "humidity2");
|
||||||
|
static st::PS_TemperatureHumidity dnevnaSobaTempVlaga(
|
||||||
|
F("temphumid3"), 60, 40, PIN_DNEVNA_SOBA_TEMPVLAGA,
|
||||||
|
st::PS_TemperatureHumidity::DHT22, "temperature3", "humidity3");
|
||||||
|
|
||||||
// Executors
|
// Executors
|
||||||
static st::EX_Switch hodnikLuc1(F("hodnik_luc_1"), PIN_HODNIK_LUC_1, LOW);
|
static st::EX_Switch wcLuc1(F("switch1"), PIN_WC_LUC_1);
|
||||||
static st::EX_Switch hodnikLuc2(F("hodnik_luc_2"), PIN_HODNIK_LUC_2, LOW);
|
|
||||||
static st::EX_Switch hodnikLuc3(F("hodnik_luc_3"), PIN_HODNIK_LUC_3, LOW);
|
|
||||||
static st::EX_Switch hodnikLuc4(F("hodnik_luc_4"), PIN_HODNIK_LUC_4, LOW);
|
|
||||||
static st::EX_Switch hodnikLedStropAmbient(F("hodnik_led_strop_ambient"),
|
|
||||||
PIN_HODNIK_LED_STROP, LOW);
|
|
||||||
static st::EX_Switch hodnikLucZunajVhod(F("hodnik_luc_zunaj_vhod"),
|
|
||||||
PIN_HODNIK_ZUNAJ_VHOD, LOW);
|
|
||||||
|
|
||||||
static st::EX_Switch hodnikVrataVhod(F("hodnik_vrata_vhod"), PIN_HODNIK_VRATA,
|
static st::EX_Switch hodnikVrataVhod(F("switch2"), PIN_HODNIK_VRATA_VHOD);
|
||||||
LOW);
|
static st::EX_Switch hodnikLuc1(F("switch3"), PIN_HODNIK_LUC_1);
|
||||||
|
static st::EX_Switch hodnikLuc2(F("switch4"), PIN_HODNIK_LUC_2);
|
||||||
|
static st::EX_Switch hodnikLuc3(F("switch5"), PIN_HODNIK_LUC_3);
|
||||||
|
static st::EX_Switch hodnikLuc4(F("switch6"), PIN_HODNIK_LUC_4);
|
||||||
|
static st::EX_Switch hodnikOmareLed(F("switch7"), PIN_HODNIK_OMARE_LED);
|
||||||
|
static st::EX_Switch hodnikStropLed(F("switch8"), PIN_HODNIK_STROP_LED);
|
||||||
|
static st::EX_Switch zunajLuc(F("switch9"), PIN_ZUNAJ_LUC);
|
||||||
|
|
||||||
|
static st::EX_Switch jedilnicaLuc1(F("switch10"), PIN_JEDILNICA_LUC_1);
|
||||||
|
static st::EX_Switch jedilnicaLuc2(F("switch11"), PIN_JEDILNICA_LUC_2);
|
||||||
|
static st::EX_Switch jedilnicaLed(F("switch12"), PIN_JEDILNICA_LED);
|
||||||
|
|
||||||
|
static st::EX_Switch dnevnaSobaLucVticnica(F("switch13"),
|
||||||
|
PIN_DNEVNA_SOBA_LUC_VTICNICA);
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// Configure debug print output from each main class
|
|
||||||
//*****************************************************************************
|
|
||||||
st::Everything::debug = true;
|
st::Everything::debug = true;
|
||||||
st::Executor::debug = true;
|
st::Executor::debug = true;
|
||||||
st::Device::debug = true;
|
st::Device::debug = true;
|
||||||
st::PollingSensor::debug = true;
|
st::PollingSensor::debug = true;
|
||||||
st::InterruptSensor::debug = true;
|
st::InterruptSensor::debug = true;
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// Initialize the "Everything" Class
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
// Initialize the optional local callback routine (safe to comment out if not
|
|
||||||
// desired)
|
|
||||||
st::Everything::callOnMsgSend = callback;
|
|
||||||
|
|
||||||
// Create the SmartThings EthernetW5x00 Communications Object
|
|
||||||
// STATIC IP Assignment - Recommended
|
|
||||||
st::Everything::SmartThing = new st::SmartThingsEthernetW5x00(
|
st::Everything::SmartThing = new st::SmartThingsEthernetW5x00(
|
||||||
mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort,
|
mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort,
|
||||||
st::receiveSmartString);
|
st::receiveSmartString);
|
||||||
|
|
||||||
// DHCP IP Assigment - Must set your router's DHCP server to provice a static
|
|
||||||
// IP address for this device's MAC address st::Everything::SmartThing = new
|
|
||||||
// st::SmartThingsEthernetW5x00(mac, serverPort, hubIp, hubPort,
|
|
||||||
// st::receiveSmartString);
|
|
||||||
|
|
||||||
// Run the Everything class' init() routine which establishes Ethernet
|
|
||||||
// communications with the SmartThings Hub
|
|
||||||
st::Everything::init();
|
st::Everything::init();
|
||||||
|
|
||||||
//*****************************************************************************
|
// Sensors
|
||||||
// Add each sensor to the "Everything" Class
|
|
||||||
//*****************************************************************************
|
st::Everything::addSensor(&wcTipka2);
|
||||||
st::Everything::addSensor(&wcLuc1);
|
st::Everything::addSensor(&wcTipka2);
|
||||||
st::Everything::addSensor(&wcLuc2);
|
|
||||||
st::Everything::addSensor(&wcAlarm);
|
st::Everything::addSensor(&wcAlarm);
|
||||||
st::Everything::addSensor(&wcTempHum);
|
st::Everything::addSensor(&wcTempVlaga);
|
||||||
st::Everything::addSensor(&hodnikZvonecTipkalo);
|
|
||||||
|
st::Everything::addSensor(&hodnikZvonecTipka);
|
||||||
|
st::Everything::addSensor(&hodnikStopnisceSenzor);
|
||||||
|
st::Everything::addSensor(&hodnikVrataSenzor);
|
||||||
|
|
||||||
st::Everything::addSensor(&jedilnicaTipka1);
|
st::Everything::addSensor(&jedilnicaTipka1);
|
||||||
st::Everything::addSensor(&jedilnicaTipka2);
|
st::Everything::addSensor(&jedilnicaTipka2);
|
||||||
st::Everything::addSensor(&jedilnicaTipka3);
|
st::Everything::addSensor(&jedilnicaTipka3);
|
||||||
st::Everything::addSensor(&jedilnicaTipka4);
|
st::Everything::addSensor(&jedilnicaTipka4);
|
||||||
st::Everything::addSensor(&jedilnicaTipka5);
|
st::Everything::addSensor(&jedilnicaTipka5);
|
||||||
st::Everything::addSensor(&otroskaTipka1);
|
|
||||||
st::Everything::addSensor(&otroskaTipka2);
|
|
||||||
|
|
||||||
//*****************************************************************************
|
st::Everything::addSensor(&podstrehaTempVlaga);
|
||||||
// Add each executor to the "Everything" Class
|
st::Everything::addSensor(&dnevnaSobaTempVlaga);
|
||||||
//*****************************************************************************
|
|
||||||
|
st::Everything::addSensor(&otroskaSobaTipka1);
|
||||||
|
st::Everything::addSensor(&otroskaSobaTipka2);
|
||||||
|
|
||||||
|
// Executors
|
||||||
|
|
||||||
|
st::Everything::addExecutor(&wcLuc1);
|
||||||
|
|
||||||
|
st::Everything::addExecutor(&hodnikVrataVhod);
|
||||||
st::Everything::addExecutor(&hodnikLuc1);
|
st::Everything::addExecutor(&hodnikLuc1);
|
||||||
st::Everything::addExecutor(&hodnikLuc2);
|
st::Everything::addExecutor(&hodnikLuc2);
|
||||||
st::Everything::addExecutor(&hodnikLuc3);
|
st::Everything::addExecutor(&hodnikLuc3);
|
||||||
st::Everything::addExecutor(&hodnikLuc4);
|
st::Everything::addExecutor(&hodnikLuc4);
|
||||||
st::Everything::addExecutor(&hodnikLedStropAmbient);
|
st::Everything::addExecutor(&hodnikOmareLed);
|
||||||
st::Everything::addExecutor(&hodnikLucZunajVhod);
|
st::Everything::addExecutor(&hodnikStropLed);
|
||||||
st::Everything::addExecutor(&hodnikVrataVhod);
|
st::Everything::addExecutor(&zunajLuc);
|
||||||
|
|
||||||
|
st::Everything::addExecutor(&jedilnicaLuc1);
|
||||||
|
st::Everything::addExecutor(&jedilnicaLuc2);
|
||||||
|
st::Everything::addExecutor(&jedilnicaLed);
|
||||||
|
|
||||||
|
st::Everything::addExecutor(&dnevnaSobaLucVticnica);
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// Initialize each of the devices which were added to the Everything Class
|
|
||||||
//*****************************************************************************
|
|
||||||
st::Everything::initDevices();
|
st::Everything::initDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************************
|
void loop() { st::Everything::run(); }
|
||||||
// Arduino Loop() routine
|
|
||||||
//******************************************************************************************
|
|
||||||
void loop() {
|
|
||||||
//*****************************************************************************
|
|
||||||
// Execute the Everything run method which takes care of "Everything"
|
|
||||||
//*****************************************************************************
|
|
||||||
st::Everything::run();
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user