[SOLVED] Pairing, discovery and device type for a custom Arduino recliner project?


(Lee) #1

I’ve had a pretty good night with the device type and SmartApp coding but now I want to go to Marketplace for instance, click Connect New Device and have it actually discover my device and know what it is.

I haven’t seen a single piece of documentation or code samples, GISTs etc that show how this is done.

Please help me pair with the shield and the app knows what it is.

Thanks,
Lee


#2

What device is it?

Per their standards , both Zigbee and Z wave devices transmit a self identifying device class, and the hub then uses that at the time of pairing to assign a device type. (The terminology used is somewhat different, Zigbee calls them “fingerprints”, but the basic concept is the same.)

Alternatively, you can tell the hub what device class to use in the mobile app before pairing, or if the device just joins as a generic “thing” then you can change the device type after pairing is complete through the IDE.

Smartthings should be able to pair with any certified Z wave device, or any Zigbee device using the zigbee standard home automation 1.2 profile.

It will not be able to pair with most devices using other zigbee profiles or that have an additional proprietary encryption layer.


(Lee) #3

It’s a custom recliner device. I want to be able to recline my sofa without reaching down to the buttons. I want one touch close of one or all etc. the device is referred to in the code as device.recliner.

just bought 4 MPU-6050 Module 3 Axis Gyroscope Accelerometer Gyro Sensor for Arduino. I’m hoping this will allow me to support resets and allow me to have a % in a PRIMARY_CONTROL.


#4

OK, if I understand what you’re saying, you’re building an Arduino device to control your recliner and now you want it to talk to smartthings. Is that correct?

If so, you have to also add an RF antenna to your Arduino device because that’s how the smartthings communication will take Place.

The easiest way to do that is to purchase the smartthings thingshield device which is just an Arduino addon with the antenna. So that gives you the hardware part of it. You will actually be pairing the thingshield with the smartthings controller since it’s what’s doing the RF part.

http://docs.smartthings.com/en/latest/arduino/

You still need the software side to manage the communications. There is a community built piece for this called the ST_anything which is very popular.

You may have already installed the thingshield and used the ST_anything device type, I wasn’t quite clear on that…

In any case you can read more about it in the following topic:

If you ask questions in that topic, the author and other makers can probably get you moving along on your own project.


(Lee) #5

Yeah a friend brought two back from the states for me recently. I wish he’d brought more now but I’ve plenty of colleagues in the US I can get them sent to and they just sent them over to me.

I’d have thought it would discover the devices out of the box. I’ll have a look a ST_anything and have been meaning to.

Thanks for your help :slight_smile:


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #6

The ThingShield only has one Device Type signature, I think, so you have to manually attach your custom Handler to the ThingShield Device instance IDE.

Pairing is done via the Button on the shield (not the reset button).


(Lee) #7

That’s absolutely rubbish. We should be able to connect to the hub using a device type name and if the smart app is installed off you go… use another identifier like your namespace and application name and it prompts you to install the SmartApp and then off you go again.

I really do think this is a really poor aspect of the product along with the documentation :@


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #8

The ThingShield is meant for prototyping only.

Its target Customers are Developers for whom assiging the Custom Device Type in the IDE with a few clicks is easy and even preferable…


#9

Sorry, but that’s just not how zwave or zigbee work. Those are both third-party standards, not created by SmartThings. In order to operate as a more open platform and be able to work with many more types of devices, made by many different manufacturers, SmartThings includes a certified zwave controller and a certified Zigbee controller.

In part for security reasons, and in part to enable you to run multiple networks in a relatively small physical space, both of these protocols require that the end device (in this case the thingshield) and the controller exchange certain information at the time a device joins the network. That includes the device’s unique ID, which is assigned in the firmware for Zigbee devices. It also often includes the exchange of an encryption key. And it requires the human to verify their authorization to make network changes by pressing a button on the device itself. (A process which is way faster when you’re installing 300 sensors or lightbulbs in one building Than typing in the name for each one.)

So you can’t just type in a name into the IDE because the device itself needs to do the exchange with the hub.

I know most people are used to the Wi-Fi world where you typically have a dozen or so devices and the human does a lot of the network set up, including typing in all the passwords for each device.

Zigbee was designed for sensor nets where there would be literally thousands of battery-operated devices and the whole idea was to have the network basically set itself up, define its own message routes, and route around missing members if a particular sensor was off-line getting its batteries changed or whatever.

So the devices are engineered by the manufacturers, to that third-party standard, to identify themselves to the controller of the network that they are joining, and the controller and the device will work out among themselves the best routing paths.

Again, nothing to do with SmartThings, except that SmartThings has agreed to play by those rules. But this is the reason why a battery-operated motion sensor can move from one brand of controller to another and the human really doesn’t typically have to do much more then put in fresh batteries and push a button.

You really appreciate not having to individually maintain all the message paths ( or typing and serial numbers) when you get up to about two dozen devices. :sunglasses:

ALTERNATIVES TO MESH

Apple believes that the typical consumer will not be able to make the mindset change to working with a mesh network after a lifetime of experience working with Wi-Fi. So for homekit, they decided to use a combination of Bluetooth and Wi-Fi In a bridge and tunnel set up. The individual devices will cost much more than Zigbee devices and use a lot more energy. And you will have to type in an individual serial code anytime you want to add a new device to the network.

So there are alternative protocols that work exactly as you suggest, and you may prefer to use one of those,– – but then you likely won’t be able to design your own physical devices like you’re doing with your recliner right now. And you’ll pay a lot more in both money and energy draw.

For myself, I use solar power and so am fairly sensitive to energy usage of my devices. It doesn’t mean I don’t have televisions and all that, but I like low-energy home automation whenever it’s available. So I really like mesh protocols.

But different people will make different choices based on Their own circumstances and preferences. It doesn’t make one good and another bad, it just means they serve different purposes.


(Lee) #10

What to people generally do then? Make it a ZigBee or Z-Wave device?

EDIT

That would add £100 to the cost of each unit being made so another £400 if i go the ZigBee/Xbee Pro route using the official Arduino Xbee Shield. Plus any future ideas which are flooding in!!!


(Lee) #11

Ok I had a chance to catch up on some e-mails while having physic on my injured hand (very bad news and a 5 minute raging shouting at by the consultant blaming me for the first and second op failing, really?!?!).

One of the e-mails was your excellent post JDRoberts. I’m sure why you chose to remove it.

Having read it you’ve opened my eyes to a few things and reminded me that I’m just a hobbyist playing with some new (to me) tech that adds to all the Hue and such funky stuff I have around my home. I’m not looking to make commercial products although you never know the future. For example my recliner app is a bit of fun so that when I’m off to bed the all recline back to normal when I hit the good night routine and for show, laziness and a chance to learn while off work. Recliners are too different in their design to make a commercial project so no bulk buys and their associated savings etc.

I now also know how to pair the ThingShield and get it running as my device. It’s just my awkward, stubborn and petulant nature that wanted it to work the same way a commercial product does.

Thanks for the insight and time taken to explain! I think you should restore the post.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #12

At one point (3 years ago?) SmartThings was aiming to sell the custom firmwared surface mount ZigBee chip that is on the ThingShield, in mass production, aiming for ≈$10/each. I believe it has an MCU and direct GPIO, etc., quite powerful. Somewhere along the line they dropped this plan.

The chip or similar can be found from various manufacturers and can be configured with standard ZigBee HA tools (I think folks even have managed to get XBee Pro working as ZigBee HA?).

In fact, there’s nothing stopping an entrepreneur from making a better competitor to the ThingShield.


(Lee) #13

I’d like to thank JDRoberts once again. You opened my eyes to a lot of things and that led to a lot of ver useful reading. Sincerely!

I’ve now decided to ditch the snobiness of having to use only official Adruino hardware so have bought a Sain Smart Nano for Arduino V3, with the XBEE-4NANO shield, found a smaller but slightly more expensive rotaty potentiometer sensor and an Xbee transceiver which in total turns out to be much easier to source, allows for a smaller project box and works out a lot cheaper. If it works then I buy 3 more of each :smile:

Obviously I’ll still use one of the UNO R3s and ThingSheilds for prototyping other things and bug fixes etc.

As an added bonus I can return an unsed UNO R3 to Amazon and sell the second ThingShield on UK eBay for at least twice what I paid for it. I checked with its current name of ‘SmartThings Shield for Arduino’ and ‘ThingShield’ in both active and completed listings and it appears there’s never been one listed and since SmartThings do not ship to the UK that gives me the oppourtunity to charge more.

And best of all I’ve learned a lot in the process!!! Thank you