[RELEASE] ST_Anything - Arduino/ESP8266/ESP32

Yes. It would. But that means you would still need a key as a backup.

1 Like

Check out these two vids captured on my camera:

  1. https://www.dropbox.com/s/7fephui9tqdstzb/WT.mp4?dl=0
  2. https://www.dropbox.com/s/ug10avcwfkh1kcs/IT.mp4?dl=0

That is why I need the gate…if the gate wasn’t locked I would have had some problems. And if it weren’t for the cameras…I wouldn’t have known this even happened.

Let me know once you see the vids…so I can take them off. Don’t want to keep these public for too long.

Understood! Thanks for sharing.

1 Like

BETA Release - Child Contact Sensor Enhanced with Runtime

This is a Child Contact Sensor that has been modified to allow you to select what you want displayed (On/Off, Open/Closed, Alarm/Normal, etc), to be able to invert the normal colors (Blue/Orange), and to track runtime or status of a device. It can replace the existing “Child-Contact-Sensor” DTH directly and will work the same other then adding features. As a example I’m using a contact input for a heater in my garage. So I want the display to say “Heating” for closed and “Off” for open so I select those as my display names. I also want to show open as the blue background so I invert the colors. Here is the main screen for my garage heater:

And the options:

Since this is a drop in replacement for the existing ST_Anything Child Contact Sensor I’m pushing it from my GitHub so as to not confuse stuff. If @ogiewon wants I will add these to the official repo but consider this a beta for now. I’ve gone through and tested it decently but it still needs more people then just me to test. My GitHub:

Owner: vseven
Name: SmartThings_VSeven
Branch: master

If you cannot integrate it directly (I’m having trouble installing new devices from GitHub right now…) you can install it manually by clicking here: https://raw.githubusercontent.com/vseven/SmartThings_VSeven/master/devicetypes/vseven/child-contact-sensor-enhanced-with-runtime.src/child-contact-sensor-enhanced-with-runtime.groovy and copy/paste it into My Device Handlers -> Create New Device Handler -> From Code. Once you do that go to My Devices, find the device you want to switch, click it, click Edit, and select the new “Child Contact Device Enhanced with Runtime”.


I purchased these buzzers on Amazon: http://amzn.to/2HHFEpo

Just want to make sure this works with ST Anything/ D1 Mini Wemos? It can operate from 3V-24V and from my understanding the Wemos delivers 3V??

And just to confirm…the D1 Mini Wemos can only be powered with 5V? Not 12?

They should work, but be sure to check the spec sheet to make sure they don’t draw too much current from the ESP8266’s GPIO pins.

They pull 12mA. Is that too much?


Per the link above, 12ma per pin is the maximum.


I have followed the steps in the original post but must have made a mistake. I have added the device but no child is being created.

i get this error messages:

[name:temperature1, value:-196.60, isStateChange:false, displayed:false, linkText:Test Arduino, descriptionText:Test Arduino temperature1 is -196.60]
62ee7308-a087-4031-83fe-73ee4553772d 11:48:37 PM: debug isChild = true, but no child found - Auto Add it!

i also get a message on the app, st_anything parent device has not fully configured. …

can anyone suggest a way forward?



Double check that you installed and published all of the Child dth’s.

Just received my D1 Mini Wemos and installed the ST Anything Sketch for Relay + Button and got it to work!

Can someone help me write the following sketch files. I will order two more boards.

Board 1:

  • This Relay

  • A Push Button (like a doorbell)

  • This beeper

  • An open/close sensor.

Board 2:

Board 3:



First of all i would like to say how great this project is. I was able to get everything setup with a NODEMCU and a few sensors, but i ran into a problem. It seems to disconnect after about 1-1.5 hours. I noticed in the arduino serial monitor the “Free Ram” keeps counting down and it seems to coincide with when is disconnects. Is there something that would be using up all the ram? This is what the serial monitor shows. It started at 40000 about 45 mins ago.

Everything: Sending: humidity1 35.00
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 34.00
Everything: Sending: temperature1 73.94
Everything: Sending: humidity1 34.90
Everything: Sending: temperature1 73.94
Everything: Sending: humidity1 34.90
Everything: Free Ram = 17368
Everything: Sending: temperature1 73.94
Everything: Sending: humidity1 34.90
Everything: Sending: contact1 closed
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 34.70
Everything: Sending: temperature1 73.94
Everything: Sending: humidity1 34.60
Everything: Sending: temperature1 73.94
Everything: Sending: humidity1 34.30
Everything: Sending: temperature1 73.94
Everything: Sending: humidity1 34.10
Everything: Free Ram = 16640
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 34.30
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 33.90
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 33.70
Everything: Free Ram = 16248
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 33.70
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 33.70
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 33.70
Everything: Sending: temperature1 74.12
Everything: Sending: humidity1 33.80

What type of board are you using and how are you powering your sensors? The USB port on your PC will not give a full 5v 1 amp that the NodeMCU likes. I would recommend plugging into a 5v 1amp usb “wall wart” and see if the problem persists. Also, if you only have polling sensors, a reboot really isn’t a problem, is it? Or do you also have interrupt sensors or executors on the same board?

I’m powering it from the PC as well as 2.4A usb power supply and it does the same thing. I just have it on a breadboard right now with a contact sensor and DHT22 sensor. I would be fine if it actually rebooted every 1.5 hours, but it disconnects from the network and needs a reset to connect again.

What are you having problems with? It’s not quite as simple as just knowing what the device is. There are several options for each device. For example, a relay can be standard or reverse logic (power to power on or lack of power to power on). If you are looking for how to define each of your devices in the sketch, you can look in the library. Within the class’s “h” file will be an example to put in your sketch. Wouldn’t you rather learn to create your own sketches (or learn how to modify the existing one)? Teach a man to fish…

If you’re looking for the library files they are most likely located in:
My Documents\Arduino\libraries\ST_Anything

Then you’ll see two files for each class. At the top of each one is an example of how to define the device and what the different options for the device are.

1 Like

Wait…so, how are you powering from a 2.4amp power supply and from the PC at the same time?

Can you post a copy of your sketch? And you didn’t say what type of board you’re using.

I have it plugged into the PC right now for debugging. Before it was plugged into the USB power supply. It is doing the same thing regardless how i power it.
Is there a good way to upload my sketch to here? Maybe i did something in the sketch that is causing it to run out of ram.

You can paste it, then highlight it and click the “</>” icon just about where you enter text. That will make it “code”.

Thanks, Here is my sketch:

//  File: ST_Anything_Multiples_ESP8266WiFi.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 NodeMCU ESP8266 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 NodeMCU ESP8266's WiFi.
//            ST_Anything_Multiples implements the following ST Capabilities as a demo of what is possible with a single NodeMCU ESP8266
//              - 1 x Alarm device (using a simple digital output)
//              - 1 x Contact Sensor devices (used to monitor magnetic door sensors)
//              - 1 x Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
//              - 1 x Motion devices (used to detect motion)
//              - 1 x Smoke Detector devices (using simple digital input)
//              - 1 x Temperature Measurement devices (Temperature from Dallas Semi 1-Wire DS18B20 device)
//              - 1 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"
//              - 1 x Water Sensor devices (using the 1 analog input pin to measure voltage from a water detector board)
//  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-17  Dan Ogorchock  New example showing use of Multiple device of same ST Capability
//                               used with new Parent/Child Device Handlers (i.e. Composite DH)
//    2017-05-25  Dan Ogorchock  Revised example sketch, taking into account limitations of NodeMCU GPIO pins
//    2018-02-09  Dan Ogorchock  Added support for Hubitat Elevation Hub
// SmartThings Library for ESP8266WiFi
#include <SmartThingsESP8266WiFi.h>

 int ledState = LOW;
 long previousMillis = 0;
 int interval = 1000;

// 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

#include <PS_TemperatureHumidity.h>  //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
#include <PS_DS18B20_Temperature.h>  //Implements a Polling Sesnor (PS) to measure Temperature via DS18B20 libraries 
#include <PS_Water.h>        //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector)
#include <IS_Motion.h>       //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor
#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_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 Siren capability via a digital output to a relay
#include <S_TimedRelay.h>    //Implements a Sensor to control a digital output pin with timing capabilities

//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 D7 13
//#define D8 15  //must not be pulled high during power on/reset

//Define which Arduino Pins will be used for each device
#define PIN_WATER_1               A0  //NodeMCU ESP8266 only has one Analog Input Pin 'A0'

#define PIN_ALARM_1               D0  //SmartThings Capabilty "Alarm"
#define PIN_SWITCH_1              D1  //SmartThings Capability "Switch"
#define PIN_CONTACT_1             D2  //SmartThings Capabilty "Contact Sensor"
#define PIN_BUTTON_1              D3  //SmartThings Capabilty Button / Holdable Button (Normally Open!)
#define PIN_BUTTON_2              D4  //SmartThings Capabilty Button / Holdable Button (Normally Open!)
#define PIN_MOTION_1              D5  //SmartThings Capabilty "Motion Sensor" (HC-SR501 PIR Sensor)
#define PIN_SMOKE_1               D6  //SmartThings Capabilty "Smoke Detector"
#define PIN_TEMPERATUREHUMIDITY_1         D7  //SmartThings Capabilty "Temperature Measurement" (Dallas Semiconductor DS18B20)
//#define PIN_TEMPERATURE_1         D7  //SmartThings Capabilty "Temperature Measurement" (Dallas Semiconductor DS18B20)
#define PIN_TIMEDRELAY_1          D8  //SmartThings Capability "Relay Switch"

//ESP8266 WiFi Information
String str_ssid     = "";                           //  <---You must edit this line!
String str_password = "";                   //  <---You must edit this line!
IPAddress ip(192, 168, 1, 227);       //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, 180);    // 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.
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

//Arduino Setup() routine
void setup()
pinMode(2, OUTPUT);
  //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.
  //Polling Sensors
  //static st::PS_Water               sensor1(F("water1"), 60, 20, PIN_WATER_1, 200);
 static st::PS_TemperatureHumidity sensor2(F("temphumid1"), 15, 0, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
     //static st::PS_DS18B20_Temperature sensor2(F("temperature1"), 15, 0, PIN_TEMPERATURE_1, false, 10, 1); 
  //Interrupt Sensors 
  static st::IS_Contact             sensor3(F("contact1"), PIN_CONTACT_1, LOW, true);
  //static st::IS_Button              sensor4(F("button1"), PIN_BUTTON_1, 1000, LOW, true, 500);
  //static st::IS_Button              sensor5(F("button2"), PIN_BUTTON_2, 1000, LOW, true, 500);
  //static st::IS_Motion              sensor6(F("motion1"), PIN_MOTION_1, HIGH, false);
  //static st::IS_Smoke               sensor7(F("smoke1"), PIN_SMOKE_1, HIGH, true, 500);

  //Special sensors/executors (uses portions of both polling and executor classes)
 // static st::S_TimedRelay           sensor8(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW, false, 3000, 0, 1);
  //static st::EX_Alarm executor1(F("alarm1"), PIN_ALARM_1, LOW, true);
 // static st::EX_Switch executor2(F("switch1"), PIN_SWITCH_1, LOW, true);  //Inverted logic for "Active Low" Relay Board
  //  Configure debug print output from each main class 
  //  -Note: Set these to "false" if using Hardware Serial on pins 0 & 1
  //         to prevent communication conflicts with the ST Shield communications

  //Initialize the "Everything" Class

  //Initialize the optional local callback routine (safe to comment out if not desired)
  st::Everything::callOnMsgSend = callback;
  //Create the SmartThings ESP8266WiFi Communications Object
    //STATIC IP Assignment - Recommended
    st::Everything::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, 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::SmartThingsESP8266WiFi(str_ssid, str_password, serverPort, hubIp, hubPort, st::receiveSmartString);

  //Run the Everything class' init() routine which establishes WiFi communications with SmartThings Hub
  //Add each sensor to the "Everything" Class
 // st::Everything::addSensor(&sensor6); 
 // st::Everything::addSensor(&sensor7);  
 // st::Everything::addSensor(&sensor8);  
  //Add each executor to the "Everything" Class
 // st::Everything::addExecutor(&executor1);
 // st::Everything::addExecutor(&executor2);
  //Initialize each of the devices which were added to the Everything Class

//Arduino Loop() routine
void loop()
  //Execute the Everything run method which takes care of "Everything"
    unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   
    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
      ledState = LOW;
    // set the LED with the ledState of the variable:
    digitalWrite(2, ledState);

This is the board i’m using:


And this is the hardware connected. I just have the contact sensor as a wire right now. It will be connected to a magnetic contact sensor.