Lutron RadioRA (version 1) and SmartThings saga. (Prologue)

arduino
lutron
project_lighting

(Fred Chavez) #1

Hi Folks,
Has anyone else put this together for RadioRa (version 1) yet? Inspired by this post

I’m about to start and am completely new at any of this. I have to start with the hardware pieces.

I ordered the RS232 shield and it came with two sets of pins, the single sided pins and the double sided kind with pins on the bottom, connection points on the top.

The picture when I ordered looked like this

So I figured I’d have to solder them in. Somewhat troubling as I never really soldered a lot and it has been well over a decade since the last time but you know… why not work it out. OK. So, order that and Aduino Mega 2560 and the Smartthings shield. So far so good. Then when the RS232 shield came, one set of pins was already attached. Of course it was the ones I don’t need :confused: and now I have to desolder which I have no practice in.

But thanks to the internets, there are plenty of places to watch someone do that. So back to giant internet retailer name here and order solder-sucker. Since I was browsing around I figured, I should get some decent solder, and man, that holder looks cool, and I don’t know if my soldering tip is worth a damn so that tinning mixture might be nice to have and some pre-fab jumper connections will make life easier and… and… and…

So stuff on its way. I have the Mega2560 the RS232 shield, and the Smartthings shield. I’ll start the desolder and solder in correct pins process next weekend.

I understand I’ll have to load a local IDE for the Arduino code stuff. (I understand that is referred to as a sketch I think) and then I think I have to load something onto the Arduino board using their IDE, make some device types in the Smartthings IDE and then load the Gateway app in the SmartApp section of the IDE. Some jumpers get jumped and then… well… i don’t know. :slight_smile:.

This is all a set up for me trying to figure out how to do this with the Pentair pool controller.

I figure this might be entertaining for you guys so I’ll post updates here unless someone thinks I should move this somewhere else.

Anyone have any tips or tricks, I’d be happy to hear them.
Thanks,
Woo


#2

Sounds like an ambitious project! :sunglasses: Most of the ThingShield experts hang out in the following thread if you want ideas on any of those issues:


(Fred Chavez) #3

Cool. Thank you. I think this one is just standing on Bruce’s shoulders but i’ll have to actually do something when I try to write an app that queries the Pentair controller and then controls the pool. How cool would it be to turn the pool lights a certain color when someone is at the door or the garage door opens because someone is home. Or to turn on a fountain based on someone actually being in the pool.

Coolness.

That’s a few months out though. First, on to the RadioRA thing.

I can’t tell you how cool this will be if I can get it to work. I was on the edge of ripping out all the Lutron stuff and replacing it. This makes so much more sense.


(Fred Chavez) #4

OK, so doing some reading while I’m waiting for my flight and I see the Mega doesn’t work right with the ThingShield out of the box. So I understand I have to use a different library by Ogiewon:

Which I get from here

I think.

And I copy the entire contents of that github into the libraries folder on the PC where my IDE runs…

I think…

Then I’ve got to figure out the jumpers in order to use the hardware Serial I/O instead of the software serial device.

On to researching hardware serial ports on the Mega.


#5

Ask in the thread you linked to, you’ll get the quickest answers there. :sunglasses:


(Fred Chavez) #6

JD,
No problem. I’ll definitely post questions there if I get confused, I’m just sort of logging a running commentary on what I’m doing in case it might help someone figure out something similar one day.

:slight_smile:


(Dan) #7

Fred,

Yes, you’ve got the correct idea. The only part of my github repo you need for your project is the SmartThings library. I designed this to be backwards compatible with the official ST ThingShield library. It will use SoftwareSerial if you use an Aduino UNO, just like the official library. On an Arduino MEGA, It defaults to using HardwareSerial. Just follow the directions buried in my ReadMe on GitHub as it details the wiring requirements.

You’ll also need to use the extra constructor we added when using HardwareSerial ports on the MEGA.

Here’s the pertinent info from the ReadMe…

The Arduino MEGA should use the new Hardware Serial Constructor since it has 4 UARTs. To use Hardware Serial on “Serial3”:

The “Serial3” port uses pins 14(Tx) and 15(Rx). Wire a jumper Pin14 to Pin2 and another from Pin15 to Pin3.
Use the new Hardware Serial constructor passing in the Arduino’s pin 14/15 UART (i.e “HW_SERIAL3”)
SmartThings(SmartThingsSerialType_t hwSerialPort, SmartThingsCallout_t *callout);
Note: SmartThingsSerialType_t is a new enum declared in SmartThings.h. For the pin 14/15 UART, pass in "HW_SERIAL3"
Make sure the ThingShield’s switch in the “D2/D3” position
Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it.

Dan


(Fred Chavez) #8

Wow, thanks! I’m trying to wrap my head around “Hardware Serial Constructor”. Would that be the concept of jumping the connnections between the Mega and the RS232 shield that Bruce mentions?


(Dan) #9

The term “constructor” is an object oriented programming term. The SmartThings Arduino library has some examples where your Arduino sketch initialized the library using a “constructor” which is designed for an Arduino UNO. My version of the library adds another “constructor” that is used with a MEGA. This new “constructor” properly initializes the ThingShield library to use the MEGA’s hardware serial port on pins 14/15, which you must wire to pins 2/3 respectively.


(Fred Chavez) #10

OK. So for now, I am going to assume that Bruce’s code takes this into account. I’ll see if I can learn from what he did.

Hopefully I can figure it out so as I’m trying to figure out the Pentair interface I can use it.

Thank you for explaining this to me.


(Fred Chavez) #11

OK so had a chance last weekend between trips to “fix” my RS232 Shield. I started out with this guy here:

Cool, but as you can see, this thing isn’t going to be able to take a jumper in pins 2 and 3. It did come with the other set of pins and it was a good excuse to pick up some soldering stuff.

I figured I want to use some good solder and after some poking around I found some old fashioned completely dangerous lead filled solder. It probably has asbestos fibers as well.

Some tinning powder and the solder sucker and i’m ready to go.

It took a lot longer than I thought it would to remove the solder well enough to release the pins as I couldn’t get the hang of the solder sucker operation enough to pull enough solder off the pin before it cooled back down. I had to get it out in order to totally free the pin.

What worked for me was to apply gentle but firm pressure on the pin using needle-nose pliers as I melted the solder.
As you may have guessed this totally destroyed the original pin but I wasn’t planning on keeping it anyway.

The solder sucker was great at clearing out the extra solder out of the through-holes but only after the pins were out.

After i got the original solder out I used the old “tack one pin first then set it down and level it” trick.

You can see here the one pin with solder and the drunken alignment.

In the end it came out better than I expected and yes, I did clean up all that crazy flux. Then I had to move on to checking connectivity.

I started to do continuity tests to make sure I didn’t have some sort of accidental solder connection between two pins. Everything checked out fine but as soon as I connected Ground to the power pins, I got some connection. What drive me crazy was that it looked good but I didn’t trust my soldering skills and since these two pins were next to each other, the only thing that made sense at the time was that there was a short.

Turns out that capacitors, particularly those without a charge can show something other than infinite resistance. This is what threw me.

On to loading sketches and figuring out stuff. :slight_smile:

Woo


(Fred Chavez) #12

OK so plugged everything in and tried to load up Bruce’s sketch.

Of course it didn’t work but I was hip enough to see that the .h wasn’t found. OK, now to get Dan’s .h and cpp in there.

Followed Arduino instructions and managed (somehow) to stumble into it being included. Loaded the code, added the SmartShield to my system, remembered that I had to load the code onto the shield, and loaded the virtual dimmer device handler and the on/off switch handler.

Then, a total misunderstanding led me astray for a couple of days. I saw that the app would use the ZMP query and then figured it would get that from the Lutron system to map out the devices, ask me to name them, and then figure out if they were dimmers or switches automatically and then set the correct command to send across the serial cable.

As stated earlier, I know almost nothing of this thing called coding and so I totally got this wrong. When the app behaved as programmed, I couldn’t figure out why the commands weren’t showing up.

Some experimentation and caffeine later, the app totally works. Just not as I expected. This isn’t because there is a problem with the app, but I was expecting something way more complex and the simplicity of this stumped me. :slight_smile:

  • Part 0.5 desoldering the pins and getting the stack to not catch fire? Complete
  • Part 1.0 getting the Bruce’s code loaded and the correct device handlers set up. Complete
  • Part 1.5 Getting Arduino/SmartThings Shield combo working with power and talking to SmartThings. Complete It lights up and does the cool rainbow light debug thing that tells me I’m connected correctly
  • Part 2 loading the smartapp and getting it to control lights. Working but only after I was able to figure out that Lutron wants to have an assigned number for each light.

Here’s where it will get interesting as the code needs to be modified to account for more than 32 dimmers.

More to come.


(Fred Chavez) #13

For as rock solid, clean, elegant and wonderful the original RadioRa system is, there are some quirks. One of which is a hard limit of 32 devices. They never expected anyone to want more than 32 zones (Lutron-talk for switch (dimmer or otherwise).

It may sound excessive to have more than 30 controllable lights especially if you don’t live in a mansion, but consider that lighting design is less about the main light in a room and more about the accents and you can see how those 32 zones get consumed very quickly.

Phillips Hue has done a great job of bringing the idea of accent lighting to people who never thought of it before.

My house is not very big, but I’m easily over 45 light switches. Just the kitchen has five different controllable light sources. A few more rooms and a few accent lights in each and you’re getting more zones than a single system can handle.

So when people with really big houses or the burning desire to control everything wanted more they came up with the idea of bridging two systems using a device called the Chronos Clock. Well, that’s not the official name.

The Chronos System Bridge and Timeclock was crazy expensive when they first came out. Lutron figured they’d add value by adding a sunrise/sunset schedule by longitude, cool phantom buttons, diagnostics, ability to bridge two 32 zone systems together and, most germane to this post, an RS-232 interface.

Since I don’t know anything about coding I enlisted the help of a friend of mine who knows more than me and we set about looking at Bruce’s code. First to figure out how to install, config and operate it, and then to try to figure out how to modify it so that it can control the bridged system.

Here’s the key
The way the Chronos handles this for integration purposes is by looking for a “,S1” or a “,S2” at the end of a serial message sent to it. That’s it.

Even better, if no suffix is attached to the serial message, it assumes “S1” and so Bruce’s code worked perfectly for all the lights upstairs.

How do we get ,“S2” to show up for all the second system lights? Hell, how do we even get the virtual devices to get created? How would we even ask the user for the information on which lights are on the second system?

Well, we’d have to figure out how Bruce did it in the first place. Stay tuned faithful reader, more to come.


(Fred Chavez) #14

If you have a RadioRa set up and you want to integrate it with SmartThings, you’ll be particularly interested in this post. In order to get to where we can get a bridged system to work, let’s walk through the setup and the app startup.

If you’ve made it through this much of this thread, you probably have the IDE (Integrated Development Environment) set up for SmartThings. If you don’t know what this is you can get an overview here:
http://smartthings-documentation.readthedocs.io/en/latest/introduction/introduction-to-the-ide/index.html

The TLDR here is that you use the IDE to load custom app code (Apps that control things), custom device handlers (code that tells SmartThings how to control things), and to view a nice live logging feature that helps you understand exactly what is happening.

You’ll need to attach the SmartThings Shield to your Arduino board and have it powered on so you can add it to your hub. When you add it, the device has no capabilities and just exists as a device. It is the device handler that decides what it does and how it does it.

This is what the SmartThings Shield looks like this when it sits on top of the Arduino:

On a side note, I didn’t have a picture of my SmartThings shield but one of you did so I stole it. So, full credit for that photo goes to that guy.

So, with your SmartThings Shield added to your hub and the IDE ready to load code, The first thing you do is, of course, get some code to load in there. Follow the link to Bruce’s post at the top of this thread and there you’ll find a link to his Github. Github is a place where people can conveniently share and work on code. Just click on each file and copy the text into the right IDE section.

You’ll need the application code “Lutron Gateway” (which goes in your SmartApps) and you’ll need the three Device Handlers (which unsurprisingly go in “My Device Handlers”). One for the Virtual Dimmer, one for Switch and one to run the SmartThings board that interfaces with the Arduino. You’ll also need to load the Arduino Sketch file onto the Arduino board but that is beyond the scope of this post but there is an important twist.

DO NOT USE THE STANDARD SMARTTHINGS LIBRARIES
Use these from OgieWon


You copy that entire folder into your libraries folder in your Arduino directory.

Load the sketch, load the app, load the device handlers and then stick the RS-232 shield on top of your little SmartThings sandwich and now the fun can begin.

Configuring the App up next.


#15

Always great to see detailed project descriptions. With pictures! :sunglasses: Looking forward to seeing more reports as they’re available.

One small but critical point… It is not the device type handler that tells the device what to do. That would be a Smartapp or some other function manager.

Instead, what device type handlers do is simply translate the request from the function manager into the specific format that the device requires. And translate any communication messages coming back. Basically the same as a printer driver.

The handler gives you a mechanism for telling the device what to do, but you still need a function manager to decide what instruction to send when.

Just wanted to mention it because people may get rather confused if they read other resources in the forums and in the official docs about device type handlers.

Also, SmartThings draws quite a hard line between “smartapps” (code written to run on the smartthings platform) and “apps” ( code that runs outside the SmartThings platform but may communicate to it in various ways, such as SmartRules or the official SmartThings mobile app). I’m not 100% sure, but I believe that your references to “app” would probably more accurately be references to a “SmartApp.”


(Fred Chavez) #16

JD,
Excellent point. I oversimplified this a great deal. I appreciate the clarification and the response. I get the feeling I’m going to need a lot of that on these. :smile:

I’ll need to ask for some help as well but I figured it’s better to tell the whole story first because I know there must be other RadioRa owners out there who lament how dumb our lighting system is but like me, wouldn’t change it because of it’s innate reliability and, for lack of a better term, grace.

With Bruce’s code they can have both smart control and reliability. It’s awesome. I’ve dreamed of “Alexa, turn on kitchen island.” and now I have it. I’d like other Lutron folks to see how cool that really is so I was planning on going over basic setup and function and then detour into code modification to work with a second system.

Thank you again for the feedback.
Woo


(Fred Chavez) #17

Don’t forget to jumper the pins so you can take advantage of the Mega’s hardware serial port. I know how you do this as pictured below. I don’t know why :slight_smile:

If you’ve managed to load the app and device handler software correctly, and published all three to yourself, you should see Lutron Gateway when you go to the Marketplace under "My Apps"
Select the the app and you’re greeted with this screen.


Simple enough, just fill in the blanks and get going right? Well, let’s see. The gateway should be right there since you’ve loaded the code but it might not be if you didn’t publish it to the actual Smartthing device.

And now it gets tricky.

When you select the Remove Button, any momentary switches are listed. This concerned me because I had no idea what this was used for. (I still don’t but was able to calm my superstitious howling by creating a virtual momentary switch in the IDE then selecting that.

OK hyperbolic crisis avoided.

Now the section titled “How many Lutron devices?” seems easy enough. And this is where the madness began. You see I have a habit if selecting the “Done” in the top right corner. When you enter the number of devices, and press that done you get the classic red bar of “You’ve Made A Mistake”

In the interest of saving someone all sorts of time let me tell you. If you’re thinking about pressing the blue “Done”, don’t. The only “done” you should be selecting is the one that shows up on your virtual keyboard. When you press the keyboard “done” it triggers the app to build the rest of the screen that gives you the fields to fill in.

I’m not proud of the fact that it took me two days to, out of desperation, try the keyboard “done” but I reveal this fact for any other RadioRa folks looking to set this up.

Once you hit the right done, you’re presented with a set of fields for each.
Lutron Command and Device name #x

Note, Lutron knows you want to set a dimmer level when it receives the serial characters SDL and for a switch it is expecting SSL.

The actual formats for the serial strings are:
For a dimmer SDL,NN,XXX where N is the device number and X is the brightness level from 0 to 100.
For a switch SSL,NN,YYY where N is the device number and Y is either the word OFF or ON

In “Lutron Command,” you’re going to enter “SDL,” and the number of the device you are working on. So for device 1, you’d enter “SDL,1” and “SDL,2” for device 2 and so on. If device 3 is a swtich, you will enter “SSL,3”

You’ll see in the example below how the numbers correspond.


If you fill these in and you have less than 32 dimmers and switches, you’re done. Enjoy the coolness that is “Alexa turn on kitchen cabinets” or whatever you’ve called your lutron lights. You’ve been waiting for this for a long time and it’s awesome.

Next up, modifying the code to handle a second system.


(James Hsu) #18

what happened? did you finish the project? i have a radio ra system also. would love to integrate smartthings.


(Fred Chavez) #19

Hi Sorry James. Life got in the way but I made some progress. I had three phases planned:

  1. Get the existing code (developed by user Bravenel), try desperately to understand it, decipher it, and modify it - I needed to tweak it so it could run a bridged systems via a ChronosClock device.
  2. Tweak it to be able to run devices on the second system that was bridged.
  3. Take what I learned about RS232 communication methods and apply it to the controls for my pool.

With the help of a buddy, I got mostly through Phase 1. I can copy the code somewhere so you can mess with it. It’s pretty cool and works for the first zone. The system (if bridged) adds a “System” indicator to the RS232 string sent back to Smartthings. So instead of SDL,NN,XXX the RS232 message is SDL,NN,XXX,ON,S1.

I cannot figure out how to get the code to read / interpret (or send) the S1 or S2 place in that string. This still works though for System 1 because the system assumes no suffix means “System 1”.

If you have less than 32 lights amd use a ChronosClock to just do timings and virtual/home switches, then you’d be fine. You will need the RadioRa 232 interface thing or a ChronosClock.

There is a funky thing though, when you use an actual wall switch, what Lutron calls a Local Zone Control, it sends a LZC,01,ON ,S1.
LZC = Local Zone… fine
01 = Zone ID (switch number) is 01… fine
ON = ok, this is nice to know … kind of OK
S1 = code doesn’t read this anyway.

The problem is with the “ON”. The Lutron switch goes on to whatever the last dimming level was but doesn’t specify that in the string and the code says "Oh… wow you want that ‘on’? OK, let me just set it to 100% brightness "

So that’s kind of irritating but works well enough to make sure all the lights go off with a night routine, or whatever it is.

Even for someone who is not a programmer, I know the code is embarrassing for a few reasons, little debug entries that are still floating around, likely very inefficient instructions, and of course, stubs of attempts at figuring stuff out.

But, still, if you want to look at it or take it completely, let me know. I still want to figure out the second zone, but I’m going to need a lot of time to figure it out. I don’t know anything about object-oriented anything. Going through it is like watching a Shakespeare play where my brain never clicked over to understand what they were saying. It’s all just barely out of my grasp. Maybe someone will take a look at it and say “silly Woo, you just need to do this…” and it will be awesome, but right now, it’s less than awesome. :slightly_smiling_face:

Apologies for the slow reply. Let me know and I’ll figure out some github thing or something.

Fred