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 / 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 circuits, 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|
If you have Ubuntu, you are already set up as required. Skip this part.
For Fedora only:
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).