This commit is contained in:
Gašper Dobrovoljc 2023-06-12 17:32:58 +02:00
parent 68af92e209
commit b43a0a04e0
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5

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
@ -124,23 +58,20 @@
// W5x00 Ethernet Shield Information // 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(192, 168, 88, 206); IPAddress ip(10, 10, 0, 140);
// Router gateway // Router gateway
IPAddress gateway(192, 168, 88, 1); IPAddress gateway(10, 10, 0, 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(192, 168, 88, 1); IPAddress dnsserver(10, 10, 0, 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;
@ -208,16 +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::IS_Button vhod1(F("vhod_24"), 24, LOW); static st::IS_Button button1(F("button1"), 24);
static st::IS_Button vhod2(F("vhod_25"), 25, LOW); static st::IS_Button button2(F("button2"), 25);
static st::IS_Button vhod3(F("vhod_26"), 26, LOW); static st::IS_Button button3(F("button3"), 26);
static st::IS_Button vhod4(F("vhod_27"), 27, LOW); static st::IS_Button button4(F("button4"), 27);
// Executors // Executors
static st::EX_Switch izhod1(F("izhod_28"), 28, LOW); static st::EX_Switch switch1(F("switch1"), 28);
static st::EX_Switch izhod2(F("izhod_29"), 29, LOW); static st::EX_Switch switch2(F("switch2"), 29);
static st::EX_Switch izhod3(F("izhod_30"), 30, LOW); static st::EX_Switch switch3(F("switch3"), 30);
static st::EX_Switch izhod4(F("izhod_31"), 31, LOW); static st::EX_Switch switch4(F("switch4"), 31);
//***************************************************************************** //*****************************************************************************
// Configure debug print output from each main class // Configure debug print output from each main class
@ -254,18 +185,18 @@ void setup() {
//***************************************************************************** //*****************************************************************************
// Add each sensor to the "Everything" Class // Add each sensor to the "Everything" Class
//***************************************************************************** //*****************************************************************************
st::Everything::addSensor(&vhod1); st::Everything::addSensor(&button1);
st::Everything::addSensor(&vhod2); st::Everything::addSensor(&button2);
st::Everything::addSensor(&vhod3); st::Everything::addSensor(&button3);
st::Everything::addSensor(&vhod4); st::Everything::addSensor(&button4);
//***************************************************************************** //*****************************************************************************
// Add each executor to the "Everything" Class // Add each executor to the "Everything" Class
//***************************************************************************** //*****************************************************************************
st::Everything::addExecutor(&izhod1); st::Everything::addExecutor(&switch1);
st::Everything::addExecutor(&izhod2); st::Everything::addExecutor(&switch2);
st::Everything::addExecutor(&izhod3); st::Everything::addExecutor(&switch3);
st::Everything::addExecutor(&izhod4); st::Everything::addExecutor(&switch4);
//***************************************************************************** //*****************************************************************************
// Initialize each of the devices which were added to the Everything Class // Initialize each of the devices which were added to the Everything Class