Announcing the "ST_Anything" Arduino/ThingShield Project

Ajay,

I have added your addition to the ST_Anything GitHub repository, hacks and all! :slight_smile:

I don’t have time to go through it in detail to make any improvements, however I also didn’t want to forget about your contribution to the project. Hopefully others will find it helpful as well.

I did modify the comments sections to reflect the correct file names and to give you credit for the work.

Thank you!

Dan

Had a question about v2.9 that was posted. Github mentions “Added Arduino OTA support for ESP8266” but I’m not seeing any change in the example sketches or the libraries to support OTA. Can you give me a nudge in the right direction? Do we have to incorporate the OTA code from Arduino into the sketch from ST_Anything? Is there a version of a library where the info is located? Any first steps you might be able to give would be greatly appreciated.
Thanks again for this. I currently have 5 ESP8266 devices running throughout my house performing different functions. Saved me SOO much cash and no batteries to replace!

All of the Arduino OTA changes are located in the “SmartThingsESP8266WiFi” library. I noticed my test NodeMCU was more prone to lockup’s after the OTA Update feature was added. I did some research and found an updated version of the ArduinoOTA.cpp file was available which prevents lockups.

Here is the post in the more current ST_Anything thread that details the patch.

Thanks so much for the info!

Hi Dan!

Thanks for the ST_Anything! I use it on several devices and works really good!. I have started a new project to control mye ventilation system at home. It needs 3 relay’s to control speed. 1 for low. 1 for medium and one for high. When selection one of speeds the other relays needs to turn of. This I have managed to configure. The one thing I can not figure out is to get a fan control in SmartThings. I would like to use the standard control so I can use it with Action Tiles etc.

Can you point me in the right direction?

1 Like

I’ve been trying to find the same thing!!! Can’t find it anywhere. I’ve had to just use the 4 relays as separate devices which makes it so cumbersome.

I answered this question in the newer thread


Only comment would be that it would have to accept 4 pins. High, Med, Low and Off.

Dan,
I’ve finally got the ST_Anything working with nodemcu. Now I want to implement this pulse counting flow-sensor. Can you give me some pointers how to integrate it into the flow?

thanks,

Chin

I’m going to have to think about that question
 No one has asked for that device for years
 What ST Device Capability do you think matches best with a flow meter? Perhaps a simple Voltage Measurement capability?

I’ll try to dust off that code and see if I can get it working on the ESP8266 platform. It may take me a little while to find some free time. Feel free to remind me in a few days if I don’t get back you.

I think power device is closest. liters/minutes is like Kwh. Power meter also counts pulses typically. Many power meters will send out a pulse of light for every KW consumed. For the flow-sensor, a pulse is generated for every X liters of water flow. So counting pulses, every Y seconds is what’s needed.

@cslee - I was able to get this working very quickly.

I created a new “Child Power Meter” Device Handler, and updated the “Parent_ST_Anything_Ethernet” DTH accordingly. Please add/update your ST_Anything Groovy code accordingly (easiest to just use the GitHub integration if available to you.)

I have also revised some of the Arduino code to work with the ESP8266 platform. Please update your 
Arduino\libraries\ST_Anything folder with the new version of “PS_PulseCounter.h” and “PS_PulseCounter.cpp”.

Finally, you’ll need to add a device to your ST_Anything Arduino sketch.

  • be sure to add “#include <PS_PulseCounter.h>” at the top of your sketch, near the other include statements.
  • add a “#define PIN_PULSE D5” type of statement for whatever PIN you choose to use.
  • add a " static st::PS_PulseCounter sensor1(F(“power1”), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);" statement in your setup() routine. Read the header file comments to see what all of the arguments are used for. NOTE: You must use the name “power1” in order for the child device to be created!
  • add a " st::Everything::addSensor(&sensor1);" statement in setup() to make sure ST_Anything knows about your new sensor device

Have fun! Please let me know if everything works as expected or if you have any issues.

1 Like

Sorry, I just saw this. I’ll give it a try asap.

1 Like

Dan,
I updated the arduino libraries and DHT. I removed the device in ST and added it back. However I dont see the child power in ST. The water has disappeared in ST.

Here’s the device handler:

In arduino sketch, I used the ST_Anything_multplies_ESP8266 and modified it with:

#include <PS_PulseCounter.h> // Implements a pulse counter

#define PIN_PULSE D5

//static st::PS_Water sensor1(F(“water1”), 60, 20, PIN_WATER_1, 200); // comment out this
static st::PS_PulseCounter sensor1(F(“power1”), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);

st::Everything::addSensor(&sensor1); // left this alone

Anything I’m doing wrong?

thanks,
chin

Sorry pasted the wrong DHT

Chin,

My sketch uses the following lines to declare the pulse counter and it works fine. Did you update the Parent Ethernet DTH as well? Did you publish it? Did you remember to go into the new Parent Device on your ST Phone App and configure its settings (i.e. MAC address, IP, and Port) ?

  #define PIN_PULSE                    D5  //digital input to count pulses
  static st::PS_PulseCounter sensor4(F("power1"), 120, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);

Dan,
Thanks. It was the Parent Ethernet DTH which did not get published. It appears in ST now. I’ll do more testing with the flow sensor now. I’ll let you know how it goes.

thanks,
chin

1 Like

Dan,
It is working. The power registers some value when pulses are detected. A few seconds later it goes to 0.
How can I get two measures out of it. One is total cumulative pulse which can be reset (much like kWh in power meters) and another which measure pulse/minute (much like watts). Each one will need a scaling factor to adjust the value to (gallons) and second to gallons/hr. It much also be nice to have a days since reset for first measure.

thanks,

Chin

Chin,

You’re going to have to probably modify the Child DTH to add that additional functionality yourself. I’d rather leave the Arduino code as simple as possible. You should be able to modify the existing ‘Child Power Meter’ to create an accumulator and reset capability, along with scaling factors/algorithms.

For an example, take a look at my ‘Child Temperature Sensor’ as it allows for a user select F/C conversion, as well as a temperature offset. You’ll see these as User Preferences near the top, and then later where these values are used to adjust the raw incoming data before the final value is updated.

To get pulses/minute, simple change the 120 to 60 in the device declaration in your setup() routine.

static st::PS_PulseCounter sensor4(F(“power1”), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);