[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

I could use some help with this sketch- https://github.com/DanielOgorchock/ST_Anything/blob/9b66c701cb486158a4dd530889863b38195110e4/Arduino/Sketches/ST_Anything_Multiples_ESP8266WiFi/ST_Anything_Multiples_ESP8266WiFi.ino

I am using an ESP8266 (NodeMCU is what I think they call the chip and board) with an DHT22 sensor. I have tried the following lines (1 by 1) with no luck. I have also tried to use the Analog Port.

Blockquote
//Polling Sensors
static st::PS_Water sensor1(F(“water1”), 60, 20, PIN_WATER_1, 200);
// static st::PS_DS18B20_Temperature sensor2(F(“temphumid”), 15, 0, PIN_TEMPERATURE_1, false, 10, 1);
//static st::PS_DS18B20_Temperature sensor2(F(“temperature1”), 15, 0, PIN_TEMPERATURE_1, false, 10, 1);
// st::PS_TemperatureHumidity sensor5(“temphumid”, 120, 10, PIN_TEMPERATUREHUMIDITY5, st::PS_TemperatureHumidity::DHT22, “pin5t”, “pin5h”);
//static st::PS_TemperatureHumidity sensor2(F(“temperature1”), 120, 10, PIN_TEMPERATURE_1, st::PS_TemperatureHumidity::DHT22);
//static st::PS_TemperatureHumidity sensor2(F(“temphumid”), 60, 40, PIN_TEMPERATURE_1, st::PS_TemperatureHumidity::DHT22,“temperature1”,“humidity1”);
static st::PS_TemperatureHumidity sensor2(F(“temphumid”), 120, 10, PIN_TEMPERATURE_1, st::PS_TemperatureHumidity::DHT22);

If anyone is using this for RGB led strip control I have a beta DTH I’d like to get tested. It enables Alexa / Google control of the RGB lights so you can say “Alexa set the Cabinet Lights to Red” and it will do so.

Once this is tested and working I’ll do the RGBW and then after the holidays I plan on tackling programmable / NeoPixel LED strips.

2 Likes

@freinkelhouse

First thing is to make sure your DHT22 sensor is wired properly to your micro-controller. Please use one of the example sketches included in the DHT Temperature Library that I have included in my GitHub repository. Not all DHT libraries work properly with the ESP8266 boards. Therefore, I have included a copy that is known to work. Once you have a DHT22 example sketch working, you’ll know your wiring and the sensor are working properly. Afterwards, you can proceed to using an ST_Anything example sketch, making sure to define the correct pin number based on your wiring.

Since you’re using a DHT based sensor, you should use the following device declaration:

static st::PS_TemperatureHumidity sensor2(F("temphumid1"), 60, 0, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22, "temperature1", "humidity1");

The documentation for each device class can be found at the top of the corresponding C++ class .h or .cpp file. I have included the relevant information below. Please note that the String strTemp and String strHumid arguments are really REQUIRED these days due to how the Child Devices are created automatically in the ST Cloud. These must follow the naming convention outlined in the ReadMe found in the GitHub repository.

//******************************************************************************************
//  File: PS_TemperatureHumidity.h
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  PS_TemperatureHumidity is a class which implements both the SmartThings "Temperature Measurement" 
//			  and "Relative Humidity Measurement" device capabilities.
//			  It inherits from the st::PollingSensor class.  The current version uses a digital input to measure the 
//			  temperature and humidity from a DHT series sensor.  This was tested with both the DHT11 and DHT22.  
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::PS_TemperatureHumidity sensor2("temphumid1", 120, 7, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22, "temperature1", "humidity1", false);
//
//			  st::PS_TemperatureHumidity() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- long interval - REQUIRED - the polling interval in seconds
//				- long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
//				- byte pin - REQUIRED - the Arduino Pin to be used as a digital output
//				- DHT_SENSOR DHTSensorType - REQUIRED - the type of DHT sensor (DHT11, DHT21, DHT22, DHT33, or DHT44)
//				- String strTemp - OPTIONAL - name of temperature sensor to send to ST Cloud (defaults to "temperature")
//				- String strHumid - OPTIONAL - name of humidity sensor to send to ST Cloud (defaults to "humidity")
//				- bool In_C - OPTIONAL - true = Report Celsius, false = Report Farenheit (Farentheit is the default)
//				- byte filterConstant - OPTIONAL - Value from 5% to 100% to determine how much filtering/averaging is performed 100 = none (default), 5 = maximum
//
//            Filtering/Averaging
//
//            Filtering the value sent to ST is performed per the following equation
//
//            filteredValue = (filterConstant/100 * currentValue) + ((1 - filterConstant/100) * filteredValue) 
//
//			  This class supports receiving configuration data from the SmartThings cloud via the ST App.  A user preference
//			  can be configured in your phone's ST App, and then the "Configure" tile will send the data for all sensors to 
//			  the ST Shield.  For PollingSensors, this data is handled in the beSMart() function.
//

The best way to know when something has changed is to monitor the traffic being sent from ST_Anything to the ST Hub. You can do this very easily from within your sketch by implementing your own logic inside the “callback()” function included in every example sketch. All of the lines are commented out by default to prevent clogging up the Arduino IDE Serial Monitor window. In the version below, I have uncommented the first two lines so you can “see” what data is being sent to ST. Using this information, you could easily keep a variable up to date with the device’s current value. This prevents the need to poll pins continuously.

//******************************************************************************************
//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.
//******************************************************************************************
void callback(const String &msg)
{
Serial.print(F("ST_Anything 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)
//st::receiveSmartString(“Put your command here!”); //use same strings that the Device Handler would send
}

@polargeek Have you had any success yet? Looking at your sketch, it appears like it should work when compared against the example sketch for the board you’re using. I would think that you should be able to control the relay. If the logic is inverted, that can be fixed via configuration changes… But it should at least do something.

Dan,
I honestly hadn’t tried again was waiting to here if I’d done something obviously wrong to not have the child device created.

I can definitely set the relay to on or off at startup by changing that logic in the sketch.

I’ll try to get some time tonight and put that sketch back on it.

OK, at least we know the sketch is able to set the startup state of the relay.

Does the Child Switch Device get created automatically and show up in your phone’s SmartThings App as a new Thing? You should also be able to see it if you click on the Parent Device you manually added via the ST IDE. After configuring the settings of the Parent Device in you phone ST app, a “refresh” command is sent to the ST_Anything micro-controller and you should see some debug statements to that effect in the Arduino IDE Serial Monitor Window.

Once you have a “switch1” Child Device, clicking it in ST App on your phone should send a command that is visible in the Arduino IDE Serial Monitor Window. You should see “switch1 on” or “switch1 off”.

Hi Dan, @ogiewon, sorry to bother you. I am trying to integrate my existing alarm system (GE Security, aka Simon XT) , it has all wireless sensors and I see no point to get a new one in place, so I have decided to integrate into the ST. I am using your ST_Anything_AlarmPanel_ESP8266WIFI sketch.
Here is what I am trying to achieve: Arm and disarm the system via the ST and get the status back into it.
I am using the wireless remote to arm&disarm the system (hidden in my house - burglars will have 45 sec to find it, before it sets the alarm off.) To control the remote I want to wire it up to relays - 1st to arm and second to disarm, to get the system feedback (activated/armed or not) I want to use its 12v outputs (high/low with relays) and monitor them with IS_Contact.
Here is the question: How can I set the relay click twice, which is required to arm perimeter and motion sensor?
Will this work:
//Executors
static st::EX_Alarm executor1(F(“alarm1”), PIN_ALARM_1, LOW, true, 1000, 1000, 2);
static st::EX_Alarm executor1(F(“alarm2”), PIN_ALARM_2, LOW, true, 1000 );

Thanks in advance!

Just put in an order for some Wemos Mini D1s and a few meters of WS2812s for a project I’m looking to implement. Bought them from AliExpress so it’s gonna take a while but I’d be willing to test it out once everything gets here. Keep me updated on your progress. Thanks for your work!

1 Like

@AlecBL

Alec,

I don’t think you want to use EX_Alarm devices to accomplish your ARM / DISARM functionality. The ALARM device is designed to be attached to a siren and controlled via a SmartThings SmartApp, like Smart Home Monitor. It does not support the extra arguments you’ve added to it.

Instead, I would recommend you use two st::S_TimedRelay devices.

  //Special sensors/executors (uses portions of both polling and executor classes)
  static st::S_TimedRelay           sensor1(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW, true, 1000, 100, 2);
  static st::S_TimedRelay           sensor2(F("relaySwitch2"), PIN_TIMEDRELAY_2, LOW, true, 1000, 0, 1);

The first one will turn on for 1 second, then off for 0.1 second, then repeat for a total of 2 times.
The second one will turn on for 1 second, then off.

Each of these will both appear in SmartThings as a switch. If you click the switch on, it will start the cycle, and then automatically turn off in ST after the cycle is complete. If you had a long running cycle (e.g. ten 1 second button presses) you could interrupt the cycle by clicking it off in the ST phone app.

Make sure you add these as sensors, not executors, in your setup() routine. This is a special class since it contains self-timing logic.

  //*****************************************************************************
  //Add each sensor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addSensor(&sensor1);
  st::Everything::addSensor(&sensor2);

Here is the documentation for this class so you can set the parameters correctly when you create them in the sketch’s setup() routine.

//  Summary:  S_TimedRelay is a class which implements the SmartThings "Relay" device capability.  It features
//			  an automatic-turn-off time delay for a relay to emulate a button press.
//
//			  It inherits from the st::Sensor class and clones much from the st::Executor Class
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::S_TimedRelay sensor1("relaySwitch1", PIN_RELAY, LOW, true, 1000, 0, 1);
//
//			  st::S_TimedRelay() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- byte pinOutput - REQUIRED - the Arduino Pin to be used as a digital output
//				- bool startingState - REQUIRED - the value desired for the initial state of the switch.  LOW = "off", HIGH = "on"
//				- bool invertLogic - REQUIRED - determines whether the Arduino Digital Ouput should use inverted logic
//				- long onTime - REQUIRED - the number of milliseconds to keep the output on, DEFGAULTS to 1000 milliseconds
//				- long offTime - OPTIONAL - the number of milliseconds to keep the output off, DEFAULTS to 0
//				- intnumCycles - OPTIONAL - the number of times to repeat the on/off cycle, DEFAULTS to 1

Dan, @ogiewon THANKS for a quick reply! Really appreciated.
Here is what my (actually yours :slight_smile:) code looks like in final version:
I hope it works ( will test it tomorrow)
thanks again!

//*************************************************************************************************
//NodeMCU v1.0 ESP8266-12e Pin Definitions (makes it much easier as these match the board markings)
//*************************************************************************************************
#define LED_BUILTIN 16
#define BUILTIN_LED 16

#define D0 16 //no internal pullup resistor
#define D1 5
#define D2 4
//#define D3 0 //must not be pulled low during power on/reset, toggles value during boot
//#define D4 2 //must not be pulled low during power on/reset, toggles value during boot
#define D5 14
#define D6 12

/******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************

#define PIN_CONTACT_1 D1 //SmartThings Capabilty “Contact Sensor1”
#define PIN_CONTACT_2 D2 //SmartThings Capabilty “Contact Sensor2”
#define PIN_TIMEDRELAY_1 D5 //SmartThings Capability “Relay Switch1”
#define PIN_TIMEDRELAY_2 D6 //SmartThings Capability “Relay Switch2”

//Polling Sensors
//Interrupt Sensors
static st::IS_Contact sensor1(F(“contact1”), PIN_CONTACT_1, LOW, true);
static st::IS_Contact sensor2(F(“contact2”), PIN_CONTACT_2, LOW, true);

//Special sensors/executors (uses portions of both polling and executor classes)
static st::S_TimedRelay sensor3(F(“relaySwitch1”), PIN_TIMEDRELAY_1, LOW, true, 1000, 500, 2);
static st::S_TimedRelay sensor4(F(“relaySwitch2”), PIN_TIMEDRELAY_2, LOW, true, 1000, 0, 1);
//Executors

//*****************************************************************************

//*****************************************************************************
//Add each sensor to the “Everything” Class
//*****************************************************************************
st::Everything::addSensor(&sensor1);
st::Everything::addSensor(&sensor2);
st::Everything::addSensor(&sensor3);
st::Everything::addSensor(&sensor4);
//*****************************************************************************
//Add each executor to the “Everything” Class
//*****************************************************************************
//st::Everything::addExecutor(&executor1); //commented
//st::Everything::addExecutor(&executor2); //commented

1 Like

Looks good! Please let us know how your testing goes.

Dan,
I’m working on 4 zone speaker selector with W5500 and MEGA Arduino to drive 8 channel Relay. I was able to modify your code to get 8 switches. Question that I have is it possible to couple 2 channels together via code vs manually in the application with if switch 1 is one turn on Switch 5. I want to make Channel 1 to 4 RHS speakers and Channel 5 to 8 RHS speakers.
Zone1 will be Channel 1 and Channel 5
Zone2 will be Channel 2 and Channel 6
Zone3 will be Channel 3 and Channel 7
Zone4 will be Channel 4 and Channel 8

Here is the code. Thank you for any help

//******************************************************************************************
// File: ST_Anything_Multiples_EthernetW5500.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 W5500 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 W5500 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 baord)
// - 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)
//
// 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 Ethernet2 W5500 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-04-22 Dan Ogorchock Initial version for W5500 Ethernet2 Shield
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for Arduino Ethernet W5500 Shield
//******************************************************************************************
#include <SmartThingsEthernetW5500.h> //Library to provide API to the SmartThings Ethernet W5500 Shield

//******************************************************************************************
// 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 <Sensor.h> //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc…)
#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 <Everything.h> //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications

#include <PS_Illuminance.h> //Implements a Polling Sensor (PS) to measure light levels via a photo resistor on an analog input pin
#include <PS_Voltage.h> //Implements a Polling Sensor (PS) to measure voltage on an analog input pin
#include <PS_TemperatureHumidity.h> //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
#include <PS_Water.h> //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector) on an analog input pin
#include <IS_Motion.h> //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor on a digital input pin
#include <IS_Contact.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_Smoke.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_CarbonMonoxide.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#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 <IS_Button.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin for button presses
#include <EX_Switch.h> //Implements an Executor (EX) via a digital output to a relay
#include <EX_Alarm.h> //Implements Executor (EX)as an Alarm capability with Siren and Strobe via digital outputs to relays
#include <S_TimedRelay.h> //Implements a Sensor to control a digital output pin with timing/cycle repeat capabilities

//**********************************************************************************************************
//Define which Arduino Pins will be used for each device
// Notes: Arduino communicates with both the W5500 and SD card using the SPI bus (through the ICSP header).
// This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega.
// On both boards, pin 10 is used to select the W5500 and pin 4 for the SD card.
// These pins cannot be used for general I/O. On the Mega, the hardware SS pin, 53,
// is not used to select either the W5500 or the SD card, but it must be kept as an output
// or the SPI interface won’t work.
// See https://www.arduino.cc/en/Main/ArduinoEthernetShield for details on the W5500 Sield
//**********************************************************************************************************
//“RESERVED” pins for W5500 Ethernet Shield - best to avoid
#define PIN_4_RESERVED 4 //reserved by W5500 Shield on both UNO and MEGA
#define PIN_1O_RESERVED 10 //reserved by W5500 Shield on both UNO and MEGA
#define PIN_11_RESERVED 11 //reserved by W5500 Shield on UNO
#define PIN_12_RESERVED 12 //reserved by W5500 Shield on UNO
#define PIN_13_RESERVED 13 //reserved by W5500 Shield on UNO
#define PIN_50_RESERVED 50 //reserved by W5500 Shield on MEGA
#define PIN_51_RESERVED 51 //reserved by W5500 Shield on MEGA
#define PIN_52_RESERVED 52 //reserved by W5500 Shield on MEGA
#define PIN_53_RESERVED 53 //reserved by W5500 Shield on MEGA

//Digital Pins
#define PIN_SWITCH_1 22 //SmartThings Capability “Switch”
#define PIN_SWITCH_2 23 //SmartThings Capability “Switch”
#define PIN_SWITCH_3 24 //SmartThings Capability “Switch”
#define PIN_SWITCH_4 25 //SmartThings Capability “Switch”
#define PIN_SWITCH_5 26 //SmartThings Capability “Switch”
#define PIN_SWITCH_6 27 //SmartThings Capability “Switch”
#define PIN_SWITCH_7 28 //SmartThings Capability “Switch”
#define PIN_SWITCH_8 29 //SmartThings Capability “Switch”

//******************************************************************************************
//W5500 Ethernet Shield Information
//******************************************************************************************
byte mac[] = {0x06,0x02,0x03,0x04,0x04,0x06}; //MAC address // <—You must edit this line using the MAC address provided with your W5500 Shield!
IPAddress ip(0000000); //Arduino device IP Address // <—You must edit this line!
IPAddress gateway(000000); //router gateway // <—You must edit this line!
IPAddress subnet(00000000); //LAN subnet mask // <—You must edit this line!
IPAddress dnsserver(000000); //DNS server // <—You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on

// Smartthings hub information
IPAddress hubIp(00000000); // smartthings hub ip // <—You must edit this line!
const unsigned int hubPort = 39500; // smartthings hub port

//******************************************************************************************
//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()
{
//******************************************************************************************
//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.
//******************************************************************************************

//Executors
static st::EX_Switch executor1(F(“switch1”), PIN_SWITCH_1, LOW, true);
static st::EX_Switch executor2(F(“switch2”), PIN_SWITCH_2, LOW, true);
static st::EX_Switch executor3(F(“switch3”), PIN_SWITCH_3, LOW, true);
static st::EX_Switch executor4(F(“switch4”), PIN_SWITCH_4, LOW, true);
static st::EX_Switch executor5(F(“switch5”), PIN_SWITCH_5, LOW, true);
static st::EX_Switch executor6(F(“switch6”), PIN_SWITCH_6, LOW, true);
static st::EX_Switch executor7(F(“switch7”), PIN_SWITCH_7, LOW, true);
static st::EX_Switch executor8(F(“switch8”), PIN_SWITCH_8, LOW, true);

//*****************************************************************************
// Configure debug print output from each main class
//*****************************************************************************
st::Everything::debug=true;
st::Executor::debug=true;
st::Device::debug=true;
st::PollingSensor::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 EthernetW5500 Communications Object
//STATIC IP Assignment - Recommended
st::Everything::SmartThing = new st::SmartThingsEthernetW5500(mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, 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::SmartThingsEthernetW5500(mac, serverPort, hubIp, hubPort, st::receiveSmartString);

//Run the Everything class’ init() routine which establishes Ethernet communications with the SmartThings Hub
st::Everything::init();

//*****************************************************************************
//Add each executor to the “Everything” Class
//*****************************************************************************
st::Everything::addExecutor(&executor1);
st::Everything::addExecutor(&executor2);
st::Everything::addExecutor(&executor3);
st::Everything::addExecutor(&executor4);
st::Everything::addExecutor(&executor5);
st::Everything::addExecutor(&executor6);
st::Everything::addExecutor(&executor7);
st::Everything::addExecutor(&executor8);

//*****************************************************************************
//Initialize each of the devices which were added to the Everything Class
//*****************************************************************************
st::Everything::initDevices();
}

//******************************************************************************************
//Arduino Loop() routine
//******************************************************************************************
void loop()
{
//*****************************************************************************
//Execute the Everything run method which takes care of “Everything”
//*****************************************************************************
st::Everything::run();
}

Also I’m trying to use SainSmart 8-Channel 5V Solid State Relay Module Board. which currently doesn’t respond well. I can get the LED to turn on but relay is not triggering. I can’t seem to figure out. I found online people are having more success with SainSmart 8-Channel Relay Module. Any suggestion on why solid state doesn’t trigger? Thank you

My understand solid state need a/c going to the before they will work correctly they also need a .1 amp of current draw. This may help.
http://forum.arduino.cc/index.php?topic=176556.0

I’m not sure about the Solid State Relay needing a/c, but be sure to provide a clean/good 5V to the Relay. Many times people tap off the Arduino/ESP and either end up only providing 3.3V (ESP) or not enough current draw as some of the power connectors on those devices are regulated. Without doing the research or math, the safest is to provide 5V direct to the Relay. I usually run power direct to the Relay and then tap off it to the Arduino/ESP as the Relay has extra (non-regulated) pins from what I remember.

It turns out when i increase the volume to 80% relay does trigger. When bellow 80% only LED turns On and Off.

May also that audio is not a true a/c signal and solid state relays only pass a/c within a certain bandwidth.

That’ what I figure Jason. I just ordered SainSmart 8-Channel Relay Module going in on Friday we will see if that one will work. I found online that SainSmart 8-Channel Relay Module will have no problem. I will keep you posted. Thank you

I used the if statements in the code to get the zones LHS and RHS to talk to each other,
Next question I have is it possible to eliminate the delay in getting switched to react to a command? Thank you

// Zone 1
if (msg == “switch1 on”) {st::receiveSmartString(“switch5 on”);}
if (msg == “switch1 off”) {st::receiveSmartString(“switch5 off”);}
// Zone 2
if (msg == “switch2 on”) {st::receiveSmartString(“switch6 on”);}
if (msg == “switch2 off”) {st::receiveSmartString(“switch6 off”);}
// Zone 3
if (msg == “switch3 on”) {st::receiveSmartString(“switch7 on”);}
if (msg == “switch3 off”) {st::receiveSmartString(“switch7 off”);}
// Zone 4
if (msg == “switch4 on”) {st::receiveSmartString(“switch8 on”);}
if (msg == “switch4 off”) {st::receiveSmartString(“switch8 off”);}

1 Like