Arduino + ST to control multiple Relays

@Javid_Mamedov

Javid,

OK, your explanation helps a lot. I do have one question though. Why does pressing the physical pushbutton connected to the Arduino send a signal back to the ST cloud, instead of simply turning on the relay locally? The act of turning on the relay locally within the Arduino, causes an update to be sent back to SmartThings, thereby updating the status of the switch-type tiles in the ST Phone Application UI. These changes can also be acted upon by other SmartApps if desired.

Would that design be sufficient?

I already have a version of a ST_Anything_Relays.ino Arduino sketch running that handles 16 relays on an Arduino MEGA. I also have a working ST_Anything_Relays.device.groovy custom Device Type running within SmartThings (which is installed once per Arduino) which shows all 16 relays as ST switch-style tiles within the one device. That was the easy part (relatively speaking.)

I am currently working on a Virtual_Switch custom Device Type (which will be installed up to 16 times) as well as a custom Smart App (one of my multiplexer apps) that will link the Arduino’s 16 digital outputs (i.e. the physical relays) to the 16 Virtual Switch devices. The 16 Virtual Switch devices allow you to activate each relay via “normal ST SmartApps”.

Basic bi-directional flow is as follows:

ST_Anything_Relays Arduino Sketch
to
SmartThings Shield
to
ST Hub
to
ST_Anything_Relays SmartThings Device Type (visible on phone app)
to
ST_Anything_Relays_Multiplexer SmartThings SmartApp (installed via phone app)
to
Virtual Switch SmartThings Device Type ( 16 of these) (visible on phone app)
to
"Normal SmartApps" that can turn on/off switch devices (if not needed, virtual devices and multiplexer not required)

Does this make sense? It can be very confusing at first, and even more so when you start coding it up! :smile: It took me a very long time to figure this all out the first time last year when I made my first Arduino/ThingShield project.

I am pretty good at writing the Arduino code and the Device Type code. The SmartApps (heavy duty groovy code) is not my specialty. I am trying to find a more elegant way to create a multiplexer app without having to copy and paste the same code 16 times with minor tweaks…

Dan

1 Like