How to make arduino ethernet shield to send POST commands to hub

I’ve been trying to create an Arduino device type that will place the hub into a listen mode for arduino commands. I have several very inexpensive 433 Mhz motion sensors and contact sensors that interface to an arduino. Then the Arduino is sending a command to a Maker channel on IFTTT, and the recipe turns on a simulated light on smartthings. Then I have a smartapp in smartthings that polls the arduino via the ethernet shield when that simulated light is turned on.

Obviously this method is heavily dependent on multiple services functioning as intended and will have issues. The round trip time is actually less than 5 seconds normally. However, it would be MUCH easier if I could figure out how to have the arduino simply send the hub commands locally.

Can anyone help me get started on the local network access from my arduino to the hub?

One option is a LAN connected device type -

The other alternative is to use ZigBee with the SmartThings shield -!/products/smartthings-shield-arduino
SmartThings Arduino ThingShield Docs


The ZigBee shield would be cool, but I already have several ethernet shields from existing projects. Plus the SmartThings shield is only available from one source and hasn’t always been in stock. Which is not a complaint against ST, I love ST. BUT It should be fairly simple :slight_smile: to have an Arduino using an ethernet shield to make a LAN connected Device.

My WISH is that smartthings would support a LAN RESTful interface. Arduino’s are much better at GET and POST than implementing the full solution in LAN devices.

Does anyone know if the hub can accept REST GET/POST from LAN devices? I got really interested in this approach from where the guy can press a button and his arduino updates the smartthings cloud server. However, I seemed to always get a redirect notice for not using HTTPS. SO I find myself wanting a LAN REST endpoint. Any ideas?

You can setup GET/POST but it has to go through the OAuth process, meaning its going out to the internet and back, not just on the local LAN. I haven’t been able to get it to work over LAN only. Here is the documentation about how to do it with the OAuth interface:

This is for communication from your device to the hub. To use GET/POST from the hub to your device, you can do that over the LAN.

OK that would be an option, Is it possible for the OAuth exchange to take place without being in an HTTPS environment?

Yes, your callback url does not actually need to be a real url at all. You can catch it and just extract the token. Unless you are talking about the SmartThings url, that needs to use https, but I wouldn’t expect that to be a problem.

Yes the smartthings URL. As far as I know, arduino uno/mega can’t send a GET/POST to an HTTPS it can only do HTTP. SO even if I have the token, I would still require the “” to allow HTTP (no S) connections.

ALSO-> WOW BRICE thanks for the quick replies and good info! This community is awesome. Thank you.

Oh, I didn’t realize that. I don’t think you’ll be able to use this method then.

Here is the approach I have right now.

  1. Arduino Mega with Ethernet shield sends a REST GET to a thingspeak thinghttp app.
  2. The thinghttp app sends the parameter on to SmartThings encased in HTTPS.
    This works really pretty well. However, should be possible to do this EASILY with smartthings alone and not require a 3rd party.

I fully appreciate ST’s desire to keep security at the forefront. The way I am maintaining security is by using the GET request to turn on a Virtual Switch. Then I have a SmartApp that then sends a Refresh/Poll command to a LAN device. When my arduino receives an RF based event it will send the request to thinghttp and that gets relayed to smartthings, the Virtual Switch turns on and the SmartApp will trigger. The smartapp then polls my arduino for the actual event.

Has anyone had any success on implementing either the SSDP or the mDNS/DNS-SD on a simple microcontroller like an Arduino? That is my next goal.

Any luck with this approach? I managed to have the hub set a GET request to my arduino with ethernet shield and have it parse the json response that the arduino sends in a custom device handler. My next step is to use the pollster smartapp to poll it continuously.

Once I have that working, I’m going to start on some type of upnp implementation based on the wemo switch.

Pollster is amazing! What sensor information are you getting from your Arduino? I use Pollster and love it for a lot of my sensors (I have very few/no battery powered devices getting polled). The problem that I ran into with Pollster was its occasional lockup that would exceed the timeout threshold for a SmartApp which almost always coincided with SmartThings failure to execute refresh/poll in a timely manner. Then I’d have to go open the settings for Pollster so the app would reinitialize with all the proper event subscriptions. I haven’t notice this happen for some time, so maybe SmartThings’ improvements have gotten that all sorted out. Pollster works great for temperature, but the minimum update time is pretty slow for event driven sensors, i.e. a door opening to turn your light on in about a minute.

To your actual question. Yes and No. I like examples, and do best by reviewing working items and then adapting them to my use case. I’ve been using as my example. I do have a raspberry pi, and I’m working on getting my arduino to do the same thing as the RPI in this example. Then make it more applicable to what I want. So far, I’ve only been able to get an arduino mega to recognize the initial broadcast and respond with its notice to the ST hub that it exists. That’s as far as I’ve gotten, and that really isn’t very far.

You should definitely keep me updated about your progress using the WeMo example

I’m monitoring the doors on my house, so realtime would be nice, but I will settle for a 1 minute delay. I used to have the arduino set to send a post to pushingbox and get an alert that way but I’d really like to avoid the extra hop outside my network.

My plan is to skip the whole discovery and subscription messages and just hard code it all. Hopefully that will work. I’ll let you know how it goes.

I’m using an arduino uno clone with a w5100 ethernet shield clone. I started with the wemo example and had it working with the arduino. (minus the discovery portion, everything hardcoded) I then realized that smartthings doesn’t really care about the headers or the content, it appears that it just compares the device network id and the mac address of the device and if they match, that device handler gets the message.

So now I have a working example, I can hit refresh on the device page in the app and it will send a GET request to the arduino and it will respond with json data that has the status of the door. In addition whenever the door opens or closes it send the same json data as a POST to the hub. I’m going to clean up the code a bit and I’ll post it on github.

After that I’m moving on to esp-01 board i have and see if i can get it to work there.

Charles this is great stuff! I was also able to compete the SSDP discovery process. Although, I don’t honestly think its best, fixed IP addresses just make much more sense. Great work!

@Charles_Schwer , thank you very much for your Arduino Smartthings Home Security example. It saved my day when I tried to convert my existing web based Arduino Garage Monitor to work with Smartthings.

Sadly your code is no longer on GitHub.

If anyone interested, my code (with few added features and modifications):

This looks very interesting. i haven’t had much patience with my Arduino yet, but it looks like it is time for me to start. I am looking forward to trying this.

In case you’re still interested, I recently revised my Arduino ST_Anything and SmartThings libraries to work with ethernet connections to the ST cloud via the hub, as decribed by @Charles_Schwer in this thread. I owe Charles much thanks for his work. Unfortunately, I believe he has moved on past the SmartThings platform.

Take a look