5 Commits
demo ... test

Author SHA1 Message Date
Gašper Dobrovoljc
b43a0a04e0 Fix 2023-06-12 17:32:58 +02:00
Gašper Dobrovoljc
68af92e209 spremeni v button 2023-05-31 19:28:44 +02:00
Gašper Dobrovoljc
f750f938d4 IP 2023-05-31 18:52:43 +02:00
Gašper Dobrovoljc
5056a3e1c3 izhod 31 2023-05-31 18:46:47 +02:00
Gašper Dobrovoljc
1d4f648b28 Dodal testne 2023-05-31 18:46:03 +02:00
2 changed files with 45 additions and 224 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"C_Cpp.default.compilerPath": "/opt/homebrew/opt/llvm/bin/clang"
}

View File

@@ -1,70 +1,4 @@
//****************************************************************************************** //******************************************************************************************
// 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 // SmartThings Library for Arduino Ethernet W5x00 Shield
//****************************************************************************************** //******************************************************************************************
#include <SmartThingsEthernetW5x00.h> //Library to provide API to the SmartThings Ethernet W5x00 Shield #include <SmartThingsEthernetW5x00.h> //Library to provide API to the SmartThings Ethernet W5x00 Shield
@@ -120,86 +54,40 @@
#define PIN_52_RESERVED 52 // reserved by W5x00 Shield on MEGA #define PIN_52_RESERVED 52 // reserved by W5x00 Shield on MEGA
#define PIN_53_RESERVED 53 // reserved by W5x00 Shield on MEGA #define PIN_53_RESERVED 53 // reserved by W5x00 Shield on MEGA
// Analog Pins
#define PIN_WATER_1 A0 // SmartThings Capability "Water Sensor"
#define PIN_WATER_2 A1 // SmartThings Capability "Water Sensor"
#define PIN_ILLUMINANCE_1 A2 // SmartThings Capability "Illuminance Measurement"
#define PIN_ILLUMINANCE_2 A3 // SmartThings Capability "Illuminance Measurement"
#define PIN_VOLTAGE_1 A4 // SmartThings Capability "Voltage Measurement"
#define PIN_VOLTAGE_2 A5 // SmartThings Capability "Voltage Measurement"
#define PIN_SMOKE_3 A8 // SmartThings Capability "Smoke Detector"
#define PIN_SMOKE_4 A9 // SmartThings Capability "Smoke Detector"
// Digital Pins
#define PIN_TEMPERATUREHUMIDITY_1 \
22 // SmartThings Capabilities "Temperature Measurement" and "Relative
// Humidity Measurement"
#define PIN_TEMPERATUREHUMIDITY_2 \
23 // SmartThings Capabilities "Temperature Measurement" and "Relative
// Humidity Measurement"
#define PIN_MOTION_1 24 // SmartThings Capability "Motion Sensor"
#define PIN_MOTION_2 25 // SmartThings Capability "Motion Sensor"
#define PIN_CONTACT_1 26 // SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_2 27 // SmartThings Capability "Contact Sensor"
#define PIN_SWITCH_1 28 // SmartThings Capability "Switch"
#define PIN_SWITCH_2 29 // SmartThings Capability "Switch"
#define PIN_TIMEDRELAY_1 30 // SmartThings Capability "Relay Switch"
#define PIN_TIMEDRELAY_2 31 // SmartThings Capability "Relay Switch"
#define PIN_SMOKE_1 32 // SmartThings Capability "Smoke Detector"
#define PIN_SMOKE_2 33 // SmartThings Capability "Smoke Detector"
#define PIN_ALARM_1 34 // SmartThings Capability "Alarm"
#define PIN_ALARM_2 40 // SmartThings Capability "Alarm"
#define PIN_STROBE_2 41 // SmartThings Capability "Alarm"
#define PIN_CO_1 42 // SmartThings Capability "Carbon Monoxide Detector"
#define PIN_CO_2 43 // SmartThings Capability "Carbon Monoxide Detector"
// Dimmer Switch Pins
#define PIN_DIMMERLEVEL_1 \
44 // SmartThings Capability "Switch Level" NOTE: MUST BE A PWM CAPABLE PIN!
#define PIN_DIMMERSWITCH_1 45 // SmartThings Capability "Switch"
#define PIN_DIMMERLEVEL_2 \
46 // SmartThings Capability "Switch Level" NOTE: MUST BE A PWM CAPABLE PIN!
#define PIN_DIMMERSWITCH_2 47 // SmartThings Capability "Switch"
// Garage Door Pins
#define PIN_DOORCONTROL_CONTACT_1 35 // SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_RELAY_1 36 // SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_CONTACT_2 37 // SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_RELAY_2 38 // SmartThings Capabilty "Door Control"
// Pushbutton Pins
#define PIN_BUTTON1 48 // SmartThings Capabilty Button / Holdable Button
#define PIN_BUTTON2 49 // SmartThings Capabilty Button / Holdable Button
//****************************************************************************************** //******************************************************************************************
// W5x00 Ethernet Shield Information // W5x00 Ethernet Shield Information
//****************************************************************************************** //******************************************************************************************
// NOTE - If your shield came with a MAC address sticker - please use that MAC // MAC address, leave first octet 0x06, change others to be unique
// address! byte mac[] = {0x06, 0x02, 0x03, 0x04, 0x05, 0x06};
byte mac[] = {0x06, 0x02, 0x03, 0x04,
0x05, 0x06}; // MAC address, leave first octet 0x06, change others
// to be unique // <---You must edit this line!
IPAddress ip(192, 168, 88, 206); // Arduino device IP Address // <---You must // Arduino device IP Address
// edit this line! IPAddress ip(10, 10, 0, 140);
IPAddress gateway(192, 168, 88, 1); // router gateway // <---You must edit this
// line! // Router gateway
IPAddress subnet(255, 255, 255, 0); // LAN subnet mask // <---You must edit IPAddress gateway(10, 10, 0, 1);
// this line!
IPAddress dnsserver(192, 168, 88, // LAN subnet mask
1); // DNS server // <---You must edit this line! IPAddress subnet(255, 255, 255, 0);
const unsigned int serverPort = 8090; // port to run the http server on
// DNS server
IPAddress dnsserver(10, 10, 0, 1);
// port to run the http server on
const unsigned int serverPort = 8090;
// Smartthings Hub Information // Smartthings Hub Information
IPAddress hubIp(192, 168, 88, 251); // IPAddress hubIp(192, 168, 1, 149); // smartthings hub ip // <---You
// smartthings hub ip // <---You must edit this line! // must edit this line! const unsigned int hubPort = 39500; // smartthings hub
const unsigned int hubPort = 39501; // smartthings hub port // port
// Hubitat Hub Information // Hubitat Hub Information
// IPAddress hubIp(192, 168, 1, 145); // hubitat hub ip // <---You
// must edit this line! const unsigned int hubPort = 39501; // hubitat hub // hubitat hub ip
// port IPAddress hubIp(192, 168, 88, 251);
// hubitat hub port
const unsigned int hubPort = 39501;
//****************************************************************************************** //******************************************************************************************
// st::Everything::callOnMsgSend() optional callback routine. This is a sniffer // st::Everything::callOnMsgSend() optional callback routine. This is a sniffer
@@ -251,64 +139,16 @@ void setup() {
// specific use case in the ST Phone Application. // specific use case in the ST Phone Application.
//****************************************************************************************** //******************************************************************************************
// Polling Sensors // Polling Sensors
static st::PS_Water sensor1(F("water1"), 60, 0, PIN_WATER_1, 200); static st::IS_Button button1(F("button1"), 24);
static st::PS_Water sensor2(F("water2"), 60, 10, PIN_WATER_2, 200); static st::IS_Button button2(F("button2"), 25);
static st::PS_Illuminance sensor3(F("illuminance1"), 60, 20, static st::IS_Button button3(F("button3"), 26);
PIN_ILLUMINANCE_1, 0, 1023, 0, 1000); static st::IS_Button button4(F("button4"), 27);
static st::PS_Illuminance sensor4(F("illuminance2"), 60, 30,
PIN_ILLUMINANCE_2, 0, 1023, 0, 1000);
static st::PS_TemperatureHumidity sensor5(
F("temphumid1"), 60, 40, PIN_TEMPERATUREHUMIDITY_1,
st::PS_TemperatureHumidity::DHT22, "temperature1", "humidity1");
static st::PS_TemperatureHumidity sensor6(
F("temphumid2"), 60, 50, PIN_TEMPERATUREHUMIDITY_2,
st::PS_TemperatureHumidity::DHT22, "temperature2", "humidity2");
static st::PS_Voltage sensor7(F("voltage1"), 60, 55, PIN_VOLTAGE_1, 0, 1023,
0, 5000);
static st::PS_Voltage sensor8(F("voltage2"), 60, 57, PIN_VOLTAGE_2, 0, 1023,
0, 5000);
static st::PS_MQ2_Smoke sensor23(F("smoke3"), 10, 3, PIN_SMOKE_3, 300);
static st::PS_MQ2_Smoke sensor24(F("smoke4"), 10, 5, PIN_SMOKE_4, 300);
// Interrupt Sensors
static st::IS_Motion sensor9(F("motion1"), PIN_MOTION_1, HIGH, false, 500);
static st::IS_Motion sensor10(F("motion2"), PIN_MOTION_2, HIGH, false, 500);
static st::IS_Contact sensor11(F("contact1"), PIN_CONTACT_1, LOW, true, 500);
static st::IS_Contact sensor12(F("contact2"), PIN_CONTACT_2, LOW, true, 500);
static st::IS_Smoke sensor13(F("smoke1"), PIN_SMOKE_1, HIGH, true, 500);
static st::IS_Smoke sensor14(F("smoke2"), PIN_SMOKE_2, HIGH, true, 500);
static st::IS_DoorControl sensor15(F("doorControl1"),
PIN_DOORCONTROL_CONTACT_1, LOW, true,
PIN_DOORCONTROL_RELAY_1, LOW, true, 1000);
static st::IS_DoorControl sensor16(F("doorControl2"),
PIN_DOORCONTROL_CONTACT_2, LOW, true,
PIN_DOORCONTROL_RELAY_2, LOW, true, 1000);
static st::IS_Button sensor17(F("button1"), PIN_BUTTON1, 1000, LOW, true,
500);
static st::IS_Button sensor18(F("button2"), PIN_BUTTON2, 1000, LOW, true,
500);
static st::IS_CarbonMonoxide sensor19(F("carbonMonoxide1"), PIN_CO_1, HIGH,
true, 500);
static st::IS_CarbonMonoxide sensor20(F("carbonMonoxide2"), PIN_CO_2, HIGH,
true, 500);
// Special sensors/executors (uses portions of both polling and executor
// classes)
static st::S_TimedRelay sensor21(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW,
true, 3000, 0, 1);
static st::S_TimedRelay sensor22(F("relaySwitch2"), PIN_TIMEDRELAY_2, LOW,
true, 3000, 0, 1);
// Executors // Executors
static st::EX_Switch executor1(F("switch1"), PIN_SWITCH_1, LOW, true); static st::EX_Switch switch1(F("switch1"), 28);
static st::EX_Switch executor2(F("switch2"), PIN_SWITCH_2, LOW, true); static st::EX_Switch switch2(F("switch2"), 29);
static st::EX_Alarm executor3(F("alarm1"), PIN_ALARM_1, LOW, true); static st::EX_Switch switch3(F("switch3"), 30);
static st::EX_Alarm executor4(F("alarm2"), PIN_ALARM_2, LOW, true, static st::EX_Switch switch4(F("switch4"), 31);
PIN_STROBE_2);
static st::EX_Switch_Dim executor5(F("dimmerSwitch1"), PIN_DIMMERSWITCH_1,
PIN_DIMMERLEVEL_1, LOW, false);
static st::EX_Switch_Dim executor6(F("dimmerSwitch2"), PIN_DIMMERSWITCH_2,
PIN_DIMMERLEVEL_2, LOW, false);
//***************************************************************************** //*****************************************************************************
// Configure debug print output from each main class // Configure debug print output from each main class
@@ -345,40 +185,18 @@ void setup() {
//***************************************************************************** //*****************************************************************************
// Add each sensor to the "Everything" Class // Add each sensor to the "Everything" Class
//***************************************************************************** //*****************************************************************************
st::Everything::addSensor(&sensor1); st::Everything::addSensor(&button1);
st::Everything::addSensor(&sensor2); st::Everything::addSensor(&button2);
st::Everything::addSensor(&sensor3); st::Everything::addSensor(&button3);
st::Everything::addSensor(&sensor4); st::Everything::addSensor(&button4);
st::Everything::addSensor(&sensor5);
st::Everything::addSensor(&sensor6);
st::Everything::addSensor(&sensor7);
st::Everything::addSensor(&sensor8);
st::Everything::addSensor(&sensor9);
st::Everything::addSensor(&sensor10);
st::Everything::addSensor(&sensor11);
st::Everything::addSensor(&sensor12);
st::Everything::addSensor(&sensor13);
st::Everything::addSensor(&sensor14);
st::Everything::addSensor(&sensor15);
st::Everything::addSensor(&sensor16);
st::Everything::addSensor(&sensor17);
st::Everything::addSensor(&sensor18);
st::Everything::addSensor(&sensor19);
st::Everything::addSensor(&sensor20);
st::Everything::addSensor(&sensor21);
st::Everything::addSensor(&sensor22);
st::Everything::addSensor(&sensor23);
st::Everything::addSensor(&sensor24);
//***************************************************************************** //*****************************************************************************
// Add each executor to the "Everything" Class // Add each executor to the "Everything" Class
//***************************************************************************** //*****************************************************************************
st::Everything::addExecutor(&executor1); st::Everything::addExecutor(&switch1);
st::Everything::addExecutor(&executor2); st::Everything::addExecutor(&switch2);
st::Everything::addExecutor(&executor3); st::Everything::addExecutor(&switch3);
st::Everything::addExecutor(&executor4); st::Everything::addExecutor(&switch4);
st::Everything::addExecutor(&executor5);
st::Everything::addExecutor(&executor6);
//***************************************************************************** //*****************************************************************************
// Initialize each of the devices which were added to the Everything Class // Initialize each of the devices which were added to the Everything Class
@@ -394,4 +212,4 @@ void loop() {
// Execute the Everything run method which takes care of "Everything" // Execute the Everything run method which takes care of "Everything"
//***************************************************************************** //*****************************************************************************
st::Everything::run(); st::Everything::run();
} }