[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

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.)

Awesome thanks! I should have posted something here earlier as I’ve lost a fair amount of time thinking I was overlooking something.

Ok thanks, not to repeat myself but I read the whole readme, and I followed the instructions, howevert, I cannot add the Device Handlers and that’s where I’m getting stuck as there is no github repository allowed in the ST Web IDE, the European and US versions are different. Sorry if we’re not talking about the same thing here.

James.

I think you’re getting confused somewhere James.
GitHub has been able to integrate for years now… Well in the UK where I am anyway.
It doesn’t really matter anyway you can still do it manually, So find the device handler you want on the GitHub page and click on “raw” then copy ALL that text and then on your SmartThings IDE page click create new device handler from code and then paste all that text into the box and save and publish.
Then carry on with creating your device.

2 Likes

As @Steveuk23 mentioned, if you’re having difficulty getting the HitHub integration working within the ST Web IDE, you can always add each Device Handler manually via the copy and paste method. Please be sure to click SAVE and PUBLISH for each device handler.

1 Like

Hi Dan did you ever look at the new SmartThings app ?
I appreciate you don’t use ST anymore so if you haven’t it’s fine as I’m still using the old app anyway.
I’ve just been updating all my 3rd party D/H’s so thought I’d check yours.
Cheers

I have not bothered to update any of my DTH’s for the new ST App. Another user, @vseven, has added some updates to the Child DTH’s to make them somewhat compatible with the New ST App.

2 Likes