[RELEASE] ST_Anything v2.9.7 - Arduino/ESP8266/ESP32 to ST via ThingShield, Ethernet, or WiFi

@BarryA It appears I may need a forced disconnect as well. What information do you need?

You should be able to send a disconnect command on your own from the Hub utilities page in the IDE.

1 Like

Thanks I did the reconnect from the IDE page. Now working again.

1 Like

I forced a disconnect from the IDE last night. It didn’t seem to have worked initially but when I got up this morning things were working again.

1 Like

Hi there, I hope I’m in the right place here for solving the issue I’ve run into.

I’ve bought a Z-UNO from zwave.me planning to use it to drive a selection of relays for (primarily) garden irrigation valves. Unfortunately it seems that the basic z-uno device handler will only report the first device to smartthings and all other devices are ignored.

If I understand correctly from browsing this and other threads, it should be possible to integrate ST_Anything with the Z-Uno.

  • Is this correct?
  • What steps do I need to take to do that? Is it entirely on the arduino sketch side, or do I need to also adapt c program files? Do I need to modify the device driver?

A summary of the steps to take would be very helpful - at the very least to determine if I stand a chance in hell of making it work.

Thanks!

1 Like

Unfortunately, no. You cannot use the Z-Uno with ST_Anything. You’re probably going to have to write all of your own Arduino code as well as Z-Wave Device Handlers. Not a trivial task.

Personally, I would return the Z-Uno and simply buy an Arduino MKR WiFI 1010, an Arduino Nano 33 IoT, a NodeMCU ESP8266, or a NodeMCU ESP32 board. All of these are single board solutions that can use ST_Anything to communicate to SmartThings (or my HubDuino to communicate with Hubitat.) These are inexpensive, robust, reliable soultions with ready to run software. Of course, they use WiFi instead of Z-Wave…so that may or may not be a concern for you.

1 Like

Thanks for the clarification. Guess that is what I will do then! Which of those options would be the least hassle/most fool proof, or no real difference?

(I am leaning towards the NodeMCU ESP8266 as the rest of the circuit is 5V and it wouldn’t require a seperate power supply)

All of the boards I mentioned above are capable of being powered via their USB connectors (5vdc). However, all of their GPIO pins are 3.3v only. If you really want a 5v TTL capable device, the only one I would recommend for running ST_Anything is the Arduino MEGA 2560 with a W5500 Ethernet Shield 2. OF course, this requires a hard-wired Cat5 ethernet connection…so that might be an issue.

If you describe your use-case, I might be able to suggest a microcontroller that would suit your needs. The NodeMCU ESP8266 boards are great, but limited on GPIO.

I want to put my garden irrigation (and future extensions) on my smart home system.

Things to control right now:

  • 3x valves for irrigation; I’m looking at both manual control and a timer function. Preferably timer that runs locally and can be configured over the smartthings interface. Alternatively I will run a timer script on webpistons.
  • pond pump & uv filter; switching on/off manually or automatically.
  • relay to switch USB utility power

All the above is a matter of switching a total of 6 5V relays.

Future additional functionality I am considering:

  • Water level measurement in pond, automate top up (undecided between ultrasonic or probe resulting in analog input)
  • temperature/humidity readout
  • rgb led control
  • readout to led display of either timer functions or temperature/humidity

Thank you for your input!

Going through your code examples I think I got a fair idea how to implement most of what I need. However there are a few cases where I am not sure if there is a way to handle it on the arduino side, or if it will need to be on the smartthings/pistons/etc cloud side. I’d prefer to run as much as possible locally to continue working even if for some reason e.g. my smartthings hub is down.

My questions then are:

Duration of irrigation/relay activation; I can see that the timed relay function takes a parameter for the duration after which it is reset. I may want to change that depending on weather etc. Is there a way to change that parameter on the fly? I guess I’d need a virtual device; e.g. a dimmer take a variable input from SmartThings? Is there a best practice method for this?

Interval and switching on/off irrigation zones (relays) for automatic activation; Depending on either user action or based upon e.g. weather, humidity measurement etc I’d want to be able to enable/disable specific relays for clock-based activation as well as set the times. Any recommendations here?

Time synchronisation; Is there any (easy) way to sync time with the smartthings hub? If not I will look at NTP synchronisation.

Sounds like you really want a dedicated irrigation controller solution. There are a few Arduino/ESP8266 based irrigation projects in the community that would probably be better suited to your project needs without having to develop a lot of code. These allow for scheduling and duration via the ST App, while leaving the timing up to the micro controller to ensure valves are turned off.

You are probably right. I am looking at https://github.com/anienhuis/smart_sprinkler/tree/master/ESP8266 for one. Other than that I have really only found the SmartThings-Shield-based predecessor of that project. Have I missed anything obvious?

That said I would learn less that way, and was hoping to take more of a ‘lego’ approach. Build the building blocks, figure out how I want them to interact, then move on to implementing the interaction etc. If I then feel I want something a bit different from what has already been done, I’d at least have a clue where to start rather than gawk stupidly at the black magic box and wonder if it’d need more or less voodoo :wink:

Based upon your response I gather that the ‘lego bricks’ I’m looking for (in particular passing of variables) is not something that is easily done within the framework of ST_Anything. I’ll dig further into the alternatives.

Again, thanks for taking the time to respond!

1 Like

If you’re willing to write you’re own code, you could start with my SmartThingsESP8266 library. It implements all of the communications between ST_Anything and SmartThings. You’d want to probably reuse much of my groovy code, but probably make custom child devices to implement your sprinkler zones and time settings.

Roger that, will dive into it.

… and got the basics working with ST_Anything. Actually easier than I thought, once I got going!

1 Like

Hi, I’m looking into a new project that could involve a Arduino controller. I have no experience with Arduino and I have a few questions about the controller and the way it integrates with smartthings.

What would I like to do:

24 Pushbuttons (4 x NIKO https://www.niko.eu/nl-be/producten/schakelmateriaal-en-wandcontactdozen/schakelaars-en-wandcontactdozen/zesvoudige-potentiaalvrije-24v-drukknop-met-leds-no-productmodel-niko-9e5189f2-1271-52e7-9f90-159934ee823c) connected to Arduino as input devices.

Relayboard with 8 relays as output device.

6 outputs on Arduino that connect to 6 Qubino 0-10V dimmers connecting to six 0-10V LED-drivers.
If this is to difficult, I could choose to connect the Qubino 0-10V dimmers directly to the pushbuttons.

I have read a bit about it and I think I need a Arduino Mega with a Ethernetshield, a Relayboard with 8 relays (5V input - 230V output)

Will this work and will it be easy to program with ST_Anything?
Would I be able to use all the inputs and outputs from the smart things interface and within Webcore?

Kind regards,

Pieter-Jan

Hello all… I had success with a trial temp sensor project over the winter and it worked awesome. Now I want to start a different project with a ESP32 but I cannot get ST to create the child devices. I’ve even tried using a sketch that worked in the past. I did update all the device handlers and arduino libraries. I’ve followed the instructions with updating the parent device with IP, port, MAC.

The error I get in ST is “DEVICE ALERT childDeviceCreation failed ST_Anything Parent Device has not yet been fully configured…”

In the serial monitor I get this message “Post request timed out”

I’ve tried using the ‘stock’ multiples sketch and only changed the wifi details with no luck either. I also tried on a ESP8266 board. I’m selecting the correct board on Arduino as well. Any suggestions?

Thanks!

This issue was caused by ST Firmware v27.6. Version 27.8 is supposed to be released today which is supposed to correct this issue.

See a few posts above for more details and this temporary workaround.

Sorry if this has been answered already.

I am working with a NodeMCU ES8266 (01), also a smartthings Hub v3.
I am from Europe and the developers ide is the European one the one where it doesn’t allow github repositories in the Device Handlers.

The NodeMCU code is working fine, I get messages on Serial Port without issue, I’m using the example sketch ST_ANYTHING_RGB_ESP8366WIFI and it connects and everything works.

However when I go to add device, it is not discovered, (I don’t have the “other” device listed on both smartthings classic and smartthings new mobile app (I am trying with both) ).

At the moment I just have an RGB led connected to my ESP8266m nothing else.

Sketch:

//******************************************************************************************
//  File: ST_Anything_RGB_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 RGB LED (used to set the color of a RGB LED - either individual RGB LED's or RGB LED Strips)
//    
//  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
//    2017-10-08  Allan (vseven) Modified for a RGB LED (single LED or LED strip)
//    2018-02-09  Dan Ogorchock  Added support for Hubitat Elevation Hub
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for ESP8266WiFi
//******************************************************************************************
#include <SmartThingsESP8266WiFi.h>

//******************************************************************************************
// 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 <EX_RGB_Dim.h>      //Implements an Executor (EX) for a RGB LED or strip with PWM using 3 digital output pins

//*************************************************************************************************
//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_RGB1_Red           D5  // SmartThings Capability "Color Control"
#define PIN_RGB1_Green         D6  // SmartThings Capability "Color Control"
#define PIN_RGB1_Blue          D7  // SmartThings Capability "Color Control"

//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid     = "XXXXX";                           //  <---You must edit this line!
String str_password = "XXXXXXX";                   //  <---You must edit this line!
IPAddress ip(192,168,86,111);       //Device IP Address       //  <---You must edit this line!
IPAddress gateway(192,168,86,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,86,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, 86, 23);    // 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()
{
  //******************************************************************************************
  //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
  
  //Interrupt Sensors 

  //Special sensors/executors (uses portions of both polling and executor classes)
  
  //Executors
  static st::EX_RGB_Dim         executor1(F("rgbSwitch1"), PIN_RGB1_Red, PIN_RGB1_Green, PIN_RGB1_Blue, false);
  
  //*****************************************************************************
  //  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
  //*****************************************************************************
  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 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
  st::Everything::init();
  
  //*****************************************************************************
  //Add each sensor to the "Everything" Class
  //*****************************************************************************
      
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addExecutor(&executor1);
    
  //*****************************************************************************
  //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();
}

What stupid thing am I missing to put the device (the esp8266) on the smartthings ? … I have been at it for 6 hours and feel like I tried everything.

Serial Output from the ESP8266

Everything: Free Ram = 47160
Everything: Free Ram = 45816
Everything: Free Ram = 44624
Everything: Sending: rgbSwitch1 off
Everything: Free Ram = 44368

You cannot use the Smart App (new or classic) to ‘Discover’ the ESP8266 running ST_Anything.

Please follow the detailed instructions in the ST_Anything ReadMe, which outline the steps necessary to add/publish all of the Device Handlers, as well as the manual steps required to add the ST_Anything Parent Device via the ST Web IDE. Afterwards, you will then use the ST Classic App to configure the Parent Device’s settings.

HOWEVER- until ST firmware v27.8 is released, you will still encounter issues. You may want to simply wait a day or two until SmartThings releases that updated firmware to the v2 and v3 hubs.)

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.