SmartThings Community

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


(L B) #2187

I just tried to make it a smaller post.

(Dan) #2188

Did the code I posted work for you?

Tip: to help make it easier in the future, be sure to highlight all of your pasted code and then click the Preformatted Text (</>) menu option in the editor window. This makes it much easier for others to copy and paste the code without the ASCII characters getting all messed up.

(L B) #2189

Yes it did. I am comparing to understand what I did wrong.
Now I understand. I thought you meant the top notes. I didn’t take out the #include, I used a thingsshield sketch in the folder. Thinking about it, I original downloaded an older version of the anythings master. Must be an older one.

And thanks again! I thought I did it right :smile:
Next I will add smokes and water. I should be able to get it…

(L B) #2190

I need help on motions. My motions are nc. I changed the value false and left it high. Will they work like that?
They didn’t work as it was original written, always shows motion, I assume because the pins were always powered.

(Dan) #2191

The sample code is designed for an Active High PIR motion detector, which supplies either GND or 5V externally.

The documentation is at the top of the IS_Motion.h and .cpp files.

If you have a dry contact motion detector, try using something like:

st::IS_Motion sensor1(F(“motion1”), PIN_MOTION, HIGH, true, 500);

if that provides backwards motion values, simply change it to

st::IS_Motion sensor1(F(“motion1”), PIN_MOTION, LOW, true, 500);

//  File: IS_Motion.h
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//  Summary:  IS_Motion is a class which implements the SmartThings "Motion 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_Motion sensor5(F("motion1"), PIN_MOTION, HIGH, false, 500);
//			  st::IS_Motion() 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 output
//				- bool iState - OPTIONAL - 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)

(Fraser Wallace) #2192

Wow, this is great. Why did it take me so long to find it? Now, if only I can get it to work. When I try to veify a sketch I get the error
C:\Users\user\Documents\Arduino\libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp: In member function ‘virtual void st::SmartThingsESP8266WiFi::init()’:

C:\Users\user\Documents\Arduino\libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp:157:29: error: ‘class ArduinoOTAClass’ has no member named ‘getHostname’


I have tried verifying the Blink sketch and quite a few others, and they work OK, but I still get the error on ST_Anything sketches.

(Dan) #2193

A few ideas/questions to hopefully help…

Did you copy ALL of the ST_Anything\Arduino\Libraries folders to your computer’s corresponding Arduino\Libraries folder?

Can you successfully compile any of the ESP8266 Example Sketches that incorporate WiFi?

(Fraser Wallace) #2194

Hi, Dan. I did a download zip of your repository so I believe I should have all the files. Visually they all appear to be there.

I have also compiled WiFiscan and WiFimulti without a problem.

Thanks for all the time you have put into this project and for your help.

(L B) #2195

Got motions working, thank you for the help as always!
I have noticed something. If the board stops responding or is disconnected somehow, the app simply stays at the last state. It appears it is working, but until you look close, you don’t notice. Do you have a way to report if communication is lost?


(Dan) #2196

All I can tell you is to go back through the ReadMe, step by step, and make sure you didn’t miss anything in setting up your Arduino environment.

Are you using v2.3 of the ESP8266 Board Manager package?

(Dan) #2197

@lukeb each child device has a custom attribute called LastUpdated which has the last date and time an update was received. By default, this should update at least once every 5 minutes.

You could use one of the Community SmartApps that can notify you if a device does not receive an update within a certain timeframe.

(Fraser Wallace) #2198

I found I am using v2.2 but whenever I try to update to 2.3 I get an error downloading

I tried downloading Arduino repository but that only gets me v2.2 again.

I will keep working on it. Thanks.

(Dan) #2199

Are you trying to download the ESP8266 Board Package for Arduino manually? If you follow the instructions in my ReadMe, it should point you to another website (SparkFun, IIRC) that shows you how to easily add the ESP8266 support to the Arduino IDE. You then use the built-in Arduino IDE ‘Boards Manager’ feature to adjust the version of the ESP8266 Core support.

From my ReadMe…

“If building for a standalone ESP8266 board, make sure you have configured the Arduino IDE to include support for these boards. Follow the guide at

(Fraser Wallace) #2200

I can download and instal Arduino and instal esp8266 board as in the instructions you sent, but when I use board manager to change the version I get an error and I haven’t found a way around it yet. This also happened when I first installed Arduino about 2 years ago and I gave up then.

(Fraser Wallace) #2201

Well, I spent about 6 hours checking, deleting Arduino couple of times including all directories, found a Arduino forum with many things found including altering java settings. Tried deleting all java and reinstalling and rebooting PC. Also tried through a proxy server. The final result is now I haven’t got any esp8266 boards and can’t get any to download.

(Dan) #2202

That sounds very frustrating. Do you have another computer that you can test with? If not, have you tried logging into your computer with a new account/profile and trying again? If nothing else works, it sounds like you may need to clean install windows.

(Richard Gross) #2203

I am trying to find a way to put a power sensor into the somethings via ST_anything. I have been able to read a SCT013 current transformer using the OpenEnrgyMonitor using the EmonLib.h library. could a sensor type created to monitor power from the SCT013?

(Dan) #2204

That’s a good question, and one that I’ve tinkered with a little myself. Reading accurate values of a CT (current transformer) is not a trivial thing to do.

Can you explain what your end goal is? Maybe there is a simple way to achieve what you’re trying to do without a bunch of complicated power monitoring software.

If accurate power readings, tracking, and trending are important to you, I’d recommend getting an IoTaWatt device ( The creator of this device has been working hard on this device and software for a few years now. It is all Open Source, so you could actually build one yourself. However, I gladly handed over my money for one as I believe 1) he deserves to be compensated for his work and excellent support AND 2) his device is safety rated for NA and EU.

If you really want to use the EmonLib, I’d recommend you just use my “SmartThings…” communication libraries to integrate an Arduino sketch with SmartThings. ST_Anything is designed for more general purpose devices. I believe the timing requirements for monitoring a CT are pretty tight. ST_Anything is not designed for that. ST_Anything uses the “SmartThings…” libraries behind the scenes for all communications with the hub. It is pretty easy to use, assuming you’re a coder.

(Richard Gross) #2205

This project started out as a way to monitor my washer and dryer. I have an esp8266 with a water sensor, for leaks, a bmp280 in the outlet duct of the dryer to monitor temperature, humidity , and pressure to determine when the dryer is done. I also have a motion detector to turn on the room light and a DS18B20 temperature sensor for ambient room temp (just because I could). To determine if the washer is done I have an Aeon Labs DSC06106-ZWUS power monitor and when the current drops close to zero the washer is assumed to be done. I would like to put the washer function in with the other sensors and hence my looking at adding a CT to the st_anything.

The emon.lib seems to have only two parameter, the pin number and a correction factor. I am guessing to integrate this with st_anything is would need to create polling sensor and add this in. Is there one of the existing polling sensor libraries that would be a good start for this.

(Dan) #2206

I believe you could do this with ST_Anything, since you’re just looking for an ‘on’ versus ‘off’ result. I would suggest you start with the PS_Voltage.h and .cpp files as a starting point. Try just polling the CT connected to an Analog Input pin to see what kind of results you get (without the emonlib.) You might get lucky.

Internally to the PS_Voltage class, you could start modifying the code to perhaps smooth out the signal since it will be cycling at 60Hz. You’re just looking a a continuous period of time where the voltage does not change to know the washer is ‘off’. If the voltage starts changing, then you can send an ‘on’. I would recommend sending naming your new polling sensor a F(“switch1”) name in the constructor. Inside the code, only send data when the state changes and send “on” and “off” instead of the raw voltage. By doing this, ST will receive either “switch1 on” or “switch1 off” and create a Child Switch device which will have nice “on” and “off” states for readability.

That last bit may be a bit confusing… Let me know when you get to that point if you still have any questions.