Arduino + ST to control multiple Relays

@Javid_Mamedov, @chaospup, @zuperman4ever, @Todd_Whitehead

Gentlemen,

I have completed the development of the 16 Relay ST_Anything project and all of the necessary code can be found at https://github.com/DanielOgorchock/ST_Anything.

If you’ve never used ST_Anything, follow the basic instructions in the ReadMe to get started. You’ll want all of the Arduino code most likely, especially all of the libraries as I have recently broken them out into smaller subsets to simplify things for users who do not need everything at once…

You’ll also find some new Groovy code that you’ll need. Two Device Types (ST_Anything_Relays.devicetype.groovy and VirtualSwitch.devicetype.groovy.) Use the ST_Anything_Relays device type for your Arduino MEGA which should be running ST_Anything_Relays.ino.

After you get the Arduino and its Device Type working smoothly, you can move on to installing (by hand in the IDE) up to 16 copies of the VirtualSwitch device type. Name them something easy like “Relay1”, “Relay2”, … “Relay16”. Then load/publish the STA_Anything_Relays_Multiplexer.smartapp.groovy as a new SmartApp in the IDE. Add this smartapp using your phone. During its initialization, select the 16 virtual switch devices and the Arduino. Now you have glued the virtual devices to the individual relays in the Arduino.

Review the Arduino sketch as it has PIN assignments for both the 16 relays (digouts), plus 16 local pushbuttons (digins). The pushbuttons were requested by Javid. Using them will update ST with the change to the relay state. Pressing the local pushbuttons will toggle the relay. I have used the Internal Pullup feature of the Arduino so wire your buttons to the pin assigned and to ground.

The relays are set up to turn on a digital output (i.e. supply 5V) when triggered to the On state. Also, the default state for all 16 relays is LOW when the Arduino powers on. These two settings can be changed in the sketch when each relay’s EX_Switch object is created. No changes to the library code should be required.

I have also had to update some of the ST_Anything library files to support all of the features and to improve performance and data integrity. Please download the latest and greatest version of the files.

Have fun! Gotta run!

Dan