Problems with multiple comments to ThingShield?


(Jonathan) #1

I’m logging (via serial port) every command my shield receives. I’ve noticed two things:

  1. When two commands are sent very close together (i.e. within 2 seconds of each other), one of them (typically the last one) is never received by the shield
  2. When two commands are sent simultaneously (or as near as possible pressing two buttons on the iOS app) one command comes through twice, the other never arrives

Anyone else having the same issue? Any workarounds?

Cheers, Jonathan


(Andrew Urman) #2

@badgermanus what device handler are you using?

Software serial is notoriously slow. We’re looking at expanding our library right now as well. Which admittedly needs some work.


(Jonathan) #3

I’ve been using my own deviceType: http://build.smartthings.com/projects/arduino8wayrelay/

I had set it up so that the state in SmartThings only flipped to ON after the Arduino reported that it had successfully turned on the relay. I did this by having states like this:

standardTile("relay1", "device.relay1", canChangeIcon: true, canChangeBackground: true) {
   state "on", label: '${name}', action: "RelayOff1", icon: "st.switches.switch.on", backgroundColor: "#79b821",  nextState:"switching"
   state "off", label: '${name}', action: "RelayOn1", icon: "st.switches.switch.off", backgroundColor: "#ffffff",  nextState:"switching"
   state "switching", label: '${name}', action: "RelayOff1", icon: "st.switches.switch.on", backgroundColor: "#ff8d00"
 }

And then reporting the state back from the Arduino code like this:
smartthing.send("relayon0");

It seems the call to smartthing.send is what’s causing the problems. If I comment it out everything works just fine. The presence of debug code (Serial.print) doesn’t seem to affect things.

Cheers, Jonathan


(Jonathan) #4

I take back my previous comment - without the smartthing.send it is much more reliable, but I’m still getting a few missed commands, which I recall being the reason I put the feedback mechanism in place to start with…

Cheers, Jonathan