SmartThings API Library for Arduino IDE


I created a Smartthings API library for use with Arduino IDE to programming various microcontrollers that will interact with the Smartthings platform

The ST_API library provides the following functionality:

  1. Execute a Rule
  2. Execute a Scene
  3. Get device online state
  4. Get device status
  5. Send commands to a device:
    1. Turn on or off
    2. Set dim level
    3. Turn on & set dim level
    4. Set color temperature
    5. Set hue and saturation
    6. Refresh (for supported devices)
    7. Send arbitrary json command

The library should work with any microcontroller that supports SSL clients and has sufficient memory. There are several example sketches and all have been successfully used with the ESP32 and MKR WiFi 1010 and have complied with several other Arduino microcontrollers.

See the repository read me for additional information about the library and how to use the examples

Check out the library at: GitHub - rambo350z/ST_API: Arduino Library for interacting with SmartThings API


Hi, I’m very new to the Smartthings hub-resident Edge driver concept, so I may be asking a dumb question…it’s OK if I am. The APIs in this post seem to be able to send a control command to a Smartthings enabled device (like if I want my wifi-enabled Arduino to turn a switch on), and the APIs also seem to receive a response from the Smartthings enabled device (like a temp sensor). If I want to press a button on the Smartthings app and have it send a command to the Arduino, are there any tutorials how to do that? Thanks.

The SmartThing (ST) API does not send out events, the Arduino has to poll SmartThing API to detect a change, such as a temperature or switch state change. The quickest I was able to poll was 2-3 seconds with most of this time taken to receive the response from ST (commands to devices seem to execute in < 1 second). Realistically I wouldn’t poll any faster the once every 5 seconds.

If polling at this rate would work for you, the ST_Device_Status sketch example in the library should give you a good starting point. The code below is what gets status from a switch (GetDeviceStatus() function) and pulls out the switch status from the resultant ST json response (CapValue() function).

You will need to get a ST Personal Access Token (PAT) and update the example sketch with the PAT, location id and device id for the switch in the ST platform

if (!GetDeviceStatus(Some_Switch, interval, Some_Switch_pm, false)) return;
interval = 60; //get status every minute
//set variables to state of various device capabilities
char switchState[4] {‘\0’};
CapValue(switchState, “{"switch":{"value":”, ‘,’); RemoveQuotes(switchState);
Serial.print("Switch is "); Serial.println(switchState);