Compare commits

...

5 Commits
master ... 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 20 additions and 159 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
//******************************************************************************************
#include <SmartThingsEthernetW5x00.h> //Library to provide API to the SmartThings Ethernet W5x00 Shield
@ -120,55 +54,15 @@
#define PIN_52_RESERVED 52 // reserved by W5x00 Shield on MEGA
#define PIN_53_RESERVED 53 // reserved by W5x00 Shield on MEGA
// WC
#define PIN_WC_LUC_1 24
#define PIN_WC_LUC_2 25
#define PIN_WC_ALARM 26
#define PIN_WC_TEMPHUM 27
// Hodnik
#define PIN_HODNIK_VRATA 28
#define PIN_HODNIK_LUC_1 29
#define PIN_HODNIK_LUC_2 30
#define PIN_HODNIK_LUC_3 31
#define PIN_HODNIK_LUC_4 32
#define PIN_HODNIK_ZVONEC 33
#define PIN_HODNIK_LED_OMARA 34
#define PIN_HODNIK_LED_STROP 35
#define PIN_HODNIK_ZUNAJ_VHOD 36
#define PIN_HODNIK_SENZOR_STOPNISCE 37
#define PIN_HODNIK_SENZOR_VRATA 38
// Jedilnica
#define PIN_JEDILNICA_TIPKA_1 40
#define PIN_JEDILNICA_TIPKA_2 41
#define PIN_JEDILNICA_TIPKA_3 42
#define PIN_JEDILNICA_TIPKA_4 43
#define PIN_JEDILNICA_TIPKA_5 44
#define PIN_JEDILNICA_LUC_1 45
#define PIN_JEDILNICA_LUC_2 46
// Dnevna
#define PIN_DNEVNA_LUC_VTICNICA 48
#define PIN_DNEVNA_TEMPHUM_PODSTREHA 49
#define PIN_DNEVNA_TEMPHUM 50
// Otroška soba
#define PIN_OTROSKA_LUC_1 51
#define PIN_OTROSKA_LUC_2 52
//******************************************************************************************
// 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
byte mac[] = {0x06, 0x02, 0x03, 0x04, 0x05, 0x06};
// Arduino device IP Address
IPAddress ip(10, 10, 0, 99);
IPAddress ip(10, 10, 0, 140);
// Router gateway
IPAddress gateway(10, 10, 0, 1);
@ -245,41 +139,16 @@ void setup() {
// specific use case in the ST Phone Application.
//******************************************************************************************
// Polling Sensors
static st::IS_Contact wcLuc1(F("tipka_wc_luc_1"), PIN_WC_LUC_1, LOW);
static st::IS_Contact wcLuc2(F("tipka_wc_luc_2"), PIN_WC_LUC_2, LOW);
static st::IS_Contact wcAlarm(F("tipka_wc_alarm"), PIN_WC_ALARM, LOW);
static st::PS_TemperatureHumidity wcTempHum(
F("wc_temp_hum"), 60, 40, PIN_WC_TEMPHUM,
st::PS_TemperatureHumidity::DHT22, "wc_temp", "wc_hum");
static st::IS_Contact hodnikZvonecTipkalo(F("hodnik_zvonec_tipkalo"),
PIN_HODNIK_ZVONEC, LOW);
static st::IS_Contact jedilnicaTipka1(F("jedilnica_tipka_1"),
PIN_JEDILNICA_TIPKA_1, LOW);
static st::IS_Contact jedilnicaTipka2(F("jedilnica_tipka_2"),
PIN_JEDILNICA_TIPKA_2, LOW);
static st::IS_Contact jedilnicaTipka3(F("jedilnica_tipka_3"),
PIN_JEDILNICA_TIPKA_3, LOW);
static st::IS_Contact jedilnicaTipka4(F("jedilnica_tipka_4"),
PIN_JEDILNICA_TIPKA_4, LOW);
static st::IS_Contact jedilnicaTipka5(F("jedilnica_tipka_5"),
PIN_JEDILNICA_TIPKA_5, LOW);
static st::IS_Contact otroskaTipka1(F("otroska_tipka_1"), PIN_OTROSKA_LUC_1,
LOW);
static st::IS_Contact otroskaTipka2(F("jedilnica_tipka_5"), PIN_OTROSKA_LUC_2,
LOW);
static st::IS_Button button1(F("button1"), 24);
static st::IS_Button button2(F("button2"), 25);
static st::IS_Button button3(F("button3"), 26);
static st::IS_Button button4(F("button4"), 27);
// Executors
static st::EX_Switch hodnikLuc1(F("hodnik_luc_1"), PIN_HODNIK_LUC_1, LOW);
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,
LOW);
static st::EX_Switch switch1(F("switch1"), 28);
static st::EX_Switch switch2(F("switch2"), 29);
static st::EX_Switch switch3(F("switch3"), 30);
static st::EX_Switch switch4(F("switch4"), 31);
//*****************************************************************************
// Configure debug print output from each main class
@ -316,29 +185,18 @@ void setup() {
//*****************************************************************************
// Add each sensor to the "Everything" Class
//*****************************************************************************
st::Everything::addSensor(&wcLuc1);
st::Everything::addSensor(&wcLuc2);
st::Everything::addSensor(&wcAlarm);
st::Everything::addSensor(&wcTempHum);
st::Everything::addSensor(&hodnikZvonecTipkalo);
st::Everything::addSensor(&jedilnicaTipka1);
st::Everything::addSensor(&jedilnicaTipka2);
st::Everything::addSensor(&jedilnicaTipka3);
st::Everything::addSensor(&jedilnicaTipka4);
st::Everything::addSensor(&jedilnicaTipka5);
st::Everything::addSensor(&otroskaTipka1);
st::Everything::addSensor(&otroskaTipka2);
st::Everything::addSensor(&button1);
st::Everything::addSensor(&button2);
st::Everything::addSensor(&button3);
st::Everything::addSensor(&button4);
//*****************************************************************************
// Add each executor to the "Everything" Class
//*****************************************************************************
st::Everything::addExecutor(&hodnikLuc1);
st::Everything::addExecutor(&hodnikLuc2);
st::Everything::addExecutor(&hodnikLuc3);
st::Everything::addExecutor(&hodnikLuc4);
st::Everything::addExecutor(&hodnikLedStropAmbient);
st::Everything::addExecutor(&hodnikLucZunajVhod);
st::Everything::addExecutor(&hodnikVrataVhod);
st::Everything::addExecutor(&switch1);
st::Everything::addExecutor(&switch2);
st::Everything::addExecutor(&switch3);
st::Everything::addExecutor(&switch4);
//*****************************************************************************
// Initialize each of the devices which were added to the Everything Class