Propeller to SmartThings (communicating with the ZigBee HA public profile)

JohnR2010JohnR2010 Posts: 373
edited October 2015 in Propeller 1 Vote Up0Vote Down
This thread outlines the process for using a Propeller with a Digi xBee Pro ZB to connect to a public ZigBee Home Automation network.

Why would you want to do this?
The ZigBee Home Automation (HA) spec is used by all the new Home Automation controllers you are seeing pop up at Home Depot, Lowes, SmartThings and SmartenIT. How cool would it be to have a propeller based gizmo controlled by these home automation devices. If your device adheres to the public ZigBee HA spec it will be able to join and communicate with these networks.

This is a logical next step for the Parallax community several propeller projects in this forum have been based on Digi's 802.15.4 xBee, the ZigBee Home Automation profile is based on the same 802.15.4 standard and it defines a very detail protocol for devices to communicate with each other and to the outside world. Yes it is a bit overwhelming at first the ZigBee Spec is 604 pages and the ZigBee Cluster library is 442 pages but if you take the time to figure it out the power of communicating directly with other things is amazing!!

Why SmartThings?
I had to pick a hub to connect to and SmartThings (recently purchase by Samsung) was designed to be an open platform for Home Automation devices. They sell a ZigBee hub and several devices that work with it but they also allow you to add any standard Home Automation device by creating a custom device type. They even have a web based IDE to help you do this. All SmartThings devices are controlled by their Android and iPhone apps. So once a device joins the SmartThings Home Automation network you can see it and control it on the iPhone app!! How cool is that your propeller based gizmo shows up right next to your ZigBee Hue Bulb on the smart phone app.

Goal:
The goal of this thread is to create a very simple (hello world) standard Home Automation device that will allow you to use your smart phone (running the SmartThings app) to simply turn on a LED connected to a propeller. Once I get some feedback I plan on publishing the SPIN ZigBee HA driver on the object exchange.

You may notice that SmartThings has an Arduino shield available. If you decide to go that route I would like to point out a huge shortcoming of that device. It will only work with SmartThings, it is not based on standard Home Automation device types and clusters. It is a very proprietary solution that only works with their hub. I don’t mean to bash their shield I don’t think it was ever intended to be used on anyone's network but theirs. Enough said about that (I hope anyway).

Hardware requirements:
Your favorite propeller board http://www.parallax.com/product/32210 $49

Digi xBee Pro ZB SMT (Surface Mount) Digi part number XBP24CZ7PIS-004 you can order one here http://www.digikey.com/product-search/en?x=13&y=12&lang=en&site=us&keywords=XBP24CZ7PIS-004 $28
Other Digi xBee Pro ZB chips will work with limited support for the full ZigBee HA spec. If you want to take advantage of all features outlined in this post you need to use the ZB SMT version.

Two 2MM connection headers Digi Key part number 952-1316-ND. These headers will be soldered to the above xBee Pro SMT to make it a through-hole component so it will plug into your bread board. $5.40 for 10

Xbee USB Adapter board http://www.parallax.com/product/32400 $24.99
We will use this board to program the xBee Pro ZB SMT

SmartThings Hub from SmartThings.com $99

Software requirements:
Digi XCTU configuration program http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu.
Digi XCTU configuration file (XCTU_Cfg.zip)
Propeller ZigBee Home Automation driver (ZigBee-HA_Communications.zip)
SmartThings Custom Device Type https://github.com/JohnRucker/Nuts-Volts/blob/master/devicetypes/johnrucker/parallax-propeller-demo.src/parallax-propeller-demo.groovy

Resources:
xBee-Pro ZB SMT RF Modules product guide http://ftp1.digi.com/support/documentation/90002002_M.pdf
ZigBee Specification http://www.zigbee.org/Standards/ZigBeeSmartEnergy/Specification.aspx
ZigBee Cluster Library http://www.zigbee.org/Products/ZigBeeClusterLibraryDownload.aspx
ZigBee Home Automation Public Application Profile

Phase I Setup and configure Digi xBee Pro ZB SMT to join a ZigBee HA network
For a device to join a ZigBee HA (Home Automation) network a strict join process must be followed that is built around the exchange of 128 bit security keys. The ZigBee HA Coordinator (the SmartThings Hub is a ZigBee coordinator) controls the keys and will allow or not allow new devices to join the HA network.

Step 1)
Solder pins as show in the picture to the xBee Pro ZB SMT. This will allow you to use the xBee Pro ZB SMT just like it was a through-hole xBee.
20140902_161551625_iOS.jpg


Step 2)
Plug the xBee Pro ZB SMT into the xBee USB Adapter board and connect it to your windows PC. Download and install the latest XCTU software from Digi http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu.
Use the XCTU program to search for and connect to your xBee Pro SB SMT
Use the XCTU program to make sure your xBee Pro ZB SMT is on the current firmware version 4043 or newer.
Use the XCTU program to load the ZigBeeHAPropeller.xml (XCTU_Cfg.zip) and write it to xBee Pro ZB SMT.

The above process will change the following parameters on the xBee:
ZS ZigBee Stack Profile: 2=ZigBee-Pro. This is required to communicate with a ZigBee HA network
NJ Node JoinTime: 0x5a This setting allows devices to join a network it must not be at the default or it will allow devices to join at any time causing a security problem.
EE Encryption Enable: enable. Security has to be enabled to join a ZigBee Home Automation network
EO Set Bit 1 = 1. This will force the network security key to be transmitted encrypted.
KY Encryption Key = 0X5A6967426565416C6C69616E63653039 This is the encryption key for all ZigBee Home Automation networks. It is required to join the SmartThings hub and other standard ZigBee Home Automation networks. I will discuss the security keys and joining process in a future post.
BD Baud Rate is set to 115200
D6 is set to RTS flow control. The Propeller ZigBee Home Automation driver uses RS232 hardware flow control to communicate with the xBee. It is possible to get by without flow control but there is a lot going on and it is best to not miss any packets so it is worth the two extra wires on your board.
AP API Enable = true
AO API Output Mode = 3 ZDO pass-through

Step 3) verify that you can still communicate with the xBee Pro ZB SMT by reloading its configuration. Make sure the above settings are correct and the firmware version is 4043 or newer. At this point your xBee is configured to join a home automation network and will start searching for a coordinator to join.

Now move your xBee ZB Pro SMT to your Propellers proto board and connect it as outlined in the attached JPG
xBee_Schematic.jpg


Phase II install the sample SPIN code and configure it for your hardware
Install the sample (ZigBee-HA_Communications.zip) application. Make sure to set the Pin configurations for your hardware's xBee and LED pins! The application is documented and it should be easy to find the locations to make these changes.

This application will send status messages to the Parallax Serial Terminal connected to pins 30 and 31 at a baud rate of 250000.

Phase III install the SmartThings custom device type
After you setup and install your SmartThings hub connect to your SmartThings developer account at https://graph.api.smartthings.com and install the custom device type in the My Device Types section. The easiest way to do this is to click on the "New SmartDevice" button and fill in the required fields with bogus information (It will all be replaced in the next step) and hit create. This opens an online editor. Select all the text in this window and replace it with the text located at https://github.com/JohnRucker/SmartThings/commit/1c8bec805913cd5e8b3e9f989ead335ea5d7ddc6. Hit the save button and then hit then hit the publish button. Now your SmartThings account has a new custom device type that will be assigned to your propeller when it connects to the hub the first time.

Phase IV Boot it all up.
Before proceeding with this step make sure your SmartThings hub is all setup and configured, plugged in and you can connect to it with your smart phone.
Make sure the propeller and xBee are close to the hub so there is no issue with communications. Boot up the propeller and note the propeller is searching for a network to join. The SmartThings hub wont allow new devices to join until you use your smart phone to add a new device. Click on the plus sign at the bottom of the SmartThings dash board and then click on "Connect New Device" the LED on your SmartThings hub will start to flash green and after a few moments the xBee will join the home automation network and the propeller will go to the next step of identifying itself to the hub. The hub will query the propeller for its configuration and then match that configuration to the footprint in the SmartThings custom device type discussed in Phase III above. Follow the prompts on your phone to configure the new tile.

Now all you have to do to turn on your LED is tap the little plug symbol. The tile will turn green and you will see a packet arrive on the propeller and the LED will switch on.
20140903_183307000_iOS.png
20140903_183301000_iOS.png


Let me know how this works. This is a complex process with a lot of moving parts and I will be happy to make changes to the code if it makes things eraser or more reliable.
1024 x 768 - 64K
1024 x 768 - 63K
640 x 1136 - 339K
640 x 1136 - 351K
640 x 1136 - 120K
640 x 1136 - 360K
1024 x 750 - 108K
«1

Comments

  • 58 Comments sorted by Date Added Votes
  • RS_JimRS_Jim Posts: 1,045
    edited September 2014 Vote Up0Vote Down
    John,
    Thanks for posting this. I will be following this with interest.
    Jim
  • KMyersKMyers Posts: 396
    edited September 2014 Vote Up0Vote Down
    Like wise here. Beats my old HD 64180 system of many years ago!
    Ken N8SYG
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    More pictures of soldering the header to the xBee pro ZB SMT to make it pin compatible with the through hole versions.
    1024 x 768 - 39K
    1024 x 768 - 42K
    1024 x 768 - 47K
    1024 x 768 - 52K
  • RS_JimRS_Jim Posts: 1,045
    edited September 2014 Vote Up0Vote Down
    John,
    The last time I did any thing with home automation it was based on the X-Ten system and used an ultrasonic signal to control the main base. The computer was a Heathkit H-8 and the software was written in Z80 assembly. I would jump headlong into this,but the bank won't allow for a $99 hub and $30 per device( not counting propellers et al)
    Jim
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    I agree it is a little costly if you buy the hub for just this project. But if you already purchased a hub or are going to buy one anyway you can take advantage of that investment. There are other cost savings as well you don't have to use the Pro version of the Digi radio you can get by with the standard version and save $18 or so. I'm using my radio as a high powered ZigBee router so I went with the Pro version. The Pro version is very powerful. I have a Propeller controlling the fountain in my pond with this radio and it is a good 1000' away from my house.

    I too worked with X-10 / Insteon and to be honest that total burned me out on home automation. I could never get it to be reliable and took out all my switches and plugs. But that was years and years ago Home Automation has come a long way since then!!
  • RS_JimRS_Jim Posts: 1,045
    edited September 2014 Vote Up0Vote Down
    Great!
    Knowing that shorter range requirements can be met less expensively is good to know. Last night, I had an inspiration for a revenue generating project that will sell really well here in the Phoenix market, so I might be jumping on this sooner rather than later.

    Where is jerseyville relative to Jacksonville ? My brother lives in Jacksonville.

    Jim
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    RS_Jim wrote: »
    Great!
    Knowing that shorter range requirements can be met less expensively is good to know. Last night, I had an inspiration for a revenue generating project that will sell really well here in the Phoenix market, so I might be jumping on this sooner rather than later.

    Where is jerseyville relative to Jacksonville ? My brother lives in Jacksonville.

    Jim

    Sounds good! Looking forward to the feedback. I have several projects in the back of my mind that can take advantage of this connectivity just need to prioritize and knock a few other things off my list before I get back to it. Good luck with your project!!

    Jerseyville is 45 minutes south of Jacksonville on hwy 67. Small world!!
  • RS_JimRS_Jim Posts: 1,045
    edited September 2014 Vote Up0Vote Down
    I thought I recognized the name. I graduated from IC and we used to drive down 67 to STL for baseball games etc.
    Jim
  • marciocamuratimarciocamurati Posts: 5
    edited September 2014 Vote Up0Vote Down
    JohnR2010, I have a XBee Series 2 (https://www.sparkfun.com/products/10414) and a Smartthing Hub, do you know how can I configure it to work together? For example which function set I need to configure: End Device AT or Router AT?

    Best regards,
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    JohnR2010, I have a XBee Series 2 (https://www.sparkfun.com/products/10414) and a Smartthing Hub, do you know how can I configure it to work together? For example which function set I need to configure: End Device AT or Router AT?

    Best regards,

    Follow the steps at the top of this thread. I outline the parameters for setting the xBee Pro ZB SMT and even included a sample X-CTU config file for it. Your xBee is pretty close and should work. If you want to use my driver you will need to use Digi's X-CTU program to load the router API profile for your xBee and then set the ZS, NJ, EE, EO, KY, BD D6, AP and AO parameters as discussed above. Make sure you set your xBee for API mode my driver creates API packets to communicate with the SmartThings hub.
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    JohnR2010, I have a XBee Series 2 (https://www.sparkfun.com/products/10414) and a Smartthing Hub, do you know how can I configure it to work together? For example which function set I need to configure: End Device AT or Router AT?

    Best regards,
    Marciocamurati, I downloaded the documentation for your xBee and you should load the - 23xx - Router - API Operation firmware with the X-CTU utility. If you still have problems let me know what version of the X-CTU program your running and I will make up a configuration file for you to try.
  • marciocamuratimarciocamurati Posts: 5
    edited September 2014 Vote Up0Vote Down
    Hi JohnR2010, a doubt about how can I test if the xBee configuration is correct. After I load the Router - API and make the update with the correct configuration, the Smartthings will be able to search and find the xBee while it it's connect at the USB explorer or the Smartthings will only find the xBee when it stay integrated with the Propeller?

    Best regards,
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    Hi JohnR2010, a doubt about how can I test if the xBee configuration is correct. After I load the Router - API and make the update with the correct configuration, the Smartthings will be able to search and find the xBee while it it's connect at the USB explorer or the Smartthings will only find the xBee when it stay integrated with the Propeller?

    Best regards,
    If I understand correctly you are asking; will your xBee connect to the SmartThings hub after it has been configured and is still in the USB X-Bee Adapter board connected to your PC? The short answer is yes, if the SmartThing hub is allowing new devices to join, it will join and appear as an unknown device to SmartThings.

    Details:
    As soon as you set the xBee to the profile I outline at the top of this thread it will start to look for a valid ZigBee Home Automation network to join. You don't have to give it a command to tell it to do this. If the xBee is powered on it will start scanning for a coordinator to join. If the ZigBee Stack settings are correct, and all the security parameters match, and the network is allowing new devices to join it will join. The best way verify that it has joined the network is to look at the AO parameter with the X-CTU software. If AO=0 your connected to a valid network as a router (You will have to keep refreshing the view).

    Even more Details:
    When a ZigBee device joins a network (this is how SmartThings works) an identification process occurs. The ZigBee Home Automation spec defines several ways devices can discover each other and figure out how to talk to one another using ZigBee Device Objects (ZDO). SmartThings uses three sets of ZDO clusters to identify devices when they join a network. The first thing that happens after a device has been allowed to join a network is it should send out a device announce packet (ZDO Cluster 0x0013) this is received by the SmartThings hub. Next the hub will send out a request for active end points supported by this new device by sending a ZDO Cluster 0x0005 packet to the new device. The device is expected to respond back with a list of its end points in a ZDO cluster 0x8005 formatted packet. Now each end point is queried for a profile ID, Device ID, and a set of supported clusters on that end point (ZDO 0x0004 & 0x8004 are used for this). At this point SmartThings knows what your device is and what it can do so it starts to look for a device driver to match it with (they call this the foot printing process).

    So the long answer is since you don't have a propeller telling the xBee to do a device announce, respond to active end point request, and then respond to the simple descriptor request SmartThings will not be able to figure out what to do with your xBee. This is what my code does ZigBee-HA_Communications.zip. I have also created a custom SmartThings device type you can load into the SmartThings IDE, all of this is outlined at the top of this thread.

    If you get your xBee connected to the SmartThings hub you made a great first step!! Please keep us posted on your progress!!
  • marciocamuratimarciocamurati Posts: 5
    edited September 2014 Vote Up0Vote Down
    Hi,

    I have configured the Xbee with Router API and I made the configuration like the attached XML profile_23A7.xml.zip and at the Smartthings appeared an icon with Unknown information like below. I will try to integrate it with the propeller and update here.

    IMG_4531.jpg


    Thank you for the help!

    Best regards,
    320 x 480 - 12K
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    Well Done!! Keep in mind SmartThings still wont recognize the Propeller until you install my code and the custom SmartThings device type to work with it.
  • electromanjelectromanj Posts: 270
    edited September 2014 Vote Up0Vote Down
    JohnR2010, thank you for posting this! This looks like a really fun project! I have received my zigbee module, and I am waiting for the SmartThings hub to arrive. I am having trouble opening the code examples that you posted. They show up as a .php and my computer tries to open them with notepad ++ which renders an awesome example of many weirdo characters that I am unable to decipher. :D . Any suggestions?
    Thanks.
    traVis.

    Edit*** Must be a problem with this wonderful Windows 8.1.... I just clicked the link on my raspberry pi machine and all of the files are right there ready to be opened. Man I miss my old machine....
    It's not that the Code isn't doing what I told it to do. The problem is the Code is doing exactly what I told it to do. I just told it to do the wrong thing.....
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    No worries. I'm looking forward to feedback on the code let me know how it works out.
  • marciocamuratimarciocamurati Posts: 5
    edited September 2014 Vote Up0Vote Down
    JohnR2010, if I want to add more than one XBee with separated Propeller which attributes I need to change at the configuration? Only the NI?


    Best regards,
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    You can add as many xBee / Properer units to the ZigBee network as you like and all with the same parameters as outlined above. Each xBee has a unique IEEE address and that is what ZigBee uses to identify the node and route traffic to it. ZigBee has a hard limit of 65,000 nodes in one network but the practical limit for a mesh configured network is closer to 40 to 50 units. If your bigger than 50 units you need to switch over to source routing and that is handled by the coordinator. SmartThings does employ source routing so your network could easily support several hundred nodes. However, I'm not sure what SmartThings' max node limit is but ZigBee will support it.

    The NI (Node Identifier) setting is only used by Digi's proprietary communications, the public ZigBee HA profile doesn't use it to route packets or is even aware that it is there. Its a way for Digi's management software to ID their chips so you can set it to something if you like but it isn't required.

    If you want to give your device a name use the basic cluster from the ZigBee Cluster Library. My sample code ZigBee-HA_Communications.zip uses the basic cluster to set a description of your device, manufacture name, hardware version number, and software version number. In the attached screen shot you can see a propeller reporting its Manufacturer as Parallax and Model as Propeller Gizmo. Also note you can see other ZigBee devices, the Philips LCT001 are Hue Bulbs all on the same network.
    ScreenOfDescription.JPG
  • marciocamuratimarciocamurati Posts: 5
    edited September 2014 Vote Up0Vote Down
    Strange because yesterday I tried to connect a second XBee with the same configuration but the Smartthing identified only one. I did a test deleting the device that it found and trying to add the both again and it only identified the same device at the mesh. I will make more tests today to try to add it.
  • JohnR2010JohnR2010 Posts: 373
    edited September 2014 Vote Up0Vote Down
    Did you get your second module added to SmartThings? I know this library works with multiple devices I have done it several times in testing with multiple propellers and xBees.
  • electromanjelectromanj Posts: 270
    edited December 2014 Vote Up0Vote Down
    Worked great for me John!

    When I first got all my parts I connected the Zigbee module to the Activity Board and although I could see the device in the SmartThings app, the serial terminal never went past the network join status. It just kept displaying 7E (delimiter from the API packet?). I used different pins and I did change them in the program, but never did figure out what was going on there. I also tried reversing the rx tx pins because Ive made mistakes there before.... I was pretty sure I was connected because the data stream I was reading on my Saleae LA was sending the 0x00. I don't remember how I got it to show up in the app because I was trying a lot of different things, but I think it was after I changed the device type. I usually start a new notebook when I start a new large project, but I didn't this time.

    I decided to get back to it today and hooked the module up to the PPDB so I could replicate your instructions completely. As soon as I downloaded the program to the dev board I saw a lot strange characters spit out on the screen. I couldn't read what was going on (wrong baud rate on the PST... :D) but I knew it was different and was no longer spitting out a character over and over. Once I corrected the baud rate everything was great! No problem turning the led on and off and the SmartThings app updates correctly.

    Time to get a new notebook out and start a project!

    Thanks again!

    traVis.
    It's not that the Code isn't doing what I told it to do. The problem is the Code is doing exactly what I told it to do. I just told it to do the wrong thing.....
  • JohnR2010JohnR2010 Posts: 373
    edited December 2014 Vote Up0Vote Down
    Electromanj: This project has a lot of moving parts and it takes a broad set of skills to get everything working! Good Job!!. Looking forward to seeing what you put together with it. Since you did this with the Activity Board I think other people wold love to see how you set everything up. It would be great to see some pictures. My stuff is on a custom made PCBs and I think that puts the coders off as they don't want to fuss with a custom circuit. But now that you have proven it works with off the shelf hardware maybe more people will start playing with this.
  • JohnR2010JohnR2010 Posts: 373
    edited December 2014 Vote Up0Vote Down
    UPDATE: Here is a quick list of projects I have been working on based on this library and the Propeller:

    1)) Anemometer, ZigBee HA (Mains Powered): Reports wind speed over the Analog Cluster <<Complete, documented with custom SmartThings device type and in operation >> Backyard Anemometer.pdf

    2)) Analog Meter, ZigBee HA (Battery Powered): Display wind speed on a analog meeter. This device can be bound to the above anemometer and displays the wind speed on an old fashioned analog uA meter. Should run for over a year on two AA batteries!! << circuit complete, code in test phase >>

    3)) Color Light based on the WS2812 LEDs http://parallax.com/product/28085, ZigBee HA (Battery Powered): This light shows up just like a Hue bulb and responds to all the same clusters but it is battery powered so you can place it anywhere. Intended to be outside in remote areas << circuit complete, Spin code in test phase, SmartThings device type in test phase>>

    4)) ZigBee HA Solar Powered Router: This device can extend your ZigBee HA network outside to over a mile (line of site). I'm testing it with some Hue Bulbs that light a Merry Christmas sign about 1.200 feet away from our house. <<Circuit in test has been running for 6 weeks on solar power>>

    All the above projects have a X-Modem object that works with the legacy X-CTU client to upload new firmware directly to the Propellers EEPROM. This is still a bit rough but works really well over the ZigBee network even to my battery powered devices. Of everything I have been working on the battery powered stuff has been the most rewarding and is where ZigBee really shines as compared to WiFi and other RF protocols. When these device are sleeping they are pulling around .005mA. When they check for data the propeller continues to sleep while the xBee will spike up to 100uA to see if there is any data for the propeller. If there is data it wakes up the propeller and passes it the packet for processing.
  • electromanjelectromanj Posts: 270
    edited December 2014 Vote Up0Vote Down
    So far I have got it to work with the Propeller Professional Development Board and the Activity Board. As far as the PPDB I just used the same pin assignments that are in the demo program.

    As far as the Activity Board, I started out with the Xbee mounted to the breadboard with the Xbee adapter board (can't figure out how to add a link, but the part number is 32403).
    Today I took another crack at getting the Activity Board to work. I'm not sure if I had some wires mixed up or the wrong pin assignments in the program, but I decided to move the Xbee over to the adapter on the board. I ended up with CTS - P10, RTS - P11, DI - P12, and DO - P13. Led is on P7. That worked out fine. The only thing I could not connect to was the reset pin on the Xbee as only CTS,RTS,DI,and DO are brought out, which is why I started out on the breadboard. This setup is much cleaner. How important is the reset pin?

    Thanks.

    Here are a few pictures:
    IMG_2506.JPG
    IMG_2507.JPG
    IMG_2508.JPG
    1024 x 1024 - 379K
    1024 x 1024 - 380K
    1024 x 1024 - 413K
    It's not that the Code isn't doing what I told it to do. The problem is the Code is doing exactly what I told it to do. I just told it to do the wrong thing.....
  • JohnR2010JohnR2010 Posts: 373
    edited December 2014 Vote Up0Vote Down
    You can probably get by without the reset pin but if you design a circuit I would include it. When you get a bit further down the road you may want to change the configuration of the xBee and often you have reset it to initialize the new settings. I think I reset the xBee every time the propeller boots to make sure it is at a know state. If you have problems communicating with the xBee at start up just power off both the xBee and the Propeller and you should be good.

    Thanks for sharing the pics!!
  • electromanjelectromanj Posts: 270
    edited December 2014 Vote Up0Vote Down
    Thanks John! One more thing I would still like to try is running this from the breadboard setup from the Propeller Education Kit. I should find some time this week to do this.

    I played around with it a little more today.
    I wanted to try a simple Hello World to the PST. I changed the following:
    In the PRI method clstr_onOff of Zigbee-HA_Communications I copied this:
    if frmType == $01 AND cmdID == $02 AND attributeID == $00                     ' Toggle device
        dira[LEDPin]~~                                                              ' Set as Output
        !outa[LEDPin]                                                               ' Toggle Output
        sendDefaultResponse (CmdID, $00, $38)                                       ' Send Default response back to originator of command      
        pst.str(String(CR,"LED Toggle"))
    

    and changed it to this:
    if frmType == $01 AND cmdID == $03 AND attributeID == $00                     ' Toggle device
        'dira[LEDPin]~~                                                              ' Set as Output
        '!outa[LEDPin]                                                               ' Toggle Output
        sendDefaultResponse (CmdID, $00, $38)                                       ' Send Default response back to originator of command      
        pst.str(String(CR,"Hello World!"))
    

    In the SmartThings device type I changed the command from 0x0 to 0x3 and saved the change.

    When I try to turn the led off the PST now displays Hello World!

    My compliments John! Earlier today I only changed the off cmd in the device type to 0x3 to see if it would show up on the PST and the spin program handled it perfectly. Didn't lock up, made no changes to the led, displayed the payload correctly and went back to "waiting for packet". Thanks so much for providing a fantastic foundation to build upon!

    I downloaded some info today on zigbee clusters (one document is 832 pages!). Are there any certain manuals or documents that you would recommend to help wrap my head around the Zigbee world?

    Travis.
    It's not that the Code isn't doing what I told it to do. The problem is the Code is doing exactly what I told it to do. I just told it to do the wrong thing.....
  • JohnR2010JohnR2010 Posts: 373
    edited December 2014 Vote Up0Vote Down
    In the SmartThings device type I changed the command from 0x0 to 0x3 and saved the change.

    When I try to turn the led off the PST now displays Hello World!

    Travis.

    Well done! I know the feeling!! It is just so cool to be free from the user interface and let the SmartThings iPhone app take care of all that. I just want to add that since we are working with standard ZigBee clusters your Propeller device will work on other standard ZigBee networks as well. So the hardware is not tied to SmartThings!!
    I downloaded some info today on zigbee clusters (one document is 832 pages!). Are there any certain manuals or documents that you would recommend to help wrap my head around the Zigbee world?
    Travis.

    Don't let the size of the document overwhelm you after all it is an extreamly detailed spec that was written by multiple people in multiple countries over several years. The two PDFs I use the most are the ZigBee Cluster Library (ZigBee_Cluster_Library_Public_download_version.pdf) and the ZigBee Device Objects (ZigBee-Specification.pdf) . It will simply take some time to understand the layout but once you get one cluster figured out the others are just variations. I went out of my way to put the page numbers in my code's commits I would suggest focusing on that. A good starting point would be to look up the section on the OnOff cluster 0x0007 in my code. You will see it refers to a page number in the ZigBee Cluster Library and you can use that as a guide to see why I formatted the data packet the way I did. Another common cluster is the level cluster 0x0008 you can use it to set the brightness of something or the position of a servo motor. I use this cluster to control the brightness of some WS2812 LEDs.

    This web site has a good listings of public clusters and I often refer to it when I'm trying to decipher a data packet. http://www.perytons.com/help/Perytons51help/index.htm#!Documents/supportedzigbeeclust.htm

    Okay one last possible gotcha. If you haven't noticed yet all multibyte date values in the ZigBee payload are represented in little endian format http://en.wikipedia.org/wiki/Endianness. For example, their are 4 bytes in a long. If you send that long in a ZigBee packet your have to reverse the byte order of the 4 bytes that make up a long. Its easy to do and you will notice I have to do it often when creating a ZigBee data packet to send. If you hadn't run into this before it can mess with your head.
  • electromanjelectromanj Posts: 270
    edited January 2015 Vote Up0Vote Down
    Okay one last possible gotcha. If you haven't noticed yet all multibyte date values in the ZigBee payload are represented in little endian format http://en.wikipedia.org/wiki/Endianness. For example, their are 4 bytes in a long. If you send that long in a ZigBee packet your have to reverse the byte order of the 4 bytes that make up a long. Its easy to do and you will notice I have to do it often when creating a ZigBee data packet to send. If you hadn't run into this before it can mess with your head.

    You are right about that! I ran into that before with the crc of a modbus rtu telegram (gray hairs added).

    It took me several days to even understand what questions to ask, and I am still not sure about the wording so I hope the following makes sense....

    I am currently trying to add temperature measurement to my project. I have added an LM34 temp sensor to the Propeller Activity Board, and am able to read the temperature and display it on the PST when the led is turned on and off.

    I am going in circles trying to display the temperature on the SmartThings app.

    My first problem was trying to add a new tile (valueTile) to the device type. That ate up several days. I was not even able to remove tiles from a device type after I removed them from the device type. The solution was to log out of the smartThings app and then log back in. More gray hairs..... :)

    There are several examples of temperature/thermostat examples but these seem to be for devices that are already established. I am having a hard time getting started on this.

    As a side note, I have learned quite a bit from all of my unsuccessful trials and I am getting more familiar with this.

    Now that I have gone on and on let me get to my question...

    Do I need to use some kind of established protocol on the ST and Prop ends or should I try to query the Prop for the temperature variable and display it on the ST app tile?

    What I would prefer is a "status" button that queries the Propeller for the current temperature and displays it on the ST app.
    It's not that the Code isn't doing what I told it to do. The problem is the Code is doing exactly what I told it to do. I just told it to do the wrong thing.....
  • JohnR2010JohnR2010 Posts: 373
    edited January 2015 Vote Up0Vote Down
    This sounds like a good project. There are several ways to send data between your Prop and SmartThings. You can have SmartThings Poll the device periodically for data and / or you can have the device send updates to SmartThings either based on an event or a time interval. This is all spelled out in the Temperature measurement cluster 0x0402. If we make our device communicate using the attributes and commands in cluster 0x0402 (page 251 of the ZigBee Cluster Library) then we will be able to use SmartThings Temperature Sensor sample template that you have probably already seen in the SmartThings Device Type Templates section of the IDE.

    So we are on the same page here are the steps I would go through:
    1) Get the Propeller hardware setup and working to make sure you can read a valid temperature value. (Sounds like you have done this with the LM34 temp sensor)
    2) Add Cluster 0x402 Temperature Sensor support to your existing code. Just as I had support for the on/off cluster we need to add support for the Temperature cluster.
    3) Use SmartThings to query the 0x402 cluster running on your propeller.

    I think Step number 2 is where you are? If so I would be happy to help with steps 2 and 3. If your up for it lets build a SPIN object for cluster 0x402.
Sign In or Register to comment.