Instantly share code, notes, and snippets.

Embed
What would you like to do?
Read string from Arduino
/**
* Read From Arduino
*
* Author: urman
* Date: 2013-03-14
* Revision 2014-07-10
*/
// for the UI
metadata {
definition (name: "Read A String", author: "urman") {
capability "refresh"
}
// simulator metadata
simulator {
for (int i = 0; i <= 100; i += 5) {
def str = i.toString().collect{new BigInteger(new Integer((byte)it).toString()).toString(16)}.join('')
status "${i}": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A${str}2E30"
}
}
// UI tile definitions
tiles {
valueTile("refresh", "device.refresh") {
state("refresh", label:'${currentValue}',
)
}
main "refresh"
details "refresh"
}
}
// Parse incoming device messages to generate events
def parse(String description) {
log.trace description
def result = createEvent(name: "refresh", value: zigbee.parse(description)?.text as Double)
log.debug result?.descriptionText
return result
}
@jeremykoerber

This comment has been minimized.

jeremykoerber commented Apr 12, 2017

Hi,
I have a working arduino project that uses a waterproof temp sensor to check the temp of my hot tub and turn off the outlet if it overheats. I'm now trying to add a ThingShield and use this device handler to display the current temp in a tile. I have the ThingShield connected in the ST App, and I've added this device handler via the IDE and set the ThingShield to use it. Unfortunately, the tile always shows "--". In my Arduino sketch, I'm already sending the temp to the serial port as a string every 30 seconds, and I can see it fine in the Serial Monitor. Is there something I need to add to my sketch in order to get that temp value to be picked up by this device handler so that the value shows up in the ThingShield tile? Any help would be greatly appreciated! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment