[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

Hi, trying to convert my Adafruit Feather MO board from Adafruit IO MQTT over to ST_Anything. The board has Cortex M0+ processor (same as Adruino Zero) and WINC1500 wifi. I’m using the <SmartThingsWiFi101.h> library. So the issue is how to get the ST Library to use the MO wifi pins over the SPI.

Here’s the pins that the previous working connection with Adafruit MQTT, Wifi101, and SPI librarys.

#2 - used as the ENable pin for the WiFi module, by default pulled down low, set HIGH to enable WiFi
#4 - used as the Reset pin for the WiFi module, controlled by the library
#7 - used as the IRQ interrupt request pin for the WiFi module, controlled by the library
#8 - used as the Chip Select pin for the WiFi module, used to select it for SPI data transfer

#23 - MOSI
#22 - MISO
#24 - SCK


You should be able to simply add the “WiFi.setPins()” function in your Arduino sketch’s setup() function. Just add teh call before the following line:

  //Run the Everything class' init() routine which establishes Ethernet communications with the SmartThings Hub


ST_Anything is designed to work with the WiFi101 shield’s default pins, as well as with the MKR1000’s default settings.

I was using “WiFi.setPins()” but had it outside the set-up loop. It compiles now and I can ping the board with static IP. Problem now is none of the child sensors are reaching the smart app. I have the parent device configured and showing up on the app. Serial monitor shows connection failure. But also say “SmartThingsWiFi101: Intialized” Does initialized mean is connected and ready to send data?

****** Attempting to resend missed data *******

ST_Anything Callback: Sniffed data = temperature1 -196.60
Everything: Sending: voltage1 2862.46failure. What in this tells me that its

***** SmartThings.send() - Ethernet Connection Failed *****

hubIP = hubPort = 39500

****** Attempting to restart network *******

Initializing WiFi 101 network. Please be patient…
Attempting to connect to WPA SSID: ATT444

Enter the following three lines of data into ST App on your phone!
localIP = 192.168xxxxxxxxx.
serverPort = 8090
MAC Address = F8:F0:xxxxxxxxx.
PASSWORD = xxxxxxxxxxxxxx
hubIP =
hubPort = 39500

SmartThingsWiFi101: Intialized

Are you sure you have the hub’s is address correct? Can you ping the hub with a computer on the same network?

Personally, I’d recommend picking up a NodeMCU ESP8266 board. They are very robust and reliable, and on.y cost about $10.

I have never gotten the WiFi101 based boards to run reliably for more than a day or two before they lock up. I even recently upgraded to the latest WINC1500 firmware and WiFi101 library hoping they would have fixed the issues, but my MKR1000 still locks up after a while.

I chose this board cause it has a uFl antenna connector so I could put an external antenna outside the metal enclosure and it has PWM. I was having some lock issues as well so I added some code to do a SW reset at night and that seemed to improve that situation. That was a year ago, now the ESP32 might be a better cost effective choice if I could find one with the uFl connector.

Anyway I got the child devices up by removing the device in ST IDE and phone then re-entering it.

1 Like

Now that the board is talking to ST, back to the topic I had a month a so ago. This controller has a Adafruit INA219 i2c current sensor. I need to get that current reading “current_mA” which resides in the sketch over to ST. The value is picked up in the Loop via current_mA = ina219_B.getCurrent_mA();

I played around with the “static st::PS_Generic sensor1(F(“generic1”), 60, 0);” option but could get it to work. Is there an example sketch using the Generic Library and polling sensor?


I wrote up the generic sensor to do exactly what you are trying to do, extend ST_Anything to other sensors that might not fit the mold of a current library. It should be pretty well commented in the library (PS_generic.h and .cpp). What couldn’t you get to work? Did you try adding a generic sensor without making any changes and see the child device get created with a default value of 15?

@vseven Good point, I’m completely overthinking this, I guess my question is simply how to code the toggle switch rather than momentary then. I have virtually no coding skills, I’m more of a smartthings/arduino script (kiddy) oldie

Thanks everyone.

I’m not familiar with every part of ST anything so I will let Dan answer this better from that side but on the physical side if you have a 3 way set up going to a input on the microcontroller then it would work like normal: you turn one switch on and the input would be closed, turn the other switch on and the input would be open. You’d be using a regular 3 way switch set up with no main power going through it. Then based on a change in that input you turn on or off the output. You wouldn’t care whether the input is actually on or off, just that it has changed states. This way you can also control it through smart things. The only goofy part would be you could technically have both your 3 way switchs turned on and the light would be off one day or could be on another day since the position of the switchs no longer really matters.

@Dan_Lumbard @vseven

In order to add the “Momontary Button” local control capability, I did not modify any part of ST_Anything. I simply added some local processing code into the example Arduino Sketch that I uploaded to my Github repo.

Please simply modify the very simple logic to suit your specific use-case. This is really a good exercise for learning how to modify Arduino code. Everything that you need to change should be within the Loop() routine I have pasted below. I have not made any changes to this code from my original example. Please give it a shot as you aren’t going to hurt anything… :slight_smile: Just change the logic for what type of input trigger will cause a change of the output. (Hint: look at the “if (nCurrentVal == LOW)” line of code :wink: )

void loop()
  //Execute the Everything run method which takes care of "Everything"

  //Add User Customized Loop Code Here (instead of modifying standard library files)
  //---Begin Push Button execution section---
  //Loop through the pushbutton array
  for (nBtnIndex=0; nBtnIndex < MAX_PUSHBUTTONS; nBtnIndex++) 
    nCurrentVal = digitalRead(nBtnPins[nBtnIndex]); // read the input pin   
    if (nCurrentVal != nBtnVals[nBtnIndex][1])      // only act if the button changed state
      lngBtnLastMillis[nBtnIndex] = millis();  //keep track of when the button changed state
    if ((millis() - lngBtnLastMillis[nBtnIndex] >= MIN_DEBOUNCE_TIME) && (nBtnVals[nBtnIndex][0] != nCurrentVal))
      nBtnVals[nBtnIndex][0] = nCurrentVal; //keep current value for proper debounce logic
      if (nCurrentVal == LOW)    //only care if the button is pressed (change LOW to HIGH if logic reversed)
        strCommand = swArray[nBtnIndex]->getName() + " " + (swArray[nBtnIndex]->getStatus()== HIGH?"off":"on");
        Serial.print(F("Pushbutton: "));
        swArray[nBtnIndex]->beSmart(strCommand);  //Call the beSmart function of the proper executor object to either turn on or off the relay
        strCommand.remove(0); //clear the strCommand buffer
    nBtnVals[nBtnIndex][1] = nCurrentVal;  //keep last value for proper debounce logic
 //---End Push Button execution section---

I can not get any of the example sketches to load. this is the error I am getting…

Arduino: 1.8.5 (Windows Store (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, 9600, 4M (3M SPIFFS)”

Build options changed, rebuilding all
C:\Users\dscri\Documents\ArduinoData\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-ar: unable to rename ‘C:\Users\dscri\AppData\Local\Temp\arduino_build_394450/arduino.ar’; reason: File exists

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Any help would be appreciated

A few troubleshooting questions:

  1. Will other ‘Non ST_Anything’ sketches load to the ESP?
  2. When you say load, does it only bomb when trying to load it to the ESP, or will it not even Verify?
  3. Can you load a generic sketch to any other controllers like an Uno?

I have the same setup as you across the board, and just loaded all successfully and all is running perfectly, so the Repo and the IDE version are fine.

Let us know. on the steps above.
The only answer I have seen around other forums is completely blowing out your existing install of the IDE and reinstalling it fresh, with a fresh install of the ESP libraries as well. LAST RESORT!!!

I just wanted to Thank You for keeping this project alive. Wifey bought a new motorized and lighted Christmas decoration and I am out of smartplugs. Well of course she wants it to turn on at the same time as our ‘Christmas Theme’… OgieWon to the rescue!! I spun up one of my ESP12’s and a relay, loaded up your latest code and was automated in no time flat. Thanks Again Man!! Have a GREAT HOLIDAY!


@JohnnyFRX Glad to hear it is working for you! Enjoy it!

@derek_scritchfield Let’s start with the basics… Are you able to compile a simple example sketch (unrelated to ST_Anything) and get it to run on your NodeMCU ESP8266 based board? Start with the ubiquitous “Blink” example sketch and make sure your development evironment and USB cabling are in working order before attempting to add ALL of the ST_Anything libraries and example sketches to your computer.

it will verify and load the blink example ( that’s the only one that I Tried)
and no it will not even verify any of the ST_Anything examples
the only boards I have are a couple different nodemcu’s…
I uninstalled aurdino and deleted all associated folders then set rverything back up
I am still getting the same results

What about trying/testing one of the more technical built-in sketches like WiFi?

Just wanted to share a quick video of the ST_Anything in action. Thanks again Dan!


Looks great! Thanks for the shout out!

@derek_scritchfield can you please show me a screenshot of your C:\Users\username\Documents\Arduino\libraries\… folder? Sounds like you might just not have the ST_Anything libraries installed correctly.