Announcing the "ST_Anything" Arduino/ThingShield Project

@ogiewon thank u for coming back. I don’t suppose you could perhaps provide a bit more detail guidance ? Is there a way for me to just add some basic code to EX_Dimmer to drive a WS2812b LED strip to display a simple colour say white and where would be the best place(s) in EX_Dimmer to insert the code piece? I have not coded since college… i did C++ back then, that’s like 20years ago… but i could try borrow other peoples code and copy paste it in the right place of EX_Dimmer if you could provide a bit more detail to support me  Basically what is needed for a basic colour display like blue or white (without any fancy patterns) is to define only one pin on the NodeMCU for the signalling of the WS2812b LED strip and feed the signalling with the right small bit of code. Then we would need a basic LED strip on and off control DH with an ON OFF tile.
(Edit) BTW i cannot find EX_Dimmer in your git hub repository inside ST_Anything in the libraries. But found 2 files called EX_Switch_Dim.h and .cpp but have no clue what to do exactly.

I wish that u made it though at least to trigger the basic colours of a WS2812d led strip like blue, white, red and green and dimming them. The fancy patterns in those vids come from libraries like fastLED and Neopixel etc.

Still using mine … been swamped with other stuff so I haven’t migrated yet over to the new architecture

Hi Ken, Thanks for the update, let me know when you are ready

Ben

Sorry for the confusion on the file name for the dimmer… It is EX_Switch_Dim.h and .cpp

In the void EX_Switch_Dim::writeStateToPin() function you could change the code to call whatever LED library you want. You could also change the void EX_Switch_Dim::writeLevelToPin() function to interpret the dim levels into requests for specific LED sequences, however this routine only gets called once for each time the dim level changes.

You’d want to use these two files as a starting point for a new C++ device class. I’ll keep this on my todo list, but no promises of a timeline.

Here is a link to the .cpp file.

1 Like

I know some folks still frequent this thread instead of the new one… I’ll just leave this here in case you have interest in using the ESP32 with ST_Anything.

1 Like

Hi All…

It’s me again… like a broken record …( Old School )

If anyone has an Arduino ThingShield available for sale, please let me know
still looking for a couple units.

Thanks again

Ben

Hi Dan
I have 3 dth11 in my house one of those is on the dealing, can I substrat 2 degre from it on the readout?

Thank you

Steph,

If you’re running my latest version of Parent + Child Device Type Handlers, you now have the option to adjust the temperature offset by going into the temperature child device and adjusting its settings (gear icon).

This is the old thread. You may want to check out the newer one which is being kept up to date.

Hi all… trying to update my UNO and Thingshield to include new devices. While compiling the new code, I am getting an error (same error happens when I compile the example code).

ST_anything:170: error: ‘pinRX’ was not declared in this scope

 st::Everything::SmartThing = new st::SmartThingsThingShield(pinRX, pinTX, st::receiveSmartString);      //Use Software Serial

I’ve added the Smartthings and ST_Anything libraries…so not sure why I am getting the error. Anyone have any ideas?

Kevin,

Sorry for the issue. I have just uploaded a revised version of the ST_Anything_Multiples_Thingshield.ino sketch to my GitHub repository. This version will compile without the error for the missing #defines for pinTX and pinRX.

However, this example obviously is designed for an Arduino MEGA, not an UNO, due to the large number of devices it exemplifies. You will need to remove many of the device definitions from the example to reduce the memory footprint of the compiled sketch. Otherwise, you will receive a “sketch is too big” error when compiling for the UNO.

Thank you for the feedback, and again I am sorry you ran into this issue.

Dan

That worked. Thanks for the quick reply and fix, Dan!

1 Like

I’m interested in using ST_Anything to connect to a commercial alarm system via serial and parse received commands via rs232 to update SmartThings. Would it be possible and where should I start? Any serial examples?

I would suggest google your “alarm system and arduino” some one may done the code for it. Then you may able to modify the code to work with stanything. I have a esp8266 monitoring the keypad bus of by alarm system.

I’ve done a lot of googling. In fact that is how I found ST_Anything. I’m trying to connect to a Interlogix NX-6 via a NX-587E NetworX Virtual Keypad Module. Sounds similar to what you are doing. But I haven’t been able to find anyone that has integrated that hardware to SmartThings.

@ogiewon I talked about adding OTA support months ago and I finally got around to doing a pull request for it. I did it the easy way though meaning a lot of code will need to be added to any sketch that wants to use it. The better way would be modifying the library files to keep the code mobile.

1 Like

Thanks! I’ll take a look at your PR when I can find some free time. It is a very busy travel week.

If your handy writing custom code, you may want to simply use one of the “SmartThings” Arduino libraries in the ST_Anything GitHub repository. This permits you to write your own SERIAL to SmartThings Bridge device and have total control. The ST_Anything library uses the SmartThings library to perform all network communications between the microcontroller and the ST Hub/Cloud. Sometimes, it is easier to bypass ST_Anything and just use the SmartThings library since you’re not really interfacing with traditional Arduino sensors.

Another ST user wrote a similar bridge to integrate his old lighting system with Smarthings via an RS232 Serial interface. He kept the Arduino code very simple, and just used it to pass Serial Strings back and forth between a ST DeviceHandler/SmartApp and the physical controller device. The true brains of his system was in his SmartApp. If you want to take a look, I believe you’ll find his old code in the following repo. Be forewarned, he no longer is an active ST community member. So I would not expect too much assistance from him. His example uses the old ThingShield, which is no longer sold by ST. My “SmartThings” libraries support a variety of micrcontrollers/networking options, in addition to the old ThingShield.

Hi Dan,
I’m actually trying to get Bruce’s software working now for RadioRA integration . The one problem I am running across is that I had to use a 5100 Ethernet shield instead of the original ThingShield. From my understanding his code was based on using the ThingShield. What do you think would be needed to be done to adapt his sketch to point to maybe your 5100 libraries? Maybe I’m not looking at it right? Any help would be greatly appreciated, thanks.

Ignore the ST_Anything libraries, and just focus on replacing The SmartThings library used in Bruce’s sketch with my version specific for the W5100 shield. You can use the examples found in the SmartThings library folder to see the differences between using the ThingShield and the W5100 Ethernet shield. The basic calls are identical, however the setup() function will be where almost all changes are required. Of course, you’ve got significant changes required on the ST Groovy side to change from Zigbee to LAN.

@jparent14 I took a few minutes to modify Bruce’s old Arduino sketch to work with my newer SmartThings… libraries. Be sure to download all of the new “SmartThings…” library folders from my GitHub repo to your local C:\Users\your_username\Documents\Arduino\libraries folder. Remove any old “SmartThings” library folder you might have to avoid any conflicts.

Here is the sketch, modified to work with a W5100 shield. Again, you’ve got some significant rework to do on the Groovy Device Handler side. You could user my ST_Anything_Parent_Ethernet device handler as a starting point, but you’re going to need to hack it up dramatically to remove a ton of unnecessary code. Use it more as a model for how LAN based network communications can be made to work.

Good luck with your project!

//*****************************************************************************
/// @file
/// @brief
///   Arduino W5100 Shield SmartThings / Lutron Interface 
//*****************************************************************************
//#include <SmartThings.h>
#include <SmartThingsEthernetW5100.h>

//#define PIN_THING_RX    3
//#define PIN_THING_TX    2

SmartThingsCallout_t messageCallout;    // call out function forward decalaration

//******************************************************************************************
//W5100 Ethernet Shield Information  CHANGE THIS INFORMATION ACCORDINGLY FOR YOUR NETWORK!
//****************************************************************************************** 
byte mac[] = {0x06,0x02,0x03,0x04,0x05,0x06}; //MAC address, leave first octet 0x06, change others to be unique //  <---You must edit this line!
IPAddress ip(192, 168, 1, 204);               //Arduino 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 hub information
IPAddress hubIp(192,168,1,149);               // smartthings hub ip                         //  <---You must edit this line!
const unsigned int hubPort = 39500;           // smartthings hub port

//Create a SmartThings Ethernet W5100 object
st::SmartThingsEthernetW5100 smartthing(mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, messageCallout);
//SmartThings smartthing(HW_SERIAL3, messageCallout);  // Hardware Serial constructor

bool isDebugEnabled;    // enable or disable debug in this example

void setup()
{
  isDebugEnabled = true;

  // set the data rate for the Lutron port
  Serial2.begin(9600);

  //Run the SmartThings init() routine to make sure the Arduino W5100 Shield is connected to the ST Hub
  smartthing.init();

  if (isDebugEnabled)
  { // setup debug serial port
    Serial.begin(9600);         // setup serial with a baud rate of 9600
    Serial.println("setup..");  // print out 'setup..' on start
  }
}

String LutronResponse = "";

void getLutronResponse()
{
  char ch = Serial2.read();
  if (ch == 0x0D)
  {
    if (LutronResponse == "") return;
    smartthing.send(LutronResponse);
    LutronResponse = "";
  }
  else if (ch != '!') LutronResponse += ch;
}

void loop()
{
  smartthing.run();
  if (Serial2.available()>0) getLutronResponse();
}

void hello()
{
  if (isDebugEnabled) Serial.println("Hello from ST");
//  smartthing.shieldSetLED(1, 0, 0);
//  delay(200);
//  smartthing.shieldSetLED(0, 1, 0);
//  delay(200);
//  smartthing.shieldSetLED(0, 0, 1);
//  delay(200);
//  smartthing.shieldSetLED(1, 1, 0);
//  delay(200);
//  smartthing.shieldSetLED(1, 1, 1);
//  delay(200);
//  smartthing.shieldSetLED(1, 0, 1);
//  delay(200);
//  smartthing.shieldSetLED(0, 1, 1);
//  delay(200);
//  smartthing.shieldSetLED(3, 2, 1);
//  delay(200);
//  smartthing.shieldSetLED(1, 2, 3);
//  delay(200);
//  smartthing.shieldSetLED(2, 2, 4);
//  delay(200);
//  smartthing.shieldSetLED(4, 3, 1);
//  delay(200);
//  smartthing.shieldSetLED(0, 0, 0);
}

void messageCallout(String message)
{
  if (message == "") return;
  if (isDebugEnabled)
  {
    Serial.print("Received message: '");
    Serial.print(message);
    Serial.println("' ");
  }

  if (message.equals("hello")) hello();
  else Serial2.println(message);         // send command to Lutron
}
1 Like