[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

I’m pretty novice when it comes to this stuff. From what I saw it looks like some sketch needs to be included that allows update via http.

Not a necessity, just thought I’d ask, because i saw the ESP8266 does. I have one of these controlling a pool which uses 10 relays 5 buttons and 2 thermostats, so as you can imagine there’s a lot of stuff connected to it.

1 Like

All,

I have released ST_Anything v2.9.3. The major change in this release is the significant redesign of the EX_Servo class and Child Servo Device Handler. This new version supports user adjustable speed and min/max endpoint angles. It also implements the Switch Capability in addition to the Switch Level Capability. There are user preferences for the on and off levels (in dimmer level percentages) which will allow easy on/off control to preset Servo positions. Servo motion is now asynchronous and thus allows multiple servos to move simultaneously. This version requires both the Arduino code and Device Handler both be upgraded at the same time due to some changes in the communications protocol. Special thanks to @VooDooFiveTwo for his contributions to enable these new features.

I have also added a fix to the Parent Ethernet Device Handler that will hopefully prevent duplicate child devices from being created.

Dan

2 Likes

I’m stumped…what am i doing wrong, can’t get ds18b20 to report
image

here’s my sketch

//******************************************************************************************
//  File: ST_Anything_Multiples_EthernetW5100.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 W5100 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 W5100 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 W5100 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
//    2018-02-09  Dan Ogorchock  Added support for Hubitat Elevation Hub
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for Arduino Ethernet W5100 Shield
//******************************************************************************************
#include <SmartThingsEthernetW5100.h>    //Library to provide API to the SmartThings Ethernet W5100 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 <PS_MQ2_Smoke.h>    //Implements an Polling Sensor (PS) to monitor the status of an analog input pin from a MQ2 sensor
#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
#include <EX_Switch_Dim.h>   //Implements an Executor (EX) for a switch (on/off) and pwm output (level) uses 2 digital output pins
#include <PS_AdafruitThermocouple.h>
#include <Adafruit_MAX31855.h>
#include <PS_DS18B20_Temperature.h>

//**********************************************************************************************************
//Define which Arduino Pins will be used for each device
//  Notes: Arduino communicates with both the W5100 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 W5100 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 W5100 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/ArduinoEthernetShieldV1 for details on the W5100 Sield
//**********************************************************************************************************
//"RESERVED" pins for W5100 Ethernet Shield - best to avoid
#define PIN_4_RESERVED            4   //reserved by W5100 Shield on both UNO and MEGA
#define PIN_1O_RESERVED           10  //reserved by W5100 Shield on both UNO and MEGA
#define PIN_11_RESERVED           11  //reserved by W5100 Shield on UNO
#define PIN_12_RESERVED           12  //reserved by W5100 Shield on UNO
#define PIN_13_RESERVED           13  //reserved by W5100 Shield on UNO
#define PIN_50_RESERVED           50  //reserved by W5100 Shield on MEGA
#define PIN_51_RESERVED           51  //reserved by W5100 Shield on MEGA
#define PIN_52_RESERVED           52  //reserved by W5100 Shield on MEGA
#define PIN_53_RESERVED           53  //reserved by W5100 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_TEMPERATUREHUMIDITY_3 24  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"
#define PIN_TEMPERATUREHUMIDITY_4 25  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"
#define PIN_TEMPERATUREHUMIDITY_5 26  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"
//#define PIN_TEMPERATUREHUMIDITY_6 27  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"
//#define PIN_TEMPERATUREHUMIDITY_7 28  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"

#define PIN_TEMPERATURE_6         27  //SmartThings Capabilty "Temperature Measurement" (Dallas Semiconductor DS18B20)
#define PIN_TEMPERATURE_7         28  //SmartThings Capabilty "Temperature Measurement" (Dallas Semiconductor DS18B20)


//Thermocouple Pin Assignments
#define PIN_SCLK                  34
#define PIN_CS                    35
#define PIN_MISO                  36


//#define PIN_TEMPERATUREHUMIDITY_8 34  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"

//#define PIN_TEMPERATURE_6 27  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"
#define PIN_SWITCH_1              30  //SmartThings Capability "Switch"
#define PIN_SWITCH_2              31  //SmartThings Capability "Switch"
#define PIN_SWITCH_3              32  //SmartThings Capability "Switch"
#define PIN_SWITCH_4              33  //SmartThings Capability "Switch"

//#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 Capability "Door Control" 
//#define PIN_DOORCONTROL_RELAY_1   36  //SmartThings Capability "Door Control" 
//#define PIN_DOORCONTROL_CONTACT_2 37  //SmartThings Capability "Door Control"  
//#define PIN_DOORCONTROL_RELAY_2   38  //SmartThings Capability "Door Control" 

//Pushbutton Pins
//#define PIN_BUTTON1               48  //SmartThings Capability Button / Holdable Button
//#define PIN_BUTTON2               49  //SmartThings Capability Button / Holdable Button

//******************************************************************************************
//W5100 Ethernet Shield Information
//****************************************************************************************** 
byte mac[] = {0x06,0x02,0x03,0x04,0x05,0x02}; //MAC address, leave first octet 0x06, change others to be unique //  <---You must edit this line!
IPAddress ip(192, 168, 1, 111);               //Arduino device IP Address                   //  <---You must edit this line!
IPAddress gateway(192, 168, 1, 1);            //router gateway                              //  <---You must edit this line!
IPAddress subnet(255, 255, 255, 0);           //LAN subnet mask                             //  <---You must edit this line!
IPAddress dnsserver(192, 168, 1, 1);          //DNS server                                  //  <---You must edit this line!
const unsigned int serverPort = 8090;         // port to run the http server on

// Smartthings / Hubitat Hub TCP/IP Address
IPAddress hubIp(192, 168, 1, 100);    // smartthings/hubitat hub ip //  <---You must edit this line!

// SmartThings / Hubitat Hub TCP/IP Address: UNCOMMENT line that corresponds to your hub, COMMENT the other
const unsigned int hubPort = 39500;   // smartthings hub port
//const unsigned int hubPort = 39501;   // hubitat 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.
  //****************************************9**************************************************
  //Polling Sensors 
  static st::PS_TemperatureHumidity sensor1(F("temphumid1"), 60, 40, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
  static st::PS_TemperatureHumidity sensor2(F("temphumid2"), 60, 40, PIN_TEMPERATUREHUMIDITY_2, st::PS_TemperatureHumidity::DHT22,"temperature2","humidity2");
  static st::PS_TemperatureHumidity sensor3(F("temphumid3"), 60, 40, PIN_TEMPERATUREHUMIDITY_3, st::PS_TemperatureHumidity::DHT22,"temperature3","humidity3");
  static st::PS_TemperatureHumidity sensor4(F("temphumid4"), 60, 40, PIN_TEMPERATUREHUMIDITY_4, st::PS_TemperatureHumidity::DHT22,"temperature4","humidity4");
  static st::PS_TemperatureHumidity sensor5(F("temphumid5"), 60, 40, PIN_TEMPERATUREHUMIDITY_5, st::PS_TemperatureHumidity::DHT22,"temperature5","humidity5");
  static st::PS_DS18B20_Temperature sensor6(F("temperature6"), 60, 40, PIN_TEMPERATURE_6, false);
  static st::PS_DS18B20_Temperature sensor7(F("temperature7"), 60, 40, PIN_TEMPERATURE_7, false);
  static st::PS_AdafruitThermocouple sensor8(F("temperature8"), 30, 0, PIN_SCLK, PIN_CS, PIN_MISO);  
  

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);
 //       For Example:  st::PS_AdafruitThermocouple sensor1("temperature1", 120, 3, PIN_SCLK, PIN_CS, PIN_MISO);
//
//        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
//        - int8_t pinSCLK - REQUIRED - the Arduino Pin to be used as the MAX31855 SCLK
//        - int8_t pinCS - REQUIRED - the Arduino Pin to be used as the MAX31855 CS
//        - int8_t pinMISO - REQUIRED - the Arduino Pin to be used as the MAX31855 MISO
 // static st::PS_Water               sensor1(F("water1"), 60, 0, PIN_WATER_1, 200);
//  static st::PS_Water               sensor2(F("water2"), 60, 10, PIN_WATER_2, 200);
//  static st::PS_Illuminance         sensor3(F("illuminance1"), 60, 20, PIN_ILLUMINANCE_1, 0, 1023, 0, 1000);
//  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
//  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_Alarm               executor3(F("alarm1"), PIN_ALARM_1, LOW, true);
//  static st::EX_Alarm               executor4(F("alarm2"), PIN_ALARM_2, LOW, true, 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 
  //*****************************************************************************
  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 EthernetW5100 Communications Object
    //STATIC IP Assignment - Recommended
    st::Everything::SmartThing = new st::SmartThingsEthernetW5100(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::SmartThingsEthernetW5100(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 sensor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addSensor(&sensor1);
  st::Everything::addSensor(&sensor2);
  st::Everything::addSensor(&sensor3);
  st::Everything::addSensor(&sensor4); 
  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
  //*****************************************************************************
  st::Everything::addExecutor(&executor1);
  st::Everything::addExecutor(&executor2);
  st::Everything::addExecutor(&executor3);
  st::Everything::addExecutor(&executor4);
//  st::Everything::addExecutor(&executor5);
//  st::Everything::addExecutor(&executor6);


// Devices:
// Type - Pin(s) - Name - Device Name:
// sensor1 - 22 - temperature1,humidity1 - Living Room Temp/Humidity
// sensor2 - 23 - temperature2,humidity2 - Family Room Temp/Humidity
// sensor3 - 24 - temperature3,humidity3 - Master Bed Temp/Humidity
// sensor4 - 25 - temperature4,humidity4 - Will's Room Temp/Humidity
// sensor5 - 26 - temperature5,humidity5 - Julia's Room Temp/Humidity
// sensor6 - 27 - temperature6 - Garage Temp
// sensor7 - 28 - temperature7 - Outside Temp
// executor1 - 30 - switch1 - Environment Fan
// executor2 - 31 - switch2 - Environment Heat
// executor3 - 32 - switch3 - Environment AC
// executor4 - 33 - switch4 - Environment Humidifier
// sensor8 - PIN_SCLK 34 PIN_CS 35 PIN_MISO 36 - temperature8 - Environment Burner

  //*****************************************************************************
  //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();
}

Your sketch looks fine to me. This makes me wonder if you have properly wired the DS18B20 sensors to the Arduino. Can you please share a wiring diagram of how they are connected?

Also, you have quite a few temperature sensors, and your current sketch is trying to poll most of them at the exact same time (i.e. every 60 seconds with a 40 second offset) as shown below.

  static st::PS_TemperatureHumidity sensor1(F("temphumid1"), 60, 40, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
  static st::PS_TemperatureHumidity sensor2(F("temphumid2"), 60, 40, PIN_TEMPERATUREHUMIDITY_2, st::PS_TemperatureHumidity::DHT22,"temperature2","humidity2");
  static st::PS_TemperatureHumidity sensor3(F("temphumid3"), 60, 40, PIN_TEMPERATUREHUMIDITY_3, st::PS_TemperatureHumidity::DHT22,"temperature3","humidity3");
  static st::PS_TemperatureHumidity sensor4(F("temphumid4"), 60, 40, PIN_TEMPERATUREHUMIDITY_4, st::PS_TemperatureHumidity::DHT22,"temperature4","humidity4");
  static st::PS_TemperatureHumidity sensor5(F("temphumid5"), 60, 40, PIN_TEMPERATUREHUMIDITY_5, st::PS_TemperatureHumidity::DHT22,"temperature5","humidity5");
  static st::PS_DS18B20_Temperature sensor6(F("temperature6"), 60, 40, PIN_TEMPERATURE_6, false);
  static st::PS_DS18B20_Temperature sensor7(F("temperature7"), 60, 40, PIN_TEMPERATURE_7, false);
  static st::PS_AdafruitThermocouple sensor8(F("temperature8"), 30, 0, PIN_SCLK, PIN_CS, PIN_MISO);  

Try changing these as follows to help spread the workload out across the full 60 second window:

  static st::PS_TemperatureHumidity sensor1(F("temphumid1"), 60, 5, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
  static st::PS_TemperatureHumidity sensor2(F("temphumid2"), 60, 10, PIN_TEMPERATUREHUMIDITY_2, st::PS_TemperatureHumidity::DHT22,"temperature2","humidity2");
  static st::PS_TemperatureHumidity sensor3(F("temphumid3"), 60, 15, PIN_TEMPERATUREHUMIDITY_3, st::PS_TemperatureHumidity::DHT22,"temperature3","humidity3");
  static st::PS_TemperatureHumidity sensor4(F("temphumid4"), 60, 20, PIN_TEMPERATUREHUMIDITY_4, st::PS_TemperatureHumidity::DHT22,"temperature4","humidity4");
  static st::PS_TemperatureHumidity sensor5(F("temphumid5"), 60, 25, PIN_TEMPERATUREHUMIDITY_5, st::PS_TemperatureHumidity::DHT22,"temperature5","humidity5");
  static st::PS_DS18B20_Temperature sensor6(F("temperature6"), 60, 35, PIN_TEMPERATURE_6, false);
  static st::PS_DS18B20_Temperature sensor7(F("temperature7"), 60, 40, PIN_TEMPERATURE_7, false);
  static st::PS_AdafruitThermocouple sensor8(F("temperature8"), 30, 0, PIN_SCLK, PIN_CS, PIN_MISO);  

Do you have a 4.7K Ohm resistor going from + bus to the DS18B20 data input? Without the resistor the readings are -196.6 It should look like this

1 Like

Haha, I feel like a idiot… ok, here’s the situation, I have 2 sensors on about a 30’ run. Knowing I’d have to play with the pull up on them to get working at that distance, I hooked up another one to replace#6 at my Arduino board. I was using that one to test the code with… turned out to be a garbage jumper…

And FYI, at about 30’, 2.2k pull up seems to be perfect

1 Like

Dan,

I have a question. Can you delay the reporting of an input contact? I have a relay on a contactor for a generator. When the Gen starts, I get a few on-offs as it comes up to full power. I only need to delay the input for about a sec.

Thanks

Depending on the ST_Anything device, maybe. The IS_Contact allows you to specify the number of counts that the input has to stay in the new state before it is reported to ST. The units for this is truly counts, or the number of times through the loop() function. It is not in units of time at all. So, just start increasing the value until you stop receiving multiple changes of state.

Here is the documentation, found at the top of every ST_Anything Class Module (e.g. IS_Contact.h or .cpp)

//  Summary:  IS_Contact is a class which implements the SmartThings "Contact Sensor" device capability.
//			  It inherits from the st::InterruptSensor class.
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::IS_Contact sensor6("contact1", PIN_CONTACT, HIGH, true, 500);
//
//			  st::IS_Contact() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- byte pin - REQUIRED - the Arduino Pin to be used as a digital input
//				- bool iState - REQUIRED - LOW or HIGH - determines which value indicates the interrupt is true
//				- bool internalPullup - OPTIONAL - true == INTERNAL_PULLUP
//				- long numReqCounts - OPTIONAL - number of counts before changing state of input (prevent false alarms)

Hi Guys…is there any way how to use Arduino potentiometer with ST? e.g. When I get 20°C from multipurpose senzor I’d like to send specific resistance Ohm to my gasboiler regulation.

Arduinos don’t typically control a potentiometer. An Arduino can read the voltage coming from a potentiometer.

Do you have more details regarding the device you want to control?

[UPDATED Idea]
If you just want to use a single resistance value, you could simply wire an appropriate resistor in series with a normal dry contact relay. The relay can easily be controlled by ST_Anything based on whatever logic you want from SmartThings (i.e. you could use webCoRE.)

So, the wiring would simply be

From Gas Boiler
to Relay Dry Contact (A)
Relay Dry Contact (B) to Resistor
to Gas Boiler

Would that work?

If so, you could also use an off-the-shelf Z-Wave Dry Contact relay in the exact same manner.

Hi to all,
I know a little about arduinos and esp8266, and a dirty and quick solition that comes to my minds could be a led with the PWM and a photoresistor. Or a transistor with the PWM.

Thank you Dan for this great library, what do you recommend to use your library and a esp8266 to send an IR signal to a portable AC ? i already have the IR codes (NEC protocol), first I want to start sending the ON/OFF commands, later on add the functions for speed and temp controls over IR.

Thank you very much in advance

im still trying to intergrate ST Anything into being able to control continuous servos that run on time rather than position as I am controlling my blinds through the original pole. I have a solution that works but its messy and is limited. So might give this a look at as I generally like the ST Anything stuff that you have done Dan :smiley:

If you look at the very latest version of the EX_Servo Class, I think you should be able to come up with something fairly easily. You will see that this device is now called on every pass through the loop() routine. This should allow you to start the servo motion and then stop it some number of milliseconds later. You’d need to either hack up a new version of EX_Servo, or extend its capabilities to allow for continuous motion versus just angular position commands. Perhaps a new constructor that configures the device for continuous motion would work? Or, if you can create a new class by copying EX_Servo and modifying it so it works the way you need… I could then try to merge the two back together into a single Servo Class later on.

Hi … Please send the code for nodemcu with jsn-sr04t and thank you

Hi Dan!
For some reasons all my devices stopped working on the evening of Feb 14th. What is a lovely gift! :heart_eyes:.
All my devices are built on ESP8266 (ESP-12E or ESP-01), and were working perfectly until that day.
The only possible change was made lately is this - I was playing with a sprinkler (Irrigation Controller 4 Zones by Aaron Nienhuis) - I know, why do I need an Irrigation in mid-February???:laughing:
Anyway, after I played with it, I have noticed that lights stopped working. I am using your libs/arduino design (Using Smart Lighting app with “PIN_CONTACT_1” to detect a state of the wall switch and "PIN_RELAY_1 "execute Relay turn on/off )
I was troubleshooting and found that lights are still controllable via Google service - they would turn on/off by a voice command but no a status change when trying to use Contacts.
I have updated My device handlers from Repo — ST_Anything (master), AND after that Contacts started working but relays stopped.
I am puzzled at this point.
Do you have any suggestions?
Thanks in advance.

Me too :wink:

Not really, without a lot more information.

How long were these running before they stopped working?

Can you get an ESP8266 up and running on your workbench and start troubleshooting from there?

Are you running all of the latest code? I made some significant changes recently for the EX_Servo library which requires all of the Arduino code/libraries to be re-downloaded to make sure you get all of the ST_Anything changes.

Are you building with Arduino IDE 1.8.8 and ESP8266 2.4.2?

How long were these running before they stopped working?

Was working for about 13 months!

Can you get an ESP8266 up and running on your workbench and start troubleshooting from there?
Yes, I have a spare NodeMCU.
Are you running all of the latest code? I made some significant changes recently for the EX_Servo library which requires all of the Arduino code/libraries to be re-downloaded to make sure you get all of the ST_Anything changes.
Yes, tried to use the latest library set, the same result - no post to relay.
Tonight will try to use an unchanged version (will adjust the WIFI conf) from https://github.com/DanielOgorchock/ST_Anything/blob/master/Arduino/Sketches/ST_Anything_Relays_Buttons_ESP8266/ST_Anything_Relays_Buttons_ESP8266.ino

Are you building with Arduino IDE 1.8.8 and ESP8266 2.4.2?
using Arduino IDE 1.8.8 and ESP8266 2.5 .

I have not done any testing with ESP8266 2.5. Try using 2.4.2 instead for now as I have tested it recently.

Will Do! Thanks!

Continuing the discussion from [RELEASE] ST_Anything v2.9.2 - Arduino/ESP8266/ESP32 to ST via ThingShield, Ethernet, or WiFi:

The way I’d like to control the gas boiler or other things is to make them think there’s e.g. temperature sensor which gives the regulation information (exact resistance for exact temperature).
It should tell the boiler hey there is 20°C in a room go and start behave like there is 20 even there is not:)
I think all regulations works that way… they’re reading resistance from sensors (light sensors, temp sensors, CO2 sensors, humidity sensors etc.) If you can put the right information you can control basically everything at home. Only thing you have to do is to be able to “send” the information (resistance) which one you want.

And If understand Arduino can’t do that, right?:frowning: