Multiple Devices on One Shield

Is it possible to create multiple devices, and main tiles, from one arduino shield? Anyone have an example?

Tia,
Twack

Definitely interested in the answer to this as well. Just got my ThingShield and looking to do some cool stuff with it.

subscribeā€¦
Wish I could just follow a thread without posting a useless comment!

You can - I subscribed to this thread by hitting ā€œsubscribeā€ in the upper right of the first post. :slight_smile: Got the 2 updates without having to have made this post.

ā€¦ feeling stupidā€¦
thanks!

Now Iā€™ll shut up and wait for an actual response!

It is not currently possible to have one device in separate tiles or more than one device in one tile. We have some stuff on the drawing board for it right now.

The most difficult part is making each ā€œsub-deviceā€ individually accessible, but weā€™re workin on some cool stuff for it!

@urman, to clarify with an example I was hoping to build, letā€™s say I have one arduino+thingshield connected to two garage door openers. These garage door openers are controllable individually via relays attached to the arduino.

Are you saying that itā€™s currently not possible to control each garage door opener individually, despite the fact that they are separately controllable via the arduino itself?

@csader that should be fine. I meant two separate devices in a single tile or one device into two separate tiles. So if you had a 2 relay setup on the arduino you wouldnā€™t be able to have two distinct ā€œdevicesā€ but you could have one device with the functionality to control each relay individually.

@Andrew - so this 1:1 (device:tile) is a little screwed up via the shield I see.
It IS interesting that the multi is four (or more maybe) devices if I include the battery.
As the Keymaster I am expecting you to have us something we can use.

@philsst, If Iā€™m understanding @urman correctly, with the shield you can in fact have a ā€œSmartShieldā€ device that has multiple tiles within it for each of the attached controls. This is essentially the equivalent of the SmartMultiā€¦one device, multiple functions (tiles).

@csader, I do not read it that wayā€¦ ā€œone device with the functionality to control each relay individuallyā€.
So I read it as Shield = 1 device = 1 tile but device can have Relay A, Relay B, Relay A&B; something maybe like ā€˜modesā€™.
I would expect ā€¦ like the Multi ā€¦ has multiple devices as tiles.
The Keymaster will tell us ā€¦ certainly if I am in error.

Hopefully this helps clarify what can currently is done and my original question:

I have the ST Shield with two relays. One for Garage Door #1 and the other for Garage Door #2. I currently installed a device type (switch) that has two tiles. The main tile, and if I click the little gear, I can see the main tile as well as a sub-tile. The main operates relay #1 and the sub operates relay #2. It works both of the doors, but for door two you have to click down to see the sub-tile or button.

I also have a multi-sensor on each door that I edited the device types to be garage door open/close sensors. Which is cool as it shows whether its opening or closing during the activity and the final end state.

What Iā€™d really like is one device tile for each door and itā€™s included multi sensor.
a) The tile/button should show the current state of the door open/closed/opening/closing
b) If I touch the tile it should act like a momentary button (turn blue) and fire the command to the shield
c) show the changing state and then the final stop state.

More confusing than ever probably.

Twack

@twack; correct confusion. For myself, I am not trying to ā€˜out-guessā€™ SmartThings as being a ā€˜DA-Thingā€™

@andrew - not sure Iā€™m following you. How would you configure the setup to control the relays individually?

I took the on/off/hello (example) device and modified it.

Main on/off tile/button sends the shield a formatted message saying either ā€œonā€ or ā€œoffā€. (notice both call the ON() function)
The sub hello tile/button sends the shield a formatted message saying ā€œhelloā€.

My ON() function sets pin 7 high (relayRight), and
Hello() function sets pin 8 high (relayLeft

//*****************************************************************************
// GarageDoorOpener (modified on/off/hello
//
// Waiting to get better device type this works for now
//*****************************************************************************

#include <SoftwareSerial.h>   
#include <SmartThings.h>
#define PIN_THING_RX    3
#define PIN_THING_TX    2

SmartThingsCallout_t messageCallout;    // call out function forward decalaration
SmartThings smartthing(PIN_THING_RX, PIN_THING_TX, messageCallout);  // constructor

int ledPin = 13;
int relayRight = 7;
int relayLeft = 8;
bool isDebugEnabled;    // enable or disable debug in this example
int stateLED;           // state to track last set value of LED

void setup()
{
  // setup default state of global variables
  isDebugEnabled = true;
  
  // setup hardware pins 
  pinMode(ledPin, OUTPUT);     // define PIN_LED as an output

  pinMode(relayRight, OUTPUT); 
  pinMode(relayLeft, OUTPUT); 

  if (isDebugEnabled)
  { // setup debug serial port
    Serial.begin(9600);         // setup serial with a baud rate of 9600
    Serial.println("setup..");  // print out 'setup..' on start
  }
  
  smartthing.shieldSetLED(0, 0, 1); // set to green to start
}

void loop()
{
  // run smartthing logic
  smartthing.run();
}

void on()
{
  smartthing.shieldSetLED(83, 1, 0); //Orange for right door
  Serial.println("In On Func");
  smartthing.send("Door1 Start");
  digitalWrite(relayRight, HIGH);
  
  delay(2000);
  digitalWrite(relayRight, LOW);
  smartthing.shieldSetLED(0, 0, 1);
  smartthing.send("Door1 Done");
}

void hello()
{
  smartthing.shieldSetLED(1, 0, 0); //red for left door
  Serial.println("In Hello Func");
  smartthing.send("Door2 Start");
  digitalWrite(relayLeft, HIGH);
  
  delay(2000);
  digitalWrite(relayLeft, LOW);
  smartthing.shieldSetLED(0, 0, 1);
  smartthing.send("Door2 Done");
}

void messageCallout(String message)
{
  // if debug is enabled print out the received message
  if (isDebugEnabled)
  {
    Serial.print("Received message: '");
    Serial.print(message);
    Serial.println("' ");
  }

  if (message.equals("on"))
  {
    on();
  }
  else if (message.equals("off"))
  {
    on();
  }
  else if (message.equals("hello"))
  {
    hello();
  }
}

We too are looking for functionality as twack is.

We are developing a project with an 8-relay module board connected to an Arduino. We want one main tile (RV Control) with actual sub-tiles under that (Relay 1, Relay 2ā€¦). Each sub-tile is controllable and reports status. Hope we can get this functionality. We have the modules, the Arduino and a ST Shield and have begin breadboarding and coding (Smartthings in an RV).

Jim (and Malcolm)

J&M,

The functionality you want exists already. The arduino on/Off (example) has a main tile with one sub. You would just need to modify that to add more sub tiles and matching functions.

Iā€™ve got a sprinkler controller with 8 or 16 stations (depending) on model) that Iā€™ve hooked up to ST. Runs great.

What I want is to have a separate main tile for each relay like it is its own device (garage door button)

Happy Hacking!

I have three switches hooked up to relays and a ThingShield. This is what Iā€™m hoping for:

-A separate tile for each switch (under the device menu)
-The three switches to be controllable independently by SmartApps in response to events

Anyone have any ideas on how to make that happen in the device type code?

Iā€™m working on a similar project to control two garage doors. I have a main garage, and a smaller side garage.
From the main screen, you can tap the icon to control the main garage door. tapping the gear icon diggs into the device details. From there you can control either the main garage door, or the smaller side garage.

Door open/closed status is set using some window sensors. They are mounted to the door and report back the door open/close status.
opening and closing the door is done with a simple relay

Itā€™s about 75% complete right now, Iā€™ll post a project with the code and screenshots when Iā€™m done.

Iā€™m not sure what the limit is, but Iā€™m sure I could use this to control dozens of garage doors(or anything really)

1 Like

@jlboygenius, FYI there is already a project to accomplish what youā€™re doing. Not saying yours isnā€™t valuable as a separate project, just take a look and see before you post, that way there donā€™t end up being a bunch of duplicate projects that accomplish the same thing:

http://build.smartthings.com/projects/garagedoor/