[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

Adafruit didn’t work as in a compiled but you couldn’t get the RGB to change? Or it didn’t compile at all?

As for switching the library I’m not sure as they might define things differently. I can try it and see what I get. Or you can PM me the error messages so we’re not making a mess of this thread.

Edit: I was able to take the EX_RGBAddressable_Dim library files and the ST_Anything_AddressableRGB_ESP8266WiFi.ino from my GitHub and compile successfully against a NodeMCU 1.0 (ESP-12E Module) as is. Haven’t tried the other library yet.

1 Like

Why not just buy a purpose-built, ready to use zigbee motion sensor? You will get way better responsiveness, battery life, and reliability. Lowes has a clearance sale going on right now for their Iris Motion sensors for $15.

It is possible to do what you’ve suggested, but you would really want to simple use the “SmartThings…” communications libraries (in my ST_Anything GitHub repo) instead of the whole ST_Anything package. It would be a lot simpler and smaller code-wise.

If you really want to try this with ST_Anything, you will need to modify the IS_Motion.cpp file to remove the 30 second warm-up time that I included to prevent false motion events from being sent during power up.

If you want to do this in the sketch, look at using the ‘callback()’ function that is included on all of the ST_Anything example sketches. This function is called any time data is sent to SmartThings. You can parse the data and perform any type of analysis you’d like. Then, based on your analysis, you can send Button Events, like Pushed and Held, to ST…emulating a button controller device.

If you need help, let me know… You can look into the IS_Button.cpp file to see how it formats the data to be sent to ST. I believe it is simply “button1 pushed” or “button1 held”… Of course, your could also pretend to have a “button2” or “button3”… You do NOT need to create IS_Button devices to make this work. You just need to send the correct strings to ST, the same as if you had defined IS_Button devices. You also need to make sure you define the correct number of buttons in the Parent Device’s settings. Doing so allows other SmartApps to know how many ‘buttons’ your device has, to allow you to select those buttons as triggers for events.

Here is an example of what I am talking about… The IF statements are PSEUDO CODE, meaning you will need to parse the ‘msg’ string to get the numeric portion of the ‘voltage1 23.45’ messages being sent to ST to use in the comparison.

//******************************************************************************************
//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
  
  //PSEUDO CODE
  if  (parsed voltage message < 10) {
     st::Everything::sendSmartString(“button1 pushed”);
   }
   else if (parsed voltage message >= 10) {
     st::Everything::sendSmartString(“button1 held”);
   }

}

Thank you for your reply. I have couple of them with battery shield and I thought that it would be useful to build a motion sensor. I will look for an other project than where i can use them. I am not expert in coding. Thank you.

1 Like

@ogiewon Ok i am a total beginner with Arduino IDE and Arduino /esp in general but a fast learner :slight_smile:
I am trying to program a NodeMCU esp8266 v0.9 to cntrol 2 relays but when i am trying to compile the code it gives me this error message:
“compilation terminated.
exit status 1
SmartThingsESP8266WiFi.h: No such file or directory”
I don’t know what i am doing wrong i am sure it is something dumb but i do have that file that the rror is referencing in that folder as per instructions. I have tried to do some research on line and see how can i fix this issue but i am posting here as well
any help will be greatly appreciated
Denis

Can you tell me the exact full path to that file on your computer? It sounds like the libraries might not be installed correctly.

I am having issues creating child devices. I first started testing with an unmodified sketch but when I reached the end of the whole process I got the error: “Child device creation failed. Please make sure that the ‘null’ is installed and published.” I did a lot of research to figure out why this was happening, I tried recreating the parent device 10 or so times, completely reinstalled all parent and child DTHs to no avail. After looking at the parent DTH code, I choose to remove the number by the name of the device in the Arduino sketch, going from sensor1(F("doorControl1") to sensor1(F("doorControl"). The error went away but no child devices were created. I think something in the parent DTH is not working right for me.

Using:
Smartthings Hub V2
ESP8266-01

P.S. Live Logging has never worked on my hub despite many attempts to fix it, so I won’t be able to troubleshoot this problem that way.

Sean

You must have the number appended to each device name in the sketch. My guess is that you forgot to publish all of the child devices?

Also, please contact ST Support to resolve the live logging issue. You really need it working for troubleshooting code.

Thank you Dan for your prompt replies
here are their paths for both folders:
C:\Users\Denis Grabocka\sketchbook\ST_Anything_Multiples_ESP8266WiFi

and

C:\Users\Denis Grabocka\sketchbook\SmartThingsESP8266WiFi

Initially i just ran it from the locations above just as they were copied over from the zip file and got that error;

I also went and copied all contents of both those folders into one new folder and opened and ran Arduino IDE from that folder and still the same error persisted

what am i doing wrong?

and thank you again

Denis

I checked and made sure all of the child devices were published. Also I couldn’t get the error to go away with the numbers, the parent DTH just won’t create the child devices.

That doesn’t appear to be the correct path for standard Arduino code.

As described in the ReadMe, it should be

C:\Users\Denis Grabocka\Documents\Arduino\libraries\

And

C:\Users\Denis Grabocka\Documents\Arduino\Sketches\

Sean,

Not sure what to tell you. It sounds like you’ve got some ST IDE issues if you still cannot get Live Logging to work. Does GitHub integration work for you?

Can you show me a screen shot of your parent device from within the ST Web IDE?

The first screenshot is the parent DTH and the second is the child DTH I am trying to use.

Thanks, but I want to see the Device, not the DTH. On your My Devices tab in the ST Web IDE, click on the Parent Device you manually created, so I can see all of the details.

That would make more sense, here it is:

Everything there looks normal. I was hoping that you had simply forgotten to assign your Hub to this device, but it looks like you did.

Without Live Logging, I am not sure how to help you troubleshoot this issue.

As for renaming the device to remove the error message, that only works because I trap the new error you created by removing the numeric part of the name within the Parent Device Handler code, and log that error to Live Logging. The Parent Device Handler never even tries to create a child device without that numeric suffix to the device name. Also, the Device Names must follow the standard naming outlined in the ReadMe file. Otherwise, the parent will not know what type of child device to create.

Ok great i got it compiled, flashed on my NODEmcu and the SmartThings IDE and App part configured but i installed ST_Anything_Multiples and i obviously i got a long list of devices that i do not need.
All i need is 2 relay buttons/controls to turn on and off an electric curtain …do i just remove the buttons i do not need from the ST app and keep just the relay button and a switch button and use those as the 2 controls i need or will it be better to flash ST_Anything_Relays on my ESP8266??

As a matter of fact i am actually only looking for 2 momentary buttons … which sketch does that best since my curtains have 2 momentary buttons one for open one for close than stop automatically when they reach the end of direction.

The relays should respond to the default D pins assigned in your sketch right?? since i did not change any of that on the sketch other than the IPs and wifi config

Thank you very very much
Denis

Just for clarification… You would like two digital outputs, that after being turned on, automatically turn off after a few seconds. Is that correct? Anything else? I can whip up that sketch very quickly once I know all of your requirements.

UPDATE: Here is the base sketch to start from. You’ll need to modify the WiFi section, or course. This sketch uses Pins D1 and D2 on a NodeMCU ESP8266 board.

//******************************************************************************************
//  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
//              - 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...))
//    
//  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
//    2018-11-13  Dan Ogorchock  Revised for DENIS GRABOCKA's requirements
//
//******************************************************************************************
//******************************************************************************************
// 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 <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_TIMEDRELAY_1          D1  //SmartThings Capability "Relay Switch"
#define PIN_TIMEDRELAY_2          D2  //SmartThings Capability "Relay Switch"

//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid     = "yourSSIDhere";                           //  <---You must edit this line!
String str_password = "yourWiFiPasswordhere";                   //  <---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, 149);    // smartthings/hubitat hub ip //  <---You must edit this line!

// SmartThings / Hubitat Hub Port: 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 Handler 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)
  static st::S_TimedRelay           sensor1(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW, false, 2000, 0, 1);
  static st::S_TimedRelay           sensor2(F("relaySwitch2"), PIN_TIMEDRELAY_2, LOW, false, 2000, 0, 1);
  
  //Executors
  
  //*****************************************************************************
  //  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
  //*****************************************************************************
  st::Everything::addSensor(&sensor1);
  st::Everything::addSensor(&sensor2);
     
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
    
  //*****************************************************************************
  //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();
}
2 Likes

Yes that is it you got it right… and man than you so much for being such a great help and so quick to reply.

One last think what do i select or use on the SmartThings side what kind of device?/

Thank you again
Denis

Simply follow the same instructions from the ReadMe on the ST IDE side of things. If you already have a ST_Anything Parent Device, remove it (not the groovy code, the device.) Then, manually create a new Parent Device for this particular NodeMCU Board (unique MAC address for each board), configure its settings in the ST Classic App, and the two Child Devices will be created. Then you simply turn them on, and they will automatically turn off after 2000ms (you can change that value in the sketch as needed.)