Thingshield dimmer?


(David Carter) #1

I’m new to ST, but have a good bit of experience with Arduino. I’m currently using the on/off shield example to switch a 12v light strip on/off via a MOSFET. So far so good, this works as expected.

What I’d like to do is add the switch level capability so I can dim the led light strip. The arduino side is easy using a pwm output pin to drive the MOSFET. I have a test sketch that does this, but what I’m missing is an example of how to drive this from the ST device type, passing the brightness % to the arduino sketch.

Thanks for any suggestions.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

All communication to/from the Shield Library is by plain ASCII text messages. So you can make up your own message to send in your Device Type Handler Command method for setLevel(x) use the example to send text “level:x” or whatever is easiest to parse in your Arduino’s script.

I could just give code, but hoping the hints are more fun?


(Dan) #3

Another option you may want to consider is hacking apart a Cree bulb to get its Zigbee communications board. Pretty low cost solution, especially if all you need is on/off/dim(pwm)…

And, you can still partner it with an Arduino if desired, as demonstrated below. Biggest limitation is that it is one-way communication only.


(David Carter) #4

Thanks @ogiewon for that tip. $15 for the Cree bulb vs. $35 for the shield is quite a difference. I’ll have to look into it in more detail. One-way only would not be an issue for my application. I have about 9 amps worth of the Supernight LEDs from Amazon under the rails of my deck, and also a much shorter (~2 A) string serving as a backlight to the new TV in the basement.

I’ve already invested in a couple of the shields, and have used the proto space on one to wire up the mosfet circuit to control the 12v DC LED strip, so will still move forward with the shield-based dimming device handler.


(David Carter) #5

@ogiewon - seems like ST_Anything_Dimmer would be a great addition to your awesome project? Pass in 0-100% from the device handler, scale it to 0-255 PWM range, and analogWrite() to a PWM-compatible pin to control the LED(s). Your project was one of the first places I looked to find this capability.


(Dan) #6

I’ll take a look at adding that capability to ST_Anything. Shouldn’t be too hard.


(Dan) #7

@David_Carter I have finished adding a new class to ST_Anything call “EX_Switch_Dim” which as the ability to control both a normal digital output (on/off) and a pwm output on the Arduino from SmartThings.

Everything has been loaded into GitHub at https://github.com/DanielOgorchock/ST_Anything/

You’ll need the new EX_Switch_Dim.cpp and EX_Switch_Dim.h files in your local copy of the ST_Anything Arduino library. Then grab a copy of the ST_Anything_Switch_Dimmer.ino sketch and add that to your Arduino sketches folder. Finally, grab the new ST_Anything_Switch_Dimmer.device.groovy device handler and add that to your ST IDE’s Device Handlers.

This should get things working pretty quickly. Let me know if you have any questions.

Dan