Spark Core and SmartThings

Spark Core and SmartThings

Here is a sample application using :spark: and SmartThings.

The :spark: application uses DHT22 Temperature and Humidity Sensor for Temperateure and Humidity value and defines two Spark.function to read these sensor values.

The SmartThings application defines a new Device Type and uses :spark: APIs to read the sensor values. The device type specifies the “Polling” capability but only sometimes it is working (Raised the issue and I am awaiting SmartThings reply on this)

Reference and Inspiration


  1. Create a new device type ( with Name: Spark Core Temperature Sensor, Author: Krishnaraj Varma, Capabilities: Polling Relative Humidity Measurement Sensor Temperature Measurement

  2. Create a new device ( with Name: Your Choice, Device Network Id: Your Choicem Type: Spark Core Temperature Sensor (should be the last option), Location: Choose the correct location, Hub/Group: Leave blank

  3. Update device preferences, Click on the new device to see the details. Click the edit button next to Preferences and Enter the Device ID and Access Token

  4. Open the Mobile Application and add the newly created device, click refresh to see the Temperature and Humidity values


enter image description here

Things to do

  1. Support :spark: OAuth authentication
  2. Support multiple :spark:s
  3. Create SmartThings Cloud Connected device for Spark Core.

Can you suggest more?


Do you still need the smart hub to make this work? Or does it work by itself with just the app?

@james211, It is not using SmartThings Hub since it is only HTTPS calls to Spark Core. I didn’t try it before, but when you asked I disconnected my Hub and waited to become inactive, then I tested it and I am getting the sensor values. I am not sure whether you will be able to use the IDE and create a Device Type without a hub since I already activated my Hub.

Hmm…interesting. I would be curious since the hub costs $100. If that was eliminated it could be quite handy.

1 Like

Nope… we’ve been down this path before and the outcome is always “No hub, no developer acct.” Cool stuff though if you have a hub. :smile:

1 Like

Yes, that’s what I doubted. Thanks for the clarification @BDub!

@krvarma, when I try your code, in the Smatthings logs I get: Forbidden @ line 112

The core ID and access tokens are correct. Any ideas?

@peekay123, I have added two inputs in the Preference section, we have to input Core ID and Access Token after adding the device from phone from My Devices->Spark Temperature & Humidity Device->Preferences->Edit.

Can you check this?

@krvarma, did that. At one point I added a log.debug line after line 112 to see what “temperatureParams” was so I could understand the error. Just to be sure, I deleted and rebuilt the My Device and it worked! When I removed the log.debug line from the code and tried again, it would NOT work. I tried deleting and recreating the device but no luck. Same error I started with.

@peekay123, both of my :spark:s are not working now, one cannot switch to Spark server after connecting to Local :cloud: and another keep on blinking white. Let me fix these issues and debug the issue.

Meantime cloud you please delete the retrieve humidity portion and try, just to make sure that the second HTTP call is not creating any problem for the first one.

If you guys want, you can try my SmartApp for the Spark Core as well. I’m using httpGet instead of httpPost and I’m authenticating in the URL instead of the body.

1 Like

@krvarma, I did what you suggested and it gave me an error. Then I used curl to test the functions and found the core was not responding so I reflashed it and now everything works. I hate these types of bugs!! :stuck_out_tongue:

And thanks NickW for the offer. I like the idea of using functions and @krvarma, I believe a single function could be called for both values and more. I want to explore remote controlling a relay via the function and an extra button. If either of you has ideas, please share :smile:

1 Like

@peekay123, good to know it is working. Actually I tested it now and it is for me, also tried deleting the device and creating a new one just to see any issues.

@peekay123, regarding single function you mean combining both temperature and humidity in a 32-bit integer and return?, that’s a good idea!

And regarding the remote controlling, are you thinking of button press from SmartThings device and talk to :spark: I made a sample 2-3 months back but I didn’t publish it. Now I just put it in GitHub (

@krvarma, I did this combination on a different project and thanks for the on/off control code. I will be playing with that for sure. :stuck_out_tongue:

1 Like

Hi guys,

I’m a little late to this party, but I’m looking for some help in what seems to be the opposite flow of how you all have been using the two platforms. Instead of writing a SmartApp to control the spark, I would like the spark to be able to

  1. Simply issue on/off commands to SmartThings, or

  2. Launch existing SmartApps

Assuming this is possible, can anyone give my box car a push or point me to any relevant urls?

Thanks as always.

Take a look at this.

Thanks @NickW That looks like it will get me where I need to go.

@techbutler, since calling HTTPS calls from Spark Core is not possible you can use some intermediate you can use any intermediate server, may be you can use Sparknode, to listen to events from Spark Core and call the SmartThings API calls. Spark team is working on a feature called WebHooks which will make it easy to for HTTPS calls from Spark Core. This is in beta and hopefully will be releasing soon.

I have done similar to this previously but didn’t publish.


Thanks for that important reminder @krvarma , I’ll check out Sparknode. I’ve been following webhooks…hopefully “soon” is not wishful thinking.

I’m still working on webhooks, and we’ve got like 50 people in the beta. :slight_smile: Mostly right now it’s blocked by needing extra documentation, so I’ve gotta write that first, but you’re welcome to join the beta in the meantime if you want! :slight_smile: