ARTIK 5/7/10 and ARTIK 030 modules offer as standard the ZigBee®/Thread personal area network interface, using a built-in IEEE 802.15.4 radio. ZigBee is used primarily for control and monitoring of lights, sensors, switches, appliances, etc. and can be applied to both home and commercial/industrial automation.
The low-power ZigBee system allows devices within range of each other to autonomously form a "mesh" network that may include "star" grouping for endpoints.
|Sleepy End Devices
||Simple, battery-operated devices (like temperature sensors) form a star around a central parent device that routes their messages into the main mesh. These end devices wake up on their own schedule, check messages from / send status to their parent, and go back to sleep.|
|Powered End Devices
||Line-powered devices or devices with higher-capacity or rechargeable batteries are used when immediate reaction is required (a controllable light, for example). These devices are typically router-capable.|
||Router-capable devices can take part in a mesh and can be dynamically coordinated to select routes. Routers must stay active all the time and therefore are often line-powered.|
||One of these router devices becomes the Coordinator for the system and orchestrates forming and maintaining the network. The Coordinator can reorganize and reroute message travel paths as needed to adapt to changing conditions (device addition/removal, radio disturbances).|
By using this hybrid topology, the range of the network between the most distant endpoints is extended considerably, with communication packets travelling by "hops" along the best route.
Nearly all ZigBee devices on the market (even "end" devices) act as routers. You'll also see that they'll often surprise you with their route choices!
ZigBee Application Tutorial
This tutorial makes use of the ZigBee software stack that is part of the Simplicity Studio® 4.0 development installation (see Prerequisites). The Simplicity tool generates custom source code according to the features you select. The code stack is the same across all ARTIK module ZigBee cirsuits, so you can expect consistent ZigBee programming.
When it comes to actually compiling the generated files, the approach differs depending on whether the application is Linux-based.
ARTIK 030 applications. Being designed for low-cost and CPU-efficient applications, the ARTIK 030 is not Linux-based. Its memory and processing capabilities are not sufficient for native compilation of code, so cross-compilation takes place on a separate PC.
To simply explore the device capabilities discussed in this tutorial, you can use pre-compiled images we have prepared for you to upload.
When you're ready to create custom ARTIK 030 applications, you'll use Simplicity Studio. You'll also need to license the IAR Embedded Workbench® ARM IDE tool to cross-compile the code on your development PC. Go to Custom A030 Applications for details.
ARTIK 520, 530, 710, and 1020 applications. The EM3587 ZigBee/Thread radio on the ARTIK module works with the Linux main processor on the module as a network co-processor (NCP), connected by a simple serial interface.
The NCP on the modules arrives with its "identity" pre-flashed as a ZigBee command processor. ZigBee application programs then run from the ARTIK main processor itself. The testing described in this article uses
zigbee-cli utility programs, based on the ZigBee API supported by starting
To create and run custom applications of your own, you'll use the API just like the
-cli programs do. Network form and join operations are taken care of at your command, and you can easily turn lights on/off or dim them. The ZigBee API complements the ARTIK API, but one does not depend on installation of the other.
Optionally, you can code projects using the Simplicity Studio ZigBee stacks, similar to what you do for the ARTIK 030. In this case, you use your ARTIK 5/7/10 platform to compile the code natively (no compiler license is required), and install a pre-written NCP program. You won't use the ZigBee daemon, the API, or the utility programs.
This tutorial works with a mix of ARTIK 030, 520, 530, 710, and 1020 boards. You'll need at least two. Once the devices are joined on the network, they will be able to send messages to each other.
Obtain any combination of the following boards: ARTIK 030, 520, 530, 710, or 1020.
If you intend to develop using the ZigBee software stack, you must register an ARTIK 030 development kit with Silicon Labs. The kit comes with three boards, so one kit is sufficient for testing.
For developing software using the stack, install Simplicity Studio 4.0 on your host PC. Have your ARTIK 030 board ready to plug in when you install the software, so that it is automatically recognized and the appropriate drivers installed.
You must register at least one ARTIK 030 kit to allow installation of the ZigBee stacks, even if you only use the stacks for ARTIK 5/7/10 boards.
We recommend that you read the ZigBee fundamentals document in your Simplicity Studio ZigBee installation, usually found at
in the documentation folder:
The time for completing the tutorial portion of this article is about an hour, including the download and installation time for necessary software. The basic steps will be:
- Prepare – load needed software and firmware onto the various board types
- Create – execute the commands to form and join the ZigBee network.
- Command – send ZigBee Cluster Library (ZCL) commands to try them out.
The pre-compiled A030 HaSample… images cannot act as Coordinator. For thorough testing, you'll need at least one other ARTIK 5/7/10 board.
Prepare ARTIK 5/7/10 Boards
Using one or more ARTIK 520, 530, 710, or 1020 kits, you'll build ZigBee device nodes to play with. Any of these board types can talk with any other one, as well as with ARTIK 030 boards prepared as described elsewhere.
You'll run all ZigBee utility and application programs on the ARTIK main processor, which will transfer commands to and return data from the NCP by way of the internal serial port (the same one used for flashing an NCP firmware update).
Two pre-built utility programs provide a shorthand method for testing, avoiding lengthy network form and join sequences to get right to ZCL commands. To create and compile your own application, you'll use ZigBee API calls. Refer to the
artik_zigbee_test.c file in the ARTIK IDE section – it's the source for the program that we use here.
Install or update software
To prepare your board, you'll need to do some quick setup and installation checks.
Step 1. Set up repository to install/update software packages for ZigBee
Step 2. If needed, flash-update the NCP to re-establish its "identity" as ZigBee
Step 3. Verify that the internal serial port driver, called
zigbee-daemon, is running.
Step 1: Install the latest ZigBee API packages
ZigBee NCP firmware is loaded to each Silicon Labs device by default at the ARTIK factory, making it "ZigBee-ready". However, the main processor firmware image may or may not include ZigBee driver and utility programs. As the latest ARTIK API release (rev. 1.2) introduces new features, you'll want to update to that revision in any case.
|520||A520-OS-1.0.0||ZigBee-ready but no ARTIK SDK|
|A520-OS-2.0.0||daemon and rev. 1.1 utility programs built-in|
|530||A530-OS-1.0.0||daemon and rev. 1.1 utility programs built-in|
|710||A710-OS-1.0.0||daemon and rev. 1.1 utility programs built-in|
|A710-OS-2.0.0||daemon and rev. 1.1 utility programs built-in|
|1020||A1020-OS-1.1.0||ZigBee-ready but no ARTIK SDK|
Pull up the ARTIK SDK Installation article, and follow the instructions to:
dnfaccess to the ARTIK repository and its up-to-date packages
Make sure you enter the last command as indicated:
dnf makecache --refresh
Install the ARTIK SDK (only if you are using an older build without it).
Update to the latest SDK files (including ZigBee) by entering
Install the latest ZigBee daemon by running:
dnf remove zigbeed
dnf install zigbeed
You can verify that you have the updated version (1.2) by entering:
dnf info libartik-sdk-zigbee
If you have the rev. 1.1 API version installed and would like a reference to that older version instead, you can find the article here.
Step 2: Load the ZigBee NCP firmware if needed
The Silicon Labs chip is configured at the factory to give it a ZigBee identity. Normally you will not need to change this. But if the factory NCP image has been replaced (for Thread operation, for example), you will need to flash back the appropriate ZigBee NCP firmware before proceeding. Refer to NCP Update for details.
Step 3: Check that the ZigBee daemon is running
For all platforms, you'll need to enable the ZigBee daemon, a driver that manages the internal serial port traffic. It should start automatically with the latest packages installed.
Check whether it is running.
systemctl status zigbee-daemon
If not, you need to either:
Manually start it after each reset:
systemctl start zigbee-daemon
Set it to start itself automatically on each reset:
systemctl enable zigbee-daemon
zigbee-daemon is not operating in the background, the ZigBee applications and utility programs will not work.
Your ARTIK 5/7/10 boards are now ready for ZigBee testing.
Continue below if needed to prepare ARTIK 030 boards, or jump to Create ZigBee Network if you are not using any ARTIK 030 devices.
Prepare ARTIK 030 Boards
Using the ARTIK 030 kit, you'll build a pair of ZigBee device nodes to play with. The pre-built examples we'll use are designed to form a network automatically when used with suitably prepared ARTIK 5, 7, and/or 10 boards.
You will first be uploading different images to two ARTIK 030 development boards. If you have already followed the ARTIK 030 Software Getting Started Guide instructions, then you'll have a better understanding of what we present here.
However, our ARTIK 5/7/10 pre-built utility programs and daemon do not support ZigBee 3.0, so you'd need to repeat the exercise using the Simplicity HaSampleSwitchSoc and HaSampleLightSoc projects instead. Or just use our pre-compiled images!
Download zigbee_tutorial_17-01-15.zip; unzip and save the
ZBbootloader.s37files on your PC (shown below saved in the
Run the Simplicity Studio 4.0 program and go to the Simplicity IDE view.
Connect both boards to your PC using their USB cables, making sure the board switches are set to 'AEM'. The devices appear on the left of the screen with identifier numbers. You'll use these numbers to distinguish between HaSampleLightSoc and HaSampleSwitchSoc applications in the following steps.
HaSampleSwitchSoc.s37image to one of the ARTIK 030 boards.
Repeat using the
HaSampleLightSoc.s37image to the other board.
- Left-click to select a device.
- Note its number to associate with the application (light or switch).
- Right-click and choose Upload application… (see note below if not clickable).
- Browse to your downloads; select the
HaSampleLightSoc.s37file as the main image.
- Click the "Bootloader" checkbox.
For a bootloader, under the directory
find and select
- Click Erase chip so that the chip will be cleared before upload.
- Click OK.
Launch Terminal Console
- Open terminal emulator consoles to send commands and check status.
- Select both devices (Ctrl-left-click on the second one).
- Right-click and select Launch Console.
Once you launch the console, Simplicity automatically connects over the J-Link serial bus. If you need to upload a different image later, hit Disconnect to again make the Upload application… selection clickable.
The console windows default to a tabbed format where you can only see one at a time. Let's rearrange them and pre-select the active terminal tab we'll be using.
Click on and drag one of the tabs to the top, bottom, left, or right of the window; you'll see how it will split the window depending on where you release. A side-by-side view is helpful for our purposes.
Click on each main tab and select the Serial 1 sub-tab on each console window.
- With the cursor in the bottom command entry box of the console window, hit the Enter key to get a prompt. If you see it, you're set up now to begin testing.
Create ZigBee Network
You'll need to pick one of your ARTIK 5/7/10 boards to be Coordinator. All other ARTIK 030/5/7/10 boards will be joiners.
ARTIK 030: The pre-built images have a built-in network join feature. Just press PB0!
The ARTIK 030 HA application as written defines the buttons like this:
|PB0||if not joined: JOIN|
|if joined: PERMIT JOINING|
|PB1||if not joined: FORM (if the device is capable of forming)|
|if joined: BIND (send ZDO end device bind request)|
ARTIK 5/7/10: Operation is by console using
zigbee-test, which is menu-driven and has three menu levels.
Select the functionality
the ARTIK module
will exhibit, then
 to go to next menu.
|<pre>1: On/Off Switch
2: Level Control Switch
3: On/Off Light
4: Dimmable Light
5: Light Sensor
6: Remote Control
0: ADD DEVICE DONE </pre>
—–» to MENU 2</pre>
Create the network
 form + permit join
» join each device
 to begin testing.
|<pre>1: Form network
2: Form network (advance)
3: Join network
4: Join network (advance)
5: Leave network
6: Get network state
7: Discover device
8: Start testing
9: Network permit join
10: Network find and join
11: Network stop scan</pre>
|<pre>« as COORDINATOR
« as END DEVICE
—–» to MENU 3
« as COORDINATOR</pre>
Test devices in the
 verify join list
 devices blink/beep
|<pre>1: Get device information
2: Auto test
5: Level control
6: Illuminance measurement
7: Remote Control
8: Commissioning target start
9: Commissioning target stop
10: Commissioning initiator start
11: Commissioning initiator stop</pre>
to MENU 2
Get up and running quickly
 indicate keyboard numbers only (do not type the brackets).
- Set up each ARTIK 5/7/10 board. On the terminal console, type:
systemctl start zigbee-daemon[Enter]
[Enter] for on/off switch (you could also choose on/off light)
- [Enter] by itself, to accept the default endpoint assignment
[Enter] to finish.
You will now be on Menu 2.
- Leave any pre-existing networks.
- On each ARTIK 5/7/10 console, type
- On each ARTIK 030 console, type
- On each ARTIK 5/7/10 console, type
- Establish one of the ARTIK 5/7/10 boards as Coordinator. On its console, type:
[Enter] to form a network
- When you see 'FIND FORM', it's done forming and is in the
- From other devices, join the network within 60s:
- A030 – Press PB0
- A5/7/10 – Type
- Any other ZigBee device you may have – follow its joining procedure.
That's it! You've set up a network. All devices can communicate now. Type
 [Enter] on the Coordinator console to move to Menu 3, and then
 [Enter] to see the Node ID ('device id'), EUI (MAC address), and cluster information of each connected device.
You've seen how to quickly connect devices. Now we'll try it one step at a time with the command line interface (CLI). You'll later send ZCL light on-off commands this way.
Start with boards prepared as follows.
|ARTIK 030 boards||Launch consoles in Simplicity. You've pre-loaded each device function as either HaSampleSwitchSoc or HaSampleLightSoc.|
|ARTIK 5/7/10 boards||Use the terminal emulator to start the daemon and then run
Here we manually create a network and join it. The software stacks are still doing most of the work, but you have to use the somewhat wordy CLI interface to get things going.
To find out whether any devices are already connected, type
on each console, and look to see whether
panIDvalues match. (Note: This won't show any output on
zigbee-cliunless you have enabled a journal.)
We want to start fresh, so we want them to not match. In each console, type
Verify, using a subsequent
infocommand, that the
panIDvalue for any one device no longer matches that of another.
On the device you have chosen to be Coordinator, type
network find unused
Remember that this won't work on an A030 with the pre-built images, which were built without Coordinator capability enabled.
Again on the Coordinator, type
network pjoin 90
to permit joining for 90 seconds by other devices.
On each of the other devices, type
network find joinable
You should see the "Device Announce" message on each console.
It's worth trying this exercise several times in different configurations to make sure you understand how it works. If you're on top of it and want to skip the additional details below, jump right to entering a ZCL command.
Compare code methods
Let's review how this all works. You can use various combinations of ARTIK 030, 5, 7, and 10 devices, along with other ZigBee-compatible devices, for a ZigBee network. Interacting with the different devices is mostly the same aside from some "shortcut" differences.
All ARTIK ZigBee devices use the same command line interface (CLI), although you could choose to remove this extension in your own custom code.
The ARTIK 030 code for HaSwitch and HaLight enables the CLI through the Simplicity console, which is very interactive and provides a lot of feedback. The code also configures the buttons on the board for shortcut methods as explained below.
The ARTIK 5/7/10 support is provided by an API, which we interact with using two utility programs:
zigbee-testprovides shortcut methods similar to the A030 board, but uses the console numeric keys instead
zigbee-cliimplements the same CLI as the Simplicity console, but requires a journal to be enabled if you want to see its output.
The A030 HaSampleLightSoc and HaSampleSwitchSoc pre-built images have the Coordinator feature disabled. If you want your ARTIK 030 to have the ability to form a network as Coordinator, just modify, regenerate, and recompile the code to enable the Coordinator role.
|Initialize as Light||select ||upload HaLight or press RESET|
|Initialize as Switch||select ||upload HaSwitch or press RESET|
Level Control Switch
* Not available in the ARTIK 030 pre-built binary files, but you can generate it in Simplicity Studio
Here are the steps to form and join the network. Remember, the A030 code we're using is not enabled to be Coordinator, but as a Router, so the PB1 functions are not available.
|1.||Leave existing network||Leave existing network||
|2.||Form a new network||
||push PB1 *|
||starts automatically after form complete
|push PB1 *|
|4.||Join the network||
* Not available in the pre-built program, but can be included before you generate it in Simplicity Studio
Note that the ARTIK 5/7/10 shortcut key
 first forms the network, and then does a one-time
pjoin. If you later want to let more devices join, use
 to start another
pjoin or do it manually in
Channel and Power. Networks can be formed on different IEEE 802.15.4 frequency channels, and at a specified transmission power.
PAN ID. The Personal Area Network (PAN) ID has to match for all devices. Multiple ZigBee networks can be overlaid, each with a different PAN ID, and there will be no "eavesdropping" possible between networks.
Using the CLI, have the Switch on ARTIK 5/7/10 form a network on channel 25, power 3, PAN ID of 0xabcd, and give the ARTIK 030 Light 15 seconds to join.
On ARTIK 5/7/10 Switch:
zigbee-cli ON_OFF_SWITCH network leave network form 25 3 0xabcd network pjoin 15
On ARTIK 030 Light:
network leave network find joinable
You should see an indication on the ARTIK 030 console that it has joined PAN 0xabcd.
If you were successful, feel free to jump right to entering a ZCL command.
In the example above, the ARTIK 5/7/10 Switch is the Coordinator and the ARTIK 030 Light is a simple router. Even though the router cannot form a network, it can become a parent to local end devices.
Let's say you have a smart button that you want to add to the existing network. The button uses all the same commands as you've seen above, but implements them using hardware "tricks" since it has no connection to a terminal console.
Force the smart button to leave any existing network.
- Pry out battery drawer
- Hold down on button
- Reinsert battery (you'll get a steady red LED)
- Keep button held for 2 seconds ("network leave")
Join button to network
- Set the ARTIK 030 Light to permit joining.
- Press PB0 ("network pjoin 30")
Command the smart button to join.
- Pry out battery drawer again
- Hold down on button
- Reinsert battery again but RELEASE button just after LED turns red
("network find joinable")
- Observe that the LED turns a dim blue and blinks
- Verify that it finds the network and the LED turns green to indicate NETWORK_JOINED
Bind button to light
Put the ARTIK 030 Light into EZ-Mode commissioning.
- Press PB1 ("enable ez-mode commissioning" for 10s)
- Press PB0 ("permit join")
Command the smart button to send a join request and identify query.
- Tap the button three times rapidly
Watch the action on the ARTIK 030 console.
- Observe the
- Observe the
The button is now bound to the light. It may take a few tries for you to understand the sequence. Note also that some of these buttons have known battery contact issues. But once you get around those you'll find this sequence is reliably reproducible.
When you click the button, you'll now see a message like this on the ARTIK 030 console to indicate ON:
Rx len 3 ep 01 clus 0x0006 (on/off) FC 01 seq 72 cmd 01
and one like this to indicate OFF:
Rx len 3 ep 01 clus 0x0006 (on/off) FC 01 seq 73 cmd 00
For your convenience, we summarize the example smart button controls in this table. Some are undocumented, we report only what we have seen during testing.
|Prior State||Action||Smart Button Function|
|Joined to previous network||Insert battery with button held 2s
(make sure no devices are permitting joining at this time)
(LED steady red)
|Not joined||Insert battery with button held; release immediately on seeing red||
(LED flashes blue )
|Joining||Coordinator permits join||Joined but not bound
(LED steady green then off)
|Joined but not bound||Tap button 3x||
|Joined but not bound||Tap button 5x||issues "rejoin request", "update device", and "device announce"|
|Joined and bound||Press button||
|Joined and bound||Release button||
If you have trouble getting ZigBee networks set up, make sure you have used
network leave (or a known hardware equivalent) on all devices to tear down previous networks before starting a fresh one. Pressing a device reset button alone is generally not sufficient.
Before starting the
zigbee-cli program, you can run this command to provide debug output that "follows" events live, as they occur.
journalctl -f | grep zigbeed &
You'll get messaging to help track down issues.
Running the journal is the only way to see output from the
You may find that the On/Off test of the
zigbee-testprogram will incorrectly report "there is no endpoint to send on/off command" unless you run the journal.
An alternative use of the command:
journalctl -f -o"cat" &
strips off the date stamp for cleaner output. You can't pipe this one to
grepsince it strips off the sort term "zigbeed", so you will also see other system events.
You can instead simply dump the output of
journalctl to a file to review it at any time (not following it live).
Command Devices using ZCL
Once you're connected, you can send your first ZigBee Cluster Library (ZCL) control message from Switch to Light.
This section continues on from where we left off at the CLI Example, using an ARTIK 030 as Light. If you're instead using an ARTIK 5/7/10 as Light, just make sure you enable the journal and then execute
zigbee-cli ON_OFF_LIGHT so that you can see the returned information.
infoon the Light console.
Search through the returned information, and find the
nodeIDvalue of the Light.
- On the Switch console, type the commands:
zcl on-off toggle
send <nodeID> 1 1
where you'll replace
<nodeID>with the value you found above, like '0x1023'.
- Observe on the Light console that an
on-offmessage has arrived.
That was all! You've controlled a light. When you're ready to learn more, about CLI and ZCL commands in particular, head over to the Command Libraries section.
Custom A030 Applications
We presented a simple introduction above to familiarize you with using ARTIK 030 devices in a ZigBee environment.
To begin developing your own custom applications, you must install the IAR Systems compiler environment. Go now to the IAR Embedded Workbench® ARM IDE section to get the software download underway. Follow the ARTIK 030 Software Getting Started Guide to complete your training.
The ZigBee 3.0 (Z3) example used in that document works between ARTIK 030 boards but will not work with the ARTIK 5/7/10 examples (ZigBee HA 1.2) provided here. Use the Simplicity HaSampleSwitchSoc and HaSampleLightSoc projects instead.
Custom A5/7/10 Applications
Our pre-built utility programs introduced you to using ARTIK Linux-based devices in a ZigBee environment. To develop your own ZigBee applications on an ARTIK 5/7/10 board, you'll generate the project files on your host PC but then copy them over to your ARTIK board to compile. All the compiler tools you'll need are already on the ARTIK board.
Recommended: Use ARTIK API with ARTIK IDE
The fastest and simplest approach to ZigBee development is to use the ZigBee API. You can use ZigBee API calls just like any other ARTIK API calls.
If you think this approach is right for you, start by recreating the
zigbee-test program in the ARTIK IDE section. Just compile and run!
Optional: Use ZigBee stackTHE INFORMATION IN THIS SECTION IS PRELIMINARY AND MAY NOT BE ACCURATE.
Customize your ZigBee development if you have special needs that go beyond the current ZigBee API capabilities, such as developing for ZigBee 3.0 (not yet supported in the API). As the approach described here requires deep knowledge of the ZigBee stack internals, we recommend that you try using the ZigBee API first.
You can only access the Simplicity Studio ZigBee stack for ARTIK 5/7/10 if you have also purchased an ARTIK 030 kit to register.
When you create an application, keep in mind that your program will be communicating directly over the UART interface with the NCP to send commands and receive data. You should first learn more about how the NCP and the ARTIK processor communicate. The NCP application note is a good place to start.
in the documentation folder:
Create NCP application. Follow this procedure on the development PC you used to install your ARTIK 030 Simplicity Studio software, which is prerequisite to developing ARTIK 5/7/10 applications.
If not present, create a new directory
builderinside this directory:
In Simplicity Studio 4.0, select File > Switch Workspace > Other to change the workspace to point to the directory you just created. After switching the workspace, Simplicity Studio 4.0 will restart.
- Create your project in Simplicity.
- Choose File > New > Project and create an AppBuilder project.
Select the ZCL application type.
Choose the Host stack, not the SoC stack.
Pick a project, such as XncpLed, or start from a blank one if you prefer.
Continue clicking Next and Finish to get to the main project. You can ignore chip selection and messages about boards and toolchains; they don't matter, as you will be compiling the code in its native environment.
Under the HAL Configuration tab, look under "Platform configuration" to set "Wireless Chip" to EM3587, and "Host" to Unix host. Set other tab information according to the device you're trying to create.
You'll also need to select the correct UART port and method.
Serial port Flow control 520 ttySAC1 rts-cts (hardware) 530 ttyAMA1 rts-cts (hardware) 710 ttySAC0 xon-xoff (software) 1020 ttySAC0 rts-cts (hardware)
Click Generate to produce the output files. Note that they are all under the \vx.x.x.x\app\builder\ directory.
- Close the Simplicity Studio program.
Compile under Linux. Follow this procedure to transfer source code to your ARTIK board for compilation.
Using a program like WinSCP, copy the
vx.x.x.xdirectory with all its subdirectories under
/rootdirectory on the ARTIK board.
On your ARTIK board Linux command line,
cdto your project directory
make NO_READLINE=1to begin compiling.
Your executable file is now here:
Run the program. Before you can run your program, you'll need to install and start the corresponding application on the radio chip side, as noted in AN1010-Customized-NCP.pdf. Then you can execute your program as you would any other.
When running your own applications, you must temporarily stop or permanently disable the installed API package software we have provided.
The following information refers to the Simplicity Studio HaSample… application code referenced in this article. Interpreter support for these commands is not guaranteed to be available in other ZigBee applications.
We present below the CLI commands as supported by the HaSample… application code.
The general serial commands on all devices are:
• help—shows what top-level commands are available
• version—gives the stack and application version
• info—gives information about the local node
• network form [channel] [power] [panid in hex]
• network join [channel] [power] [panid in hex]
• network leave
• network pjoin [time]
• print attr—print the ZCL attribute table
• print identify—print the identify cluster state
• print groups—print the groups table
• print scenes —print the scenes table
• print c (ias-ace info)—print the ias-ace info
• print report—print the reporting table
• write [cluster] [attrID] [dataLen] [data]
• stats—if HA_ENABLE_STATS is defined, then this command shows the number of received and transmitted messages
Save keytrokes by typing only enough characters to make the keyword unique. For example, instead of
network leave try
In addition, you may find the CLI examples in this User Guide to be helpful.
in the documentation folder:
The ZigBee Cluster Library (ZCL) standard is defined by the ZigBee Alliance to be for use by alliance members only.
We present below the ZCL commands supported by the CLI.
The following are CLI serial commands used for clusters. They construct a payload, so you must issue a
send call to send the message. That is, commands will be paired like this:
zcl ... send [Node ID] [src endpoint] [dst endpoint]
The following are global serial commands used for clusters.
• zcl global read [cluster] [attrID:2]
• zcl global write [cluster] [attrID:2] [type] [data]
• zcl global uwrite [cluster] [attrID:2] [type] [data]
• zcl global nwrite [cluster] [attrID:2] [type] [data]
• zcl global discover [cluster] [attrID:2] [max # to report]
• zcl global report-read [cluster] [attrID:2] [direction:1]
• zcl global send-me-a-report [cluster] [attrID:2] [type:1] [min:2] [max:2] [chg:1-4]
• zcl global expect-report-from-me [cluster] [attrID:2] [timeout:2]
There are also cluster-specific serial commands that are available on a per-cluster basis. The application must have defined the client side of the cluster to have access to all these commands.
• zcl basic rtfd
• zcl identify id [identify time:2]
• zcl identify query
• zcl groups add [grp ID:2] [name:16]
• zcl groups view [grp ID:2]
• zcl groups get [count:1] [[groupID:2] * count]
• zcl groups remove [grp ID:2]
• zcl groups rmall
• zcl groups ad-if-id [grp ID:2] [name:16]
• zcl scenes add [groupId:2] [sceneId:1] [trans time:1] [name:n]
• zcl scenes view [groupId:2] [sceneId:1]
• zcl scenes remove [groupId:2] [sceneId:1]
• zcl scenes rmall [groupId:2]
• zcl scenes store [groupId:2] [sceneId:1]
• zcl scenes recall [groupId:2] [sceneId:1]
• zcl scenes get-membership [groupId:2]
• zcl scenes set [on/off:1 boolean] [level:1 int]
• zcl on-off off
• zcl on-off on
• zcl on-off toggle
• zcl level-control mv-to-level [level:1] [trans time:2]
• zcl level-control move [mode:1] [rate:2]
• zcl level-control step [step:1] [step size:1] [trans time:2]
• zcl level-control stop
• zcl level-control o-mv-to-level [level:1] [trans time:2]
• zcl level-control o-move [mode:1] [rate:2]
• zcl level-control o-step [step:1] [step size:1] [trans time:2]
• zcl level-control o-stop
• zcl tstat set [mode:1 int] [amount:1 int]
• zcl ias-zone enroll [zone type: 2 int] [manuf code: 2 int]
• zcl ias-zone sc [zone status: 2 int] [ext status: 1 int]
• zcl ias-ace arm [mode: 1 int]
• zcl ias-ace bypass [numZones: 1 int] [zone: * int]
• zcl ias-ace emergency
• zcl ias-ace fire
• zcl ias-ace panic
• zcl ias-ace getzm
• zcl ias-ace getzi
The following command is unique.
• zcl raw [cluster] [len] [data 0-8] [data 9-16] [data 17-24] [data 25-32]
Once devices are joined, you can start sending ZigBee ZCL commands to them.
info shows what server and client clusters are supported by a device.
print attr (or the shorthand version
prints the attribute table that shows the cluster and attribute information. This is useful when sending read attributes commands. To create a read attributes command use:
zcl global read <cluster in decimal> <attribute in hex>
For instance, to create a read attributes for basic cluster (0), attribute ZCL version (0000), and send to Node ID 0xaabb:
zcl global read 0 0000 send aabb
To determine the short address of a device to send to, use the
info command and look for nodeID. For instance, if the command
print a shows this:
idx clus / attr /type(len)/ rw / data 00: 000A / 0000 / 23 (04) / WRITE / 00 01 50 05 (time)
then reading that attribute on a device with shortID/Node ID 0x5AAF is done as follows:
zcl global read 10 0000 send 5AAF
The result will be as follows:
RX len 0B, clus 0x000A (time) FC 00 seq 00 cmd 01 payload[00 00 00 23 B8 50 01 00 ]
The payload is attribute ID (0x0000), status (0x00), type (0x23), and value (0x00 01 50 B8)
ARTIK IDE ZigBee Test Project
If you'd like to start using the ZigBee API, we've got an easy project for you! You can use the ARTIK IDE to recreate the
zigbee-test program we used in this article, and then modify it for your own application.
- Go to ARTIK IDE – Linux Projects and follow the instructions.
When you get to the screen that lets you choose the application you want to develop, choose ZigBee.
Once the example loads, delete the
artik_zigbee_cli.cfile. It's there for your reference, but conflicts with
artik_zigbee_test.cif present at compile time.
- Compile and run the project as-is to verify that the code provided generates the utility program you have used throughout this article.
Now you can augment it to suit your needs. Have fun!