<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee</link><pubDate>Fri, 28 Jul 2023 20:36:51 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>dychen</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Current Revision posted to Documents by dychen on 7/28/2023 8:36:51 PM&lt;br /&gt;
&lt;p&gt;Zigbee is an open communication standard developed to enable low latency, low-power, secure, wireless IoT data networks.&lt;/p&gt;
&lt;h2 id="mcetoc_1h6ch781q0" class="essTitle xbold" title="Essentials of Zigbee"&gt;&lt;a name="top"&gt;&lt;/a&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img style="padding-right:18px;vertical-align:middle;" alt="essentials logo" src="/e14/assets/legacy/2017/learningess.png" width="175px" /&gt;&lt;/a&gt;Wireless Protocol Series - Part 6 - Essentials of Zigbee&lt;/h2&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from Zigbee&amp;rsquo;s enabling a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some Zigbee devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;br /&gt; &lt;strong&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/strong&gt; | &lt;strong&gt;&lt;a href="#test"&gt;Test Your Knowledge &lt;img loading="lazy" style="vertical-align:middle;" alt="test link" src="/e14/assets/legacy/gen/LinkArrow.gif" /&gt;&lt;/a&gt; &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For more information on Zigbee, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials-wirelessprotocol6-doc"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1h6ch781q1" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;2. Objectives&lt;/h2&gt;
&lt;hr style="margin:0;" /&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1h6ch781q2" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;3. Basic Concepts&lt;/h2&gt;
&lt;div class="xbold" style="display:inline-block;font-size:11px;text-align:right;vertical-align:middle;width:24%;"&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/div&gt;
&lt;hr style="margin:0;" /&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 1: Zigbee Topology&lt;/h5&gt;
&lt;/center&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Analysis&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Zigbee Networking &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Zigbee Security &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Zigbee Applications&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- The Zigbee Development Environment&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-2f99e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2f99e'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-16ebd" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('16ebd'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-01d20" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('01d20'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-c1ab2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c1ab2'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;h5&gt;Figure 2: Zigbee Modules&lt;/h5&gt;
&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials-wirelessprotocol6-doc"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 3: Zigbee USB Adapter&lt;/h5&gt;
&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-a3dfb" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a3dfb'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/h5&gt;
&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/h5&gt;
&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;h2 id="mcetoc_1h6ch781q3" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;4. Glossary&lt;/h2&gt;
&lt;div class="xbold" style="display:inline-block;font-size:11px;text-align:right;vertical-align:middle;width:24%;"&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/div&gt;
&lt;hr style="margin:0;" /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/h5&gt;
&lt;div style="border-bottom:1px solid #555555;padding-bottom:10px;"&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Profile image" height="110" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-0944b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('0944b'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-41742" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('41742'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-aaf8f" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('aaf8f'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-73574" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('73574'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-18dd4" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('18dd4'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-fa6b8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('fa6b8'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-3f45f" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3f45f'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;h2 id="mcetoc_1h6ch781q4" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;Test Your Knowledge&lt;/h2&gt;
&lt;div class="xbold" style="display:inline-block;font-size:11px;text-align:right;vertical-align:middle;width:24%;"&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/div&gt;
&lt;div style="float:left;padding-bottom:2px;padding-right:10px;width:150px;"&gt;            
&lt;style&gt;
   .e14-achievement-name{font-size:14px;font-weight:700;text-align:center;height:40px;margin:0;padding:5px}.e14-avatar{width:50% !important;margin:auto;border-radius:500px}.e14-avatar img{border-radius:543px}.e14-progress-bar{height:12px;border-radius:6px;background-clip:padding-box;background:#3575c2}.e14-achievement-thumb{height:200px}.e14-achievement-criteria{font-size:10px !important;overflow:hidden;margin-bottom:10px;line-height:1.5;height:60px}.e14-achievement-criteria p{font-size:10px !important;overflow:hidden;margin-bottom:10px;line-height:1.5;height:60px}.e14-achievement-criteria.complete{height:38px}.e14-achievement-criteria.complete p{height:38px}.e14-greyout{-webkit-filter:grayscale(90%);-moz-filter:grayscale(90%);-o-filter:grayscale(90%);-ms-filter:grayscale(90%);filter:grayscale(90%)}.e14-complete{float:right;margin-top:-20px;padding-right:5px;margin-bottom:12px;font-weight:700;color:dimgray}.e14-achievement-status{margin:5px}.shimmer{position:relative;overflow:hidden;background:#f6f7f8;background:linear-gradient(-45deg,#eee 40%,#fafafa 50%,#eee 60%);background-size:300%;background-position-x:100%;animation:shimmer 8s infinite linear}@keyframes shimmer{0%{background-position:-1000px 0}
100%{background-position:1000px 0}}
@media only screen and (max-width:480px){.e14-achievement-criteria{display:none}.e14-complete{font-size:9px}.e14-user-achievement{width:100px !important;height:150px !important}.e14-achievement-status{margin-top:15px}.e14-achievement-thumb{height:130px}.e14-achievement-name{font-size:10px}} 
&lt;/style&gt;

    &lt;div id="embed-d7757597b10e4acbb360eed926b17dce_thumbnails" data-columnclass="thumbnail-column"&gt;
        &lt;div class="content thumbnail e14-user-achievement" data-href="/achievements/2db6a175-13d4-436b-a70d-13815dfbbb00" style="border: 3px solid #8d8d8d;cursor: pointer;"&gt;
        	       &lt;h2 class="name e14-achievement-name"&gt;
    		            Wireless Protocol 6&lt;br&gt;
    		       &lt;/h2&gt;
    			&lt;div class="e14-avatar e14-greyout"&gt;
    				&lt;img loading="lazy" src="https://community-storage.element14.com/communityserver-components-imagefileviewer/achievements/2db6a17513d4436ba70d13815dfbbb00/WirelessP6Badge.png-140x140x2.png?_=SIGfoQqESNAQUtf0zrJW7A==" style="width: 140px;max-height:140px;overflow:hidden;background:url(&amp;#39;https://community-storage.element14.com/communityserver-components-imagefileviewer/achievements/2db6a17513d4436ba70d13815dfbbb00/WirelessP6Badge.png-140x140x2.png?_=SIGfoQqESNAQUtf0zrJW7A==&amp;#39;) center center no-repeat;background-size:cover;aspect-ratio:140/140" alt="Wireless Protocol 6" border="0" /&gt;
    		    &lt;/div&gt;
    		    &lt;div style="padding:5px;"&gt;
    		        &lt;div title="Complete our Essentials: Wireless Protocol&amp;nbsp;6 course, take the quiz, and leave your feedback to earn this badge." class="e14-achievement-criteria"&gt;Complete our Essentials: Wireless Protocol 6 course, take the quiz, and leave your feedback...&lt;/div&gt;
    		        
    		    &lt;/div&gt;
    		&lt;/div&gt;
    &lt;/div&gt;   
&lt;/script&gt;&lt;/div&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;center&gt;
&lt;h3 id="mcetoc_1h6ch781q5" style="clear:both;"&gt;For more wireless protocol modules click on the next button.&lt;/h3&gt;
&lt;/center&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;a href="/w/documents/28137/matter-smart-home-protocol?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-next"&gt;Next&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, python, home automation, smart devices, low power, industrial automation, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/18</link><pubDate>Thu, 27 Jul 2023 20:48:51 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 18 posted to Documents by pchan on 7/27/2023 8:48:51 PM&lt;br /&gt;
&lt;p&gt;Zigbee is an open communication standard developed to enable low latency, low-power, secure, wireless IoT data networks.&lt;/p&gt;
&lt;h2 id="mcetoc_1h6ch781q0" class="essTitle xbold" title="Essentials of Zigbee"&gt;&lt;a name="top"&gt;&lt;/a&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img style="padding-right:18px;vertical-align:middle;" alt="essentials logo" src="/e14/assets/legacy/2017/learningess.png" width="175px" /&gt;&lt;/a&gt;Wireless Protocol Series - Part 6 - Essentials of Zigbee&lt;/h2&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from Zigbee&amp;rsquo;s enabling a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some Zigbee devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;br /&gt; &lt;strong&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/strong&gt; | &lt;strong&gt;&lt;a href="#test"&gt;Test Your Knowledge &lt;img loading="lazy" style="vertical-align:middle;" alt="test link" src="/e14/assets/legacy/gen/LinkArrow.gif" /&gt;&lt;/a&gt; &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For more information on Zigbee, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials-wirelessprotocol6-doc"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1h6ch781q1" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;2. Objectives&lt;/h2&gt;
&lt;hr style="margin:0;" /&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1h6ch781q2" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;3. Basic Concepts&lt;/h2&gt;
&lt;div class="xbold" style="display:inline-block;font-size:11px;text-align:right;vertical-align:middle;width:24%;"&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/div&gt;
&lt;hr style="margin:0;" /&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 1: Zigbee Topology&lt;/h5&gt;
&lt;/center&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Analysis&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Zigbee Networking &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Zigbee Security &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- Zigbee Applications&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p class="xbold"&gt;&lt;i&gt;- The Zigbee Development Environment&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-7d218" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('7d218'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-414a1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('414a1'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-3957f" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3957f'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-73a09" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('73a09'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;h5&gt;Figure 2: Zigbee Modules&lt;/h5&gt;
&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials-wirelessprotocol6-doc"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 3: Zigbee USB Adapter&lt;/h5&gt;
&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-03cf7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('03cf7'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/h5&gt;
&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt;
&lt;h5&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/h5&gt;
&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;h2 id="mcetoc_1h6ch781q3" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;4. Glossary&lt;/h2&gt;
&lt;div class="xbold" style="display:inline-block;font-size:11px;text-align:right;vertical-align:middle;width:24%;"&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/div&gt;
&lt;hr style="margin:0;" /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/h5&gt;
&lt;div style="border-bottom:1px solid #555555;padding-bottom:10px;"&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Profile image" height="110" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-2dd40" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2dd40'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-26b77" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('26b77'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-40371" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('40371'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-f9bf6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('f9bf6'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-72cea" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('72cea'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-12b75" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('12b75'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-2393a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;CMP=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc&amp;osetc=e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2393a'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cmpoverride="e14c-referral-cmty-handler-essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;h2 id="mcetoc_1h6ch781q4" class="xbold" style="color:#007fac;display:inline-block;vertical-align:middle;width:75%;"&gt;Test Your Knowledge&lt;/h2&gt;
&lt;div class="xbold" style="display:inline-block;font-size:11px;text-align:right;vertical-align:middle;width:24%;"&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/div&gt;
&lt;div style="float:left;padding-bottom:2px;padding-right:10px;width:150px;"&gt;            
&lt;style&gt;
   .e14-achievement-name{font-size:14px;font-weight:700;text-align:center;height:40px;margin:0;padding:5px}.e14-avatar{width:50% !important;margin:auto;border-radius:500px}.e14-avatar img{border-radius:543px}.e14-progress-bar{height:12px;border-radius:6px;background-clip:padding-box;background:#3575c2}.e14-achievement-thumb{height:200px}.e14-achievement-criteria{font-size:10px !important;overflow:hidden;margin-bottom:10px;line-height:1.5;height:60px}.e14-achievement-criteria p{font-size:10px !important;overflow:hidden;margin-bottom:10px;line-height:1.5;height:60px}.e14-achievement-criteria.complete{height:38px}.e14-achievement-criteria.complete p{height:38px}.e14-greyout{-webkit-filter:grayscale(90%);-moz-filter:grayscale(90%);-o-filter:grayscale(90%);-ms-filter:grayscale(90%);filter:grayscale(90%)}.e14-complete{float:right;margin-top:-20px;padding-right:5px;margin-bottom:12px;font-weight:700;color:dimgray}.e14-achievement-status{margin:5px}.shimmer{position:relative;overflow:hidden;background:#f6f7f8;background:linear-gradient(-45deg,#eee 40%,#fafafa 50%,#eee 60%);background-size:300%;background-position-x:100%;animation:shimmer 8s infinite linear}@keyframes shimmer{0%{background-position:-1000px 0}
100%{background-position:1000px 0}}
@media only screen and (max-width:480px){.e14-achievement-criteria{display:none}.e14-complete{font-size:9px}.e14-user-achievement{width:100px !important;height:150px !important}.e14-achievement-status{margin-top:15px}.e14-achievement-thumb{height:130px}.e14-achievement-name{font-size:10px}} 
&lt;/style&gt;

    &lt;div id="embed-d7757597b10e4acbb360eed926b17dce_thumbnails" data-columnclass="thumbnail-column"&gt;
        &lt;div class="content thumbnail e14-user-achievement" data-href="/achievements/2db6a175-13d4-436b-a70d-13815dfbbb00" style="border: 3px solid #8d8d8d;cursor: pointer;"&gt;
        	       &lt;h2 class="name e14-achievement-name"&gt;
    		            Wireless Protocol 6&lt;br&gt;
    		       &lt;/h2&gt;
    			&lt;div class="e14-avatar e14-greyout"&gt;
    				&lt;img loading="lazy" src="https://community-storage.element14.com/communityserver-components-imagefileviewer/achievements/2db6a17513d4436ba70d13815dfbbb00/WirelessP6Badge.png-140x140x2.png?_=SIGfoQqESNAQUtf0zrJW7A==" style="width: 140px;max-height:140px;overflow:hidden;background:url(&amp;#39;https://community-storage.element14.com/communityserver-components-imagefileviewer/achievements/2db6a17513d4436ba70d13815dfbbb00/WirelessP6Badge.png-140x140x2.png?_=SIGfoQqESNAQUtf0zrJW7A==&amp;#39;) center center no-repeat;background-size:cover;aspect-ratio:140/140" alt="Wireless Protocol 6" border="0" /&gt;
    		    &lt;/div&gt;
    		    &lt;div style="padding:5px;"&gt;
    		        &lt;div title="Complete our Essentials: Wireless Protocol&amp;nbsp;6 course, take the quiz, and leave your feedback to earn this badge." class="e14-achievement-criteria"&gt;Complete our Essentials: Wireless Protocol 6 course, take the quiz, and leave your feedback...&lt;/div&gt;
    		        
    		    &lt;/div&gt;
    		&lt;/div&gt;
    &lt;/div&gt;   
&lt;/script&gt;&lt;/div&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;center&gt;
&lt;h3 id="mcetoc_1h6ch781q5" style="clear:both;"&gt;For more wireless protocol modules click on the next button.&lt;/h3&gt;
&lt;/center&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;a href="/w/documents/28137/matter-smart-home-protocol?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-next"&gt;Next&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/17</link><pubDate>Fri, 26 May 2023 19:14:04 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 17 posted to Documents by pchan on 5/26/2023 7:14:04 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard developed to enable low latency, low-power, secure, wireless IoT data networks.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;a href="/w/documents/28137/matter-smart-home-protocol?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-next"&gt;Next&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from Zigbee&amp;rsquo;s enabling a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some Zigbee devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Zigbee, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials-wirelessprotocol6-doc"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-b3cd3" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b3cd3'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-d8914" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d8914'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-1a214" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('1a214'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-f4e23" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('f4e23'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials-wirelessprotocol6-doc"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-3a572" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3a572'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-e1da6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e1da6'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-cf58e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('cf58e'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-7718a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('7718a'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-90b22" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('90b22'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-330ed" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('330ed'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-50728" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('50728'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-c4d3f" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c4d3f'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/16</link><pubDate>Wed, 09 Nov 2022 21:40:02 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 16 posted to Documents by pchan on 11/9/2022 9:40:02 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard developed to enable low latency, low-power, secure, wireless IoT data networks.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from Zigbee&amp;rsquo;s enabling a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some Zigbee devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Zigbee, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials-wirelessprotocol6-doc"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-dd468" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('dd468'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-25ca7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('25ca7'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-bcf09" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bcf09'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-a10e5" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a10e5'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials-wirelessprotocol6-doc"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-6473d" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('6473d'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-661ab" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('661ab'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-bc13e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bc13e'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-e3b68" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e3b68'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-d9a86" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d9a86'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-4f761" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4f761'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a2773" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a2773'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a942a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a942a'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/15</link><pubDate>Wed, 09 Nov 2022 20:04:25 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 15 posted to Documents by pchan on 11/9/2022 8:04:25 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard developed to enable low latency, low-power, secure, wireless IoT data networks.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from Zigbee&amp;rsquo;s enabling a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some Zigbee devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Zigbee, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-64c34" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('64c34'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-2d30c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2d30c'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-004a6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('004a6'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-43204" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('43204'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-f07ec" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('f07ec'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-8683e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8683e'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-98c0a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('98c0a'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a0b83" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a0b83'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-92291" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('92291'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-2f359" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2f359'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-155b5" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('155b5'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-378de" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('378de'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/14</link><pubDate>Wed, 09 Nov 2022 20:02:33 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 14 posted to Documents by pchan on 11/9/2022 8:02:33 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard developed to enable low latency, low-power, secure, wireless IoT data networks.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from Zigbee&amp;rsquo;s enabling a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some Zigbee devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-15577" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('15577'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-79191" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('79191'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-9f28c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9f28c'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-95218" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('95218'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-656ef" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('656ef'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-76c10" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('76c10'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-288a7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('288a7'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-cbb26" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('cbb26'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-9e6b4" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9e6b4'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-536a9" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('536a9'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-8082b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8082b'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-dfe68" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('dfe68'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/13</link><pubDate>Tue, 08 Nov 2022 17:09:14 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>srutledge</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 13 posted to Documents by srutledge on 11/8/2022 5:09:14 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard for wireless IoT devices that features low latencies, low power consumption,&amp;nbsp;and support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-d1a82" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d1a82'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-7f37e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('7f37e'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-55443" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('55443'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-a7486" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a7486'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-330ba" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('330ba'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-b443b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b443b'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-d2520" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d2520'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-2b526" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2b526'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-b51d1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b51d1'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-58740" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('58740'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-8baba" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8baba'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-62b99" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('62b99'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/12</link><pubDate>Tue, 08 Nov 2022 16:54:01 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 12 posted to Documents by pchan on 11/8/2022 4:54:01 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-ebefe" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('ebefe'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-35b64" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('35b64'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-901cf" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('901cf'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-b7534" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b7534'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-4d3db" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4d3db'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-d0bfc" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d0bfc'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-e083d" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e083d'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-50f31" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('50f31'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-c9bcf" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c9bcf'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-68178" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('68178'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-3233c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3233c'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-884b8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('884b8'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of Zigbee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/11</link><pubDate>Tue, 08 Nov 2022 16:51:25 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 11 posted to Documents by pchan on 11/8/2022 4:51:25 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;Zigbee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of Zigbee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of Zigbee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zigbee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. Zigbee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use Zigbee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the Zigbee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe Zigbee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of Zigbee&lt;/li&gt;
&lt;li&gt;Discuss Zigbee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The Zigbee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the Zigbee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: Zigbee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the Zigbee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different Zigbee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for Zigbee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the Zigbee stack. It comprises the Application Support (APS) sub-layer and Zigbee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. Zigbee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. Zigbee also supports the tree topology. A Zigbee coordinator (PAN coordinator) establishes the initial network, and Zigbee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The Zigbee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. Zigbee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Zigbee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of Zigbee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the Zigbee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;Zigbee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; Zigbee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via Zigbee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The Zigbee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A Zigbee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the Zigbee Alliance), and comprises a radio, Zigbee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of Zigbee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop Zigbee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-6dbd8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('6dbd8'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 Zigbee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-935fe" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('935fe'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Zigbee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-99cc7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('99cc7'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigbeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-bafea" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bafea'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: Zigbee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control Zigbee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and Zigbee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the Zigbee2MQTT library to control Zigbee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. Zigbee2MQTT works with a variety of Zigbee USB adapters and devices. Although the code was developed for a Raspberry Pi with a Zigbee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigbeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: Zigbee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A Zigbee adapter is the interface that enables Zigbee on the computer (or server). Several types of Zigbee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-905f2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('905f2'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support Zigbee. With the proper hardware and software, many other platforms also support Zigbee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the Zigbee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:600;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the Zigbee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the Zigbee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. Zigbee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via Zigbee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;Zigbee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-174ab" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('174ab'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-d7cb2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d7cb2'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-20895" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('20895'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST Zigbee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-9094e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9094e'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-6a1e0" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('6a1e0'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-75ef0" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('75ef0'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-bf0ae" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bf0ae'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more Zigbee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/10</link><pubDate>Sat, 05 Nov 2022 20:18:54 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>dychen</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 10 posted to Documents by dychen on 11/5/2022 8:18:54 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-16e1c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('16e1c'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-c6e35" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c6e35'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-4283d" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4283d'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-26b7c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('26b7c'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This developer tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-bf9f3" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bf9f3'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, &lt;/i&gt;and&lt;i&gt; MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, &lt;/i&gt;and&lt;i&gt; BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-2a84b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2a84b'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-1e3df" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('1e3df'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-ab028" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('ab028'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-140f2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('140f2'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-9ef6e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9ef6e'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-e3d02" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e3d02'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-185aa" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('185aa'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/9</link><pubDate>Sat, 05 Nov 2022 20:14:12 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>dychen</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 9 posted to Documents by dychen on 11/5/2022 8:14:12 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-8cfd2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8cfd2'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-16e7a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('16e7a'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-0ddd5" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('0ddd5'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-7f5f5" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('7f5f5'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This developer tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-dbb59" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('dbb59'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-8d1eb" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8d1eb'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-bfe88" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bfe88'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-67e65" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('67e65'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-ecd1e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('ecd1e'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-bda1a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bda1a'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-f0748" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('f0748'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a30b1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a30b1'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: iiot, mqtt, low power, iot, wireless, connectivity, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/8</link><pubDate>Sat, 05 Nov 2022 19:52:42 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>dychen</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 8 posted to Documents by dychen on 11/5/2022 7:52:42 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-60856" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('60856'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-2475a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2475a'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-193e7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('193e7'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-fdf7c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('fdf7c'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This developer tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-14a9f" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('14a9f'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-9ccd9" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9ccd9'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-1f8de" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('1f8de'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-06edb" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('06edb'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-0b941" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('0b941'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-3ca27" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3ca27'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-da033" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('da033'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-6edd8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('6edd8'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your Zigbee knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/7</link><pubDate>Fri, 04 Nov 2022 22:09:36 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 7 posted to Documents by pchan on 11/4/2022 10:09:36 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials-wirelessprotocol6-doc"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials-wirelessprotocol6-doc"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Home Automation&lt;/span&gt;&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Industrial Automation&lt;/span&gt;&lt;br /&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Consumer Electronics&lt;/span&gt;&lt;br /&gt; ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Healthcare&lt;/span&gt;&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-83048" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('83048'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-3ff53" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3ff53'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-9d3b1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9d3b1'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-b20fd" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b20fd'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Application Development&lt;/span&gt;&lt;br /&gt;This developer tutorial demonstrates basic application development, using the &lt;a href="/products/raspberry-pi" data-icid="essentials"&gt;Raspberry Pi&lt;/a&gt; to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p&gt;&lt;span class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/span&gt;&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-a43f7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a43f7'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;span class="xbold"&gt;Software&lt;/span&gt;&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:500;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-89c91" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('89c91'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-edfd1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('edfd1'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-9fbf3" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9fbf3'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-51c11" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('51c11'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-086a2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('086a2'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-4fdcb" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4fdcb'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-4dacc" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4dacc'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/6</link><pubDate>Fri, 04 Nov 2022 22:01:24 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 6 posted to Documents by pchan on 11/4/2022 10:01:24 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;p class="xbold"&gt;Home Automation&lt;br /&gt; A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Industrial Automation&lt;br /&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;p class="xbold"&gt;Consumer Electronics&lt;br /&gt; ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;p class="xbold"&gt;Healthcare&lt;br /&gt; In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-fae23" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('fae23'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-be0a4" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('be0a4'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-70d52" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('70d52'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-535bf" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('535bf'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p class="xbold"&gt;Application Development&lt;br /&gt;This developer tutorial demonstrates basic application development, using the Raspberry Pi to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;p class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;br /&gt; Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;p class="xbold"&gt;Hardware&lt;/p&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4:&amp;nbsp;&lt;a id="e14-product-link-d61e6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3051886,3051887,3369503&amp;nsku=02AH3162,02AH3164,64AH2041&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d61e6'));" data-farnell="3051886,3051887,3369503" data-newark="02AH3162,02AH3164,64AH2041" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Raspberry Pi&lt;/a&gt; &amp;nbsp;Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;p class="xbold" style="clear:both;"&gt;Software&lt;br /&gt; The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:300;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:300;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;font-weight:300;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;font-size:15px;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-4f170" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4f170'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-c4d85" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c4d85'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-c6541" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c6541'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-98748" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('98748'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-bac2b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bac2b'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-85ef7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('85ef7'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-18ccc" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('18ccc'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/5</link><pubDate>Fri, 04 Nov 2022 20:54:39 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 5 posted to Documents by pchan on 11/4/2022 8:54:39 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" height="270" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" width="395" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Home automation&lt;/h4&gt;
&lt;p&gt;A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Industrial Automation&lt;/h4&gt;
&lt;p&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Consumer Electronics&lt;/h4&gt;
&lt;p&gt;ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Healthcare&lt;/h4&gt;
&lt;p&gt;In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-17d40" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('17d40'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-fc546" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('fc546'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-7ae39" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('7ae39'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-d1f09" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d1f09'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;strong&gt;Application Development&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This developer tutorial demonstrates basic application development, using the Raspberry Pi to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/h4&gt;
&lt;p&gt;Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Hardware&lt;/h4&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4: Raspberry Pi Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;h4 style="clear:both;"&gt;&lt;b&gt;Software&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-02f05" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('02f05'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-27e07" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('27e07'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-ba951" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('ba951'));" data-farnell="3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-b102e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b102e'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-2b227" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2b227'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-aea5e" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('aea5e'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a7633" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a7633'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/4</link><pubDate>Fri, 04 Nov 2022 20:49:13 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 4 posted to Documents by pchan on 11/4/2022 8:49:13 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Home automation&lt;/h4&gt;
&lt;p&gt;A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Industrial Automation&lt;/h4&gt;
&lt;p&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Consumer Electronics&lt;/h4&gt;
&lt;p&gt;ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Healthcare&lt;/h4&gt;
&lt;p&gt;In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-0e8d4" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('0e8d4'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-775cf" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('775cf'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-73b30" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('73b30'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-e1efb" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e1efb'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;strong&gt;Application Development&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This developer tutorial demonstrates basic application development, using the Raspberry Pi to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/h4&gt;
&lt;p&gt;Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Hardware&lt;/h4&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4: Raspberry Pi Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:150px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;h4 style="clear:both;"&gt;&lt;b&gt;Software&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-bc1c1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bc1c1'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-c566d" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c566d'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-b31ba" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku= 3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b31ba'));" data-farnell=" 3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-2a8e8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2a8e8'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a8cdc" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a8cdc'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-fd542" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('fd542'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-9b8f8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9b8f8'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/3</link><pubDate>Fri, 04 Nov 2022 20:47:49 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 3 posted to Documents by pchan on 11/4/2022 8:47:49 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Home automation&lt;/h4&gt;
&lt;p&gt;A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Industrial Automation&lt;/h4&gt;
&lt;p&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Consumer Electronics&lt;/h4&gt;
&lt;p&gt;ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Healthcare&lt;/h4&gt;
&lt;p&gt;In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/DigiXBee3ZigbeeEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-bbdbe" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('bbdbe'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/OnsemiGreenPwrKtEss.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-e5b4b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e5b4b'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/DigiXbee2Ess.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-a7e87" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a7e87'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:230px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-51817" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('51817'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;strong&gt;Application Development&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This developer tutorial demonstrates basic application development, using the Raspberry Pi to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/h4&gt;
&lt;p&gt;Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Hardware&lt;/h4&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:220px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/ZigBeeUSBEss.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/raspberrypi4Ess.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4: Raspberry Pi Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:100px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/IkeaZigbeeBulb.jpg" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;h4 style="clear:both;"&gt;Software&lt;/h4&gt;
&lt;p&gt;The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="font-size:1.2em;margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/Esszigbee_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/MGM12P32_22_F1024GE_AEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-0b01c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('0b01c'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-2c3c8" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2c3c8'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/PTM535BZTransmitterEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-7a8f4" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku= 3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('7a8f4'));" data-farnell=" 3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/XB3_24Z8STZigbeeEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-8a148" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8a148'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/SLWSTK6102AWirelessEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-9d674" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('9d674'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/1323XNSKBDM_DevBDEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-336ef" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('336ef'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:230px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/EM34XVRDK_DevKtEss.png" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-859ea" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('859ea'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/WirelessP6Badge.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/2</link><pubDate>Wed, 02 Nov 2022 21:48:11 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 2 posted to Documents by pchan on 11/2/2022 9:48:11 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol1.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;- Analysis&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol style="font-size:1.2em;"&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Networking &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Security &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- ZigBee Applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Home automation&lt;/h4&gt;
&lt;p&gt;A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Industrial Automation&lt;/h4&gt;
&lt;p&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Consumer Electronics&lt;/h4&gt;
&lt;p&gt;ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Healthcare&lt;/h4&gt;
&lt;p&gt;In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;- The ZigBee Development Environment&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:240px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/diagram2a_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-2cd00" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('2cd00'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:245px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/diagram2b_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-5d6aa" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('5d6aa'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:240px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/diagram2c_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-3c53a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3c53a'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:245px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/diagram2d_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-4ac98" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('4ac98'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;strong&gt;Application Development&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This developer tutorial demonstrates basic application development, using the Raspberry Pi to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Light control using Raspberry Pi and ZigBee&lt;/h4&gt;
&lt;p&gt;Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;h4 class="xbold"&gt;Hardware&lt;/h4&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:200px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/diagram3_wirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:200px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/diagram4_wirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4: Raspberry Pi Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:200px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/diagram5_wirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;h4 style="clear:both;"&gt;Software&lt;/h4&gt;
&lt;p&gt;The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/wirelessprotocol6_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-a3767" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a3767'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-abfee" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('abfee'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-58fc2" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku= 3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('58fc2'));" data-farnell=" 3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-53bcb" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('53bcb'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-641b9" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('641b9'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-49b59" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('49b59'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-50eb6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('50eb6'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/motorcontrol2BDG.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item><item><title>Essentials of ZigBee</title><link>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee/revision/1</link><pubDate>Wed, 02 Nov 2022 21:41:27 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19b38aa7-6dbe-46dc-8d58-e1c14650428d</guid><dc:creator>pchan</dc:creator><comments>https://community.element14.com/learn/learning-center/essentials/w/documents/27860/essentials-of-zigbee#comments</comments><description>Revision 1 posted to Documents by pchan on 11/2/2022 9:41:27 PM&lt;br /&gt;
&lt;div style="padding-bottom:4px;"&gt;ZigBee is an open communication standard for wireless IoT devices that features low latencies, low power consumption, as well as support for multiple network topologies.&lt;/div&gt;
&lt;p&gt;&lt;div class="e14-navigation-buttons"&gt;&lt;a href="/w/documents/27815/learn-the-basics-and-implementations-of-bluetooth-le-audio-and-its-applications?ICID=essentials-wirelessprotocol6-doc"&gt;
                    &lt;button class="e14-nav-button-prev"&gt;Previous&lt;/button&gt;
                &lt;/a&gt;&lt;/div&gt;&lt;script&gt;e14.func.queueScripts.add(function(){ e14.func.repositionNavButtons(); })&lt;/script&gt;&lt;/p&gt;
&lt;div style="background-color:#f9f9f9;border:1px solid #c6c6c6;display:block;float:right;padding:6px 8px;width:212px;"&gt;&lt;a href="/learn/learning-center/" data-icid="essentials"&gt;element14 Learning Center&lt;/a&gt;&lt;/div&gt;
&lt;div style="border-bottom:1px solid #c6c6c6;border-top:1px solid #c6c6c6;clear:both;padding:8px;"&gt;
&lt;div style="display:inline-block;padding-right:16px;vertical-align:top;"&gt;&lt;a href="/learn/learning-center/essentials" data-icid="essentials"&gt;&lt;img alt="essentials logo" src="/e14/assets/main/2021/LC_essentiallogo_37h.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="display:inline-block;"&gt;
&lt;p class="essTitle" style="font-size:18px;font-weight:bold;" title="Essentials of ZigBee"&gt;&lt;span style="color:#007fac;"&gt;Wireless Protocol VI:&lt;/span&gt; Essentials of ZigBee&lt;/p&gt;
&lt;/div&gt;
&lt;hr /&gt;&lt;span style="padding-right:6px;"&gt;&lt;a href="#intro"&gt;1. Introduction &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#object"&gt; 2. Objectives &lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec3"&gt; 3. Basic Concepts&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#sec4"&gt;4. Glossary&lt;/a&gt;&lt;/span&gt; | &lt;span style="padding:0px 6px;"&gt;&lt;a href="#components"&gt;Related Components&lt;/a&gt;&lt;/span&gt; | &lt;span style="font-weight:bold;padding:0px 6px;"&gt;&lt;a href="#test"&gt;Take the Quiz &lt;i class="text-orange xs-ml05 fas fa-caret-right"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:15px;padding:0px 0px;"&gt;&lt;a name="intro"&gt;&lt;/a&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ZigBee is a popular communication protocol used in many modern sensor and control networks, including home and industrial automation. ZigBee was developed as an open connectivity standard for wireless IoT networks. Its growing popularity stems from a variety of useful features, including low latency, support for multiple network topologies, and low power consumption; some devices can have battery life lasting several years. Wireless devices that use ZigBee operate in unlicensed radio bands, including 868 MHz, 915 MHz, and 2.4 GHz frequency bands. This learning module is an introduction to the ZigBee protocol, spanning the technology, architecture, applications, and development tools.&lt;/p&gt;
&lt;p&gt;For more information on Home Automation, take a look at our eBook: &lt;a href="/w/documents/27842/home-automation-with-the-raspberry-pi---ebook" data-icid="essentials"&gt;Home Automation with the Raspberry Pi&lt;/a&gt;.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;&lt;strong&gt;2. Objectives&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-top:8px;"&gt;Upon completion of this module, you will be able to:&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;Describe ZigBee technology and communication protocols&lt;/li&gt;
&lt;li&gt;Understand the concepts underlying the technology&lt;/li&gt;
&lt;li&gt;Discuss various applications of ZigBee&lt;/li&gt;
&lt;li&gt;Discuss ZigBee development, including hardware and software&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="sec3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;3. Basic Concepts&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The ZigBee network layer supports star, tree, and mesh topologies. In mesh and tree topologies, the ZigBee coordinator forms the personal area network (PAN) and chooses specific key network parameters, such as assigning addresses. Mesh networks allow full peer-to-peer communication.&lt;/p&gt;
&lt;div&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 1" src="/e14/assets/main/2022b/diagram1_Esswirelessprotocol1.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 1: ZigBee Topology&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Analysis&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee architecture is a protocol stack with five layers.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Application Layer&lt;/li&gt;
&lt;li&gt;Security Layer&lt;/li&gt;
&lt;li&gt;Network Layer&lt;/li&gt;
&lt;li&gt;Medium Access Control (MAC) Layer&lt;/li&gt;
&lt;li&gt;Physical (PHY) Layer&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; The PHY layer is the lowest layer and closest to the hardware. This layer directly controls and communicates with the ZigBee radio. The physical layer translates the data packets in over-the-air bits for transmission and vice-versa during reception.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; The MAC layer works as an interface between the network and physical layer, controlling access and resolving conflict between competing nodes. The MAC layer provides PAN ID and also network discovery via beacon requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer:&lt;/strong&gt; The Network Layer is responsible for routing and establishing the different ZigBee topologies. The network layer acts as an interface between the MAC and application layers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security Layer: &lt;/strong&gt; The Security Layer handles encryption; with security enabled, data for ZigBee devices is encrypted with a 128-bit AES (Advanced Encryption Standard) network key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; The Application Layer (or Application Framework) is the highest protocol layer in the ZigBee stack. It comprises the Application Support (APS) sub-layer and ZigBee Device Object (ZDO). The Application Layer contains manufacturer-defined applications, and is responsible for the discovery and binding of services.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;ZigBee Networking &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee networking layer manages the formation of the network, which can be one of two networking topologies: star and peer-to-peer. In the star topology, every device in the network communicates only with the PAN coordinator. ZigBee uses the Ad-hoc On-demand Distance Vector (AODV) routing protocol. ZigBee also supports the tree topology. A ZigBee coordinator (PAN coordinator) establishes the initial network, and ZigBee routers form the branches and relay the messages to devices.&lt;/p&gt;
&lt;p&gt;In a peer-to-peer topology, each device can communicate directly with the other devices on the network, as long as the placement of these devices is sufficiently close to establish a successful communication link. Any Fully Functional Device (FFD) in a peer-to-peer network can play the role of the PAN coordinator. A peer-to-peer network can take different shapes by defining restrictions on the devices that can mutually communicate. An unrestricted peer-to-peer network is known as mesh topology.&lt;/p&gt;
&lt;p&gt;A PAN coordinator always creates an IEEE 802.15.4 network, regardless of its topology. The PAN coordinator controls the network and performs duties such as allocating a unique address (16-bit or 64-bit) to each device in the network, initiating, terminating, and routing the messages throughout the network and selecting a unique PAN identifier for the network. The unique PAN identifier permits the devices within a network to use the 16-bit short-addressing method and still communicate with other devices across independent networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ZigBee Security &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ZigBee network uses a 128-bit (16 Bytes) AES network key to encrypt all data transmission. Every node must obtain the network key in order to join the network. The network key is regenerated and distributed through the network at different intervals. ZigBee also implements link keys between devices. Link keys are unique keys shared by a pair of nodes, used to encrypt the data transmitted between the two devices. Link keys are generated by the trust center, the device assigned the responsibility of authenticating new nodes and distributing the network key.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ZigBee Applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A wide variety of industries and applications can take advantage of ZigBee wireless networking; these include home automation, industrial applications, health care, and inventory tracking.&lt;/p&gt;
&lt;h5&gt;Home automation&lt;/h5&gt;
&lt;p&gt;A home automation network typically does not need high data rates; the standard data rate in home automation is only 10 kbps, well within the ZigBee specification. Home automation applications include security, light control, meter reading, irrigation, and multi-zone HVAC systems.&lt;/p&gt;
&lt;h5&gt;Industrial Automation&lt;/h5&gt;
&lt;p&gt;ZigBee mesh networking can support the data transfer required for energy management, livestock tracking, light control, process control, and asset management.&lt;/p&gt;
&lt;h5&gt;Consumer Electronics&lt;/h5&gt;
&lt;p&gt;ZigBee finds use in game controllers, wireless remote controls, wireless peripherals for personal computers, and many other applications.&lt;/p&gt;
&lt;h5&gt;Healthcare&lt;/h5&gt;
&lt;p&gt;In a system for remote patient monitoring, data from wearables and other sensors connected to patients can be collected wirelessly. Data is encrypted and securely transferred via ZigBee.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The ZigBee Development Environment&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A ZigBee Certified Platform (ZCP) is a platform certified by the Connectivity Standards Alliance (formerly the ZigBee Alliance), and comprises a radio, ZigBee stack, and a microcontroller. Tools are available on PC for building and compiling applications, which are then transferred into target boards for debugging, generally through USB or Ethernet (wireless download is enabled in some platforms).&lt;/p&gt;
&lt;p&gt;All vendors of ZigBee radios offer development kits, complete with two or more development boards, a USB, serial or Ethernet connection to the boards, and a debug connection (BDM or JTAG) to download new binary images into the boards and to debug applications. Development kits include all the necessary hardware and software to develop ZigBee, as well as sample applications.&lt;/p&gt;
&lt;center&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:240px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2a" src="/e14/assets/main/2022b/diagram2a_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-3e409" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2766696&amp;nsku=22AC8780&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3e409'));" data-farnell="2766696" data-newark="22AC8780" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi XBee&lt;/a&gt; &amp;nbsp;3 ZigBee Mesh Kit&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:245px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2b" src="/e14/assets/main/2022b/diagram2b_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;ONsemi Strata enabled&amp;nbsp;&lt;a id="e14-product-link-0b234" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3588891&amp;nsku=12AJ7308&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('0b234'));" data-farnell="3588891" data-newark="12AJ7308" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;ZigBee Green Power Kit&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;padding-right:20px;vertical-align:middle;width:240px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2c" src="/e14/assets/main/2022b/diagram2c_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-25749" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2343882&amp;nsku=01X0182&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('25749'));" data-farnell="2343882" data-newark="01X0182" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Digi Xbee&lt;/a&gt; &amp;nbsp;2.4GHz&lt;/div&gt;
&lt;div style="display:inline-block;padding-bottom:5px;vertical-align:middle;width:245px;"&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 2d" src="/e14/assets/main/2022b/diagram2d_wirelessprotocol6.png" /&gt;&lt;br /&gt;&amp;nbsp;&lt;a id="e14-product-link-ad27c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3758008&amp;nsku=40AJ7883&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('ad27c'));" data-farnell="3758008" data-newark="40AJ7883" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;OM15080-K32W&lt;/a&gt; &amp;nbsp;USB Dongle&lt;/div&gt;
&lt;/center&gt;&lt;center&gt;&lt;em&gt;Figure 2: ZigBee Modules&lt;/em&gt;&lt;/center&gt;
&lt;p&gt;&lt;strong&gt;Application Development&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This developer tutorial demonstrates basic application development, using the Raspberry Pi to control ZigBee communication. Special thanks go to &lt;a href="https://calvin.edu/directory/people/derek-schuurman" rel="noopener noreferrer" target="_blank"&gt;Dr. Derek Schuurman&lt;/a&gt;, Computer Science Professor at Calvin University, who created &lt;a href="https://github.com/dschuurman/pi-home" rel="noopener noreferrer" target="_blank"&gt;pi-home&lt;/a&gt;, a home automation project that includes the control of lights, as well as the logging of temperature, humidity, pressure, and water leak sensors. This tutorial will go over &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights&lt;/a&gt;, a smaller version of pi-home, which focuses on the control of lights.&lt;/p&gt;
&lt;h5&gt;Light control using Raspberry Pi and ZigBee&lt;/h5&gt;
&lt;p&gt;Pi-lights enables the automation of lighting in the home, automatically turning on lights at dusk, and turning them off at a preset time. The project also includes the ability to control smart outlets. Configuration and manual operation can be performed via web browser.&lt;/p&gt;
&lt;p&gt;The project was written in Python 3, and uses the ZigBee2MQTT library to control ZigBee devices using MQTT (Messaging Queue Telemetry Transport), a lightweight messaging protocol popular in IoT systems. ZigBee2MQTT works with a variety of ZigBee USB adapters and devices. Although the code was developed for a Raspberry Pi with a ZigBee USB adapter, it can be run on other POSIX (Portable Operating System Interface) compliant systems.&lt;/p&gt;
&lt;h5&gt;Hardware&lt;/h5&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:200px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 3" src="/e14/assets/main/2022b/diagram3_wirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 3: ZigBee USB Adapter &lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A ZigBee adapter is the interface that enables ZigBee on the computer (or server). Several types of ZigBee adapters are available, include USB, GPIO or remote via WIFI or Ethernet.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:200px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 4" src="/e14/assets/main/2022b/diagram4_wirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 4: Raspberry Pi Server&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;A computer or server executes the code. Most Raspberry-Pi models are able to support ZigBee. With the proper hardware and software, many other platforms also support ZigBee networks, including Linux, Windows, and macOS.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div style="float:left;padding:12px 10px 5px 0px;width:200px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="figure 5" src="/e14/assets/main/2022b/diagram5_wirelessprotocol6.png" /&gt;&lt;br /&gt; &lt;em&gt;Figure 5: IKEA Light bulb. Image source: &lt;a href="https://www.ikea.com" rel="noopener noreferrer" target="_blank"&gt;IKEA&lt;/a&gt;&lt;/em&gt;&lt;/center&gt;&lt;/div&gt;
&lt;p&gt;Finally, choose the ZigBee devices that the system will control, such as the IKEA LED2035G10.&lt;/p&gt;
&lt;h5 style="clear:both;"&gt;Software&lt;/h5&gt;
&lt;p&gt;The source code for the project can be downloaded at the &lt;a href="https://github.com/dschuurman/pi-lights" rel="noopener noreferrer" target="_blank"&gt;pi-lights GitHub&lt;/a&gt;. Included in the package are installation instructions, as well as templates for the web interface. The two files containing source code are &lt;i&gt;pi-lights.conf&lt;/i&gt; and &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.conf&lt;/i&gt; is the file containing the configuration settings used by the source code. This includes connection addresses and ports, as well as preferences such as location (based on city) and brightness range of the light.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;pi-lights.py&lt;/i&gt; is the main source code written in Python 3. This file contains the functions performing all of the operations in the application.&lt;/p&gt;
&lt;p&gt;The following is an analysis of some of the code in &lt;i&gt;pi-lights.py&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;turn_on_bulbs&lt;/i&gt; (line 55) and &lt;i&gt;turn_off_bulbs&lt;/i&gt; (line 67) are the methods that turn the bulb(s) on and off. These methods are located in the State class, which manages device state for the bulbs and outlets.&lt;/p&gt;
&lt;div style="margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt; for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_bulbs&lt;/span&gt;(self):
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.light_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Lights turned off&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using a &lt;i&gt;for&lt;/i&gt; loop, the function sends a command to each bulb via zigbee2mqtt. In the &lt;i&gt;turn_on_bulbs&lt;/i&gt; method, that command is:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;rc&lt;/i&gt; is the return code; this is logged if there is an error.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.lock.acquire()&lt;/i&gt; and &lt;i&gt;self.lock.release()&lt;/i&gt; are primitive locks to control access to shared resources. &lt;i&gt;acquire()&lt;/i&gt; changes the state of the object to locked, blocking all other calls to it until &lt;i&gt;release()&lt;/i&gt; is called, changing it back to the unlocked state. Locking prevents multiple methods from access a shared resource at the same time, potentially resulting in corrupted data.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;self.light_state&lt;/i&gt; is a variable that is set to remember if the lights are on or off.&lt;/p&gt;
&lt;p&gt;Similarly, there are methods to turn smart outlets on and off (lines 79 and 91).&lt;/p&gt;
&lt;div style="margin-left:45px;"&gt;&lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_on_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;for outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;ON&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = True&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned on&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;turn_off_outlets&lt;/span&gt;(self):&lt;br /&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;acquire&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; outlet &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.outlets:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{outlet}/set/state&amp;#39;, &amp;#39;OFF&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return code: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.outlet_state = False&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;self.lock.&lt;span style="color:rebeccapurple;"&gt;release&lt;/span&gt;()&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;debug&lt;/span&gt;(&amp;#39;Outlets turned off&amp;#39;)&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt; &lt;i&gt;set_brightness&lt;/i&gt; (line 103) sets the brightness of the bulbs.&lt;br /&gt;&lt;br /&gt; &lt;span style="color:red;"&gt;def&lt;/span&gt; &lt;span style="color:rebeccapurple;"&gt;set_brightness&lt;/span&gt;(self, value):
&lt;div style="text-indent:10px;"&gt;self.brightness = value&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;&lt;span style="color:red;"&gt;for&lt;/span&gt; bulb &lt;span style="color:rebeccapurple;"&gt;in&lt;/span&gt; self.bulbs:&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;(rc, msg_id) = self.client.&lt;span style="color:rebeccapurple;"&gt;publish&lt;/span&gt;(f&amp;#39;zigbee2mqtt/{bulb}/set/brightness&amp;#39;, self.brightness)&lt;/div&gt;
&lt;div style="text-indent:20px;"&gt;&lt;span style="color:red;"&gt;if&lt;/span&gt; rc != 0:&lt;/div&gt;
&lt;div style="text-indent:30px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT publish return codes: {rc}&amp;#39;)&lt;/div&gt;
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;info&lt;/span&gt;(f&amp;#39;Brightness set to: {self.brightness}&amp;#39;)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the bottom of &lt;i&gt;pi-lights.py&lt;/i&gt; (line 326) is the code that executes when the application is run. First, the settings are imported from pi-light.conf. Next, the connection to the MQTT broker (line 389) is established.&lt;/p&gt;
&lt;div style="margin-left:45px;"&gt;client = mqtt.&lt;span style="color:chocolate;"&gt;Client&lt;/span&gt;()&lt;br /&gt; ret = client.&lt;span style="color:rebeccapurple;"&gt;connect&lt;/span&gt;(&lt;span style="color:chocolate;"&gt;BROKER_IP&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BROKER_PORT&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;MQTT_KEEPALIVE&lt;/span&gt;)&lt;br /&gt; &lt;span style="color:red;"&gt;if&lt;/span&gt; ret != 0:
&lt;div style="text-indent:10px;"&gt;logging.&lt;span style="color:rebeccapurple;"&gt;error&lt;/span&gt;(f&amp;#39;MQTT connect return code: {ret}&amp;#39;)&lt;/div&gt;
state = State(&lt;span style="color:chocolate;"&gt;BULBS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;OUTLETS&lt;/span&gt;, &lt;span style="color:chocolate;"&gt;BRIGHTNESS&lt;/span&gt;, client)&lt;/div&gt;
&lt;p&gt;In this code, &lt;i&gt;BROKER_IP, BROKER_PORT, and MQTT_KEEPALIVE&lt;/i&gt; are connection settings imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;. &lt;i&gt;BULBS, OUTLETS, and BRIGHTNESS&lt;/i&gt; are also imported from &lt;i&gt;pi-lights.conf&lt;/i&gt;, where the different bulbs, outlets, and the brightness range of the bulbs are specified.&lt;/p&gt;
&lt;p&gt;Finally, &lt;i&gt;scheduler&lt;/i&gt; and &lt;i&gt;light_timer&lt;/i&gt; objects are created in order to turn lights and outlets on and off at the correct times. &lt;i&gt;light_timer&lt;/i&gt; calls the &lt;i&gt;LightTimer&lt;/i&gt; class (line 118), and &lt;i&gt;scheduler&lt;/i&gt; calls Python&amp;rsquo;s &lt;i&gt;scheduler&lt;/i&gt; class, a generic interface for scheduling events.&lt;/p&gt;
&lt;p&gt;The Flask framework is used to enable the web interface. Flask is configured in the &lt;i&gt;FlaskThread&lt;/i&gt; class (line 223).&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;a name="sec4"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div style="background-color:#e7f2f5;color:#007fac;font-size:15px;margin-top:16px;padding:4px 8px;vertical-align:middle;"&gt;
&lt;div style="display:inline-block;vertical-align:top;width:75%;"&gt;&lt;strong&gt;4. Glossary&lt;/strong&gt;&lt;/div&gt;
&lt;div style="display:inline-block;font-size:11px;text-align:right;vertical-align:top;width:24%;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p style="clear:both;"&gt;&lt;/p&gt;
&lt;ul style="font-size:1.2em;"&gt;
&lt;li style="padding-top:8px;"&gt;&lt;strong&gt;AES (Advanced Encryption Standard):&lt;/strong&gt; a specification for the encryption of data. AES was established by NIST (National Institute of Standards and Technology) in 2001.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectivity Standards Alliance (formerly the ZigBee Alliance):&lt;/strong&gt; a group of companies that maintains and publishes the ZigBee standard. The group contains over 500 members.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IEEE 802.15.4:&lt;/strong&gt; a standard that defines the specifications for low data rate wireless personal area networks. ZigBee is an enhancement to the IEEE 802.15.4 standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet-of-Things (IoT):&lt;/strong&gt; a network of connected electronic devices, where devices can communicate with each other and the cloud.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium Access Control (MAC) layer:&lt;/strong&gt; the layer that works as an interface between the network and the physical layer. The MAC layer controls access, performs error correction, and resolves conflicts between competing nodes. The MAC layer also performs activities such as framing and addressing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mesh Topology:&lt;/strong&gt; a network topology where all computers and network devices are interconnected and communicate directly with one another.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MQTT (Messaging Queue Telemetry Transport):&lt;/strong&gt; a lightweight and efficient messaging transport protocol with small code footprint and minimal network bandwidth requirements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical (PHY) layer:&lt;/strong&gt; the layer that is lowest and closest to the hardware, interacting with the hardware to perform basic network functionality, such as transmitting and receiving.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star Topology:&lt;/strong&gt; a network topology where every computer or network device is connected directly to a central device, such as a hub or router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree Topology:&lt;/strong&gt; a network topology where multiple networks of star topology are connected via busses, similar to the branches on a tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-size:11px;padding-top:8px;"&gt;*Trademark. &lt;strong&gt;element14 is a trademark of Premier Farnell. &lt;/strong&gt; Other logos, product and/or company names may be trademarks of their respective owners.&lt;a name="components"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="clear:both;padding:16px 0px;"&gt;&lt;strong&gt;&lt;em&gt;Related Components&lt;/em&gt;&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox essProfile" style="float:left;padding:0px 13px 13px 0px;vertical-align:top;" alt="Wireless Protocol 6" height="100" src="/e14/assets/main/2022b/wirelessprotocol6_Profile.png" /&gt;&lt;/p&gt;
&lt;p&gt;Wireless connectivity via ZigBee is growing in popularity, especially for industrial and home automation applications. There are a variety of hardware components and software now available to help with Zigbee development.&lt;/p&gt;
&lt;hr style="clear:both;margin-top:12px;" /&gt;
&lt;div style="text-align:left;"&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;ZigBee Module&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;MGM12P32F1024GE-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-951ff" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605268,3605268RL&amp;nsku=15AJ2515&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('951ff'));" data-farnell="3605268,3605268RL" data-newark="15AJ2515" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &amp;nbsp;&lt;br /&gt;&lt;strong&gt;MGM12P22F1024GA-V4&lt;/strong&gt;&lt;br /&gt;&lt;a id="e14-product-link-8d40c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3605266,3605266RL&amp;nsku=15AJ2513&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8d40c'));" data-farnell="3605266,3605266RL" data-newark="15AJ2513" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;PTM535BZ Transmitter Module&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-a97d9" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku= 3812400&amp;nsku=74AJ0360&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('a97d9'));" data-farnell=" 3812400" data-newark="74AJ0360" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;XB3-24Z8ST ZigBee Module &lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-18665" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3529968,3529969&amp;nsku=83AH5000&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('18665'));" data-farnell="3529968,3529969" data-newark="83AH5000" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;SLWSTK6102A Wireless Starter Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-42a5d" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3249887&amp;nsku=39AH1022&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('42a5d'));" data-farnell="3249887" data-newark="39AH1022" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;1323XNSK-BDM Dev Board&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-c29fc" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2443146&amp;nsku=87R1366&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c29fc'));" data-farnell="2443146" data-newark="87R1366" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;div style="display:inline-block;margin-bottom:20px;padding-right:20px;vertical-align:middle;width:260px;"&gt;&lt;center&gt;&lt;img loading="lazy" class="nolightbox" alt="Product Image" src="/e14/assets/main/2022b/" /&gt;&lt;/center&gt;
&lt;div style="font-size:1.2em;padding:10px 0px;"&gt;&lt;strong&gt;EM34X-VRDK Dev Kit&lt;/strong&gt;&lt;/div&gt;
&lt;a id="e14-product-link-554f5" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=2514987&amp;nsku=75Y0699&amp;COM=e14c-essentials-wirelessprotocol6-doc&amp;CMP=e14c-essentials-wirelessprotocol6-doc&amp;osetc=e14c-essentials-wirelessprotocol6-doc" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('554f5'));" data-farnell="2514987" data-newark="75Y0699" data-comoverride="essentials-wirelessprotocol6-doc" data-cmpoverride="essentials-wirelessprotocol6-doc" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div style="clear:both;"&gt;&lt;center&gt;&lt;strong&gt;For more ZigBee products&amp;nbsp;&lt;/strong&gt;&lt;span &gt;&lt;a class="e14-button e14-button--primary e14-button--large" href="https://referral.element14.com/OrderCodeView?url=search?st=zigbee&amp;COM=essentials-wirelessprotocol6-doc&amp;CMP=essentials-wirelessprotocol6-doc" title="Shop Now" title="Shop Now" target="_blank"&gt;Shop Now&lt;/a&gt;&lt;/span&gt;&lt;/center&gt;&lt;/div&gt;
&lt;hr style="clear:both;margin-bottom:8px;margin-top:16px;" /&gt;
&lt;div&gt;&lt;a name="test"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="color:#007fac;font-size:18px;padding-bottom:8px;"&gt;&lt;strong&gt;Take the Quiz&lt;/strong&gt;&lt;span style="float:right;font-size:11px;"&gt;&lt;a href="#top"&gt;&lt;strong&gt;Back to Top&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" class="nolightbox xs-w15" style="float:left;padding:0px 10px 5px 0px;vertical-align:top;" alt="Wireless Protocol 6 Badge" src="/e14/assets/main/2022b/motorcontrol2BDG.png" /&gt;&lt;/p&gt;
&lt;p&gt;Are you ready to demonstrate your motor control knowledge? Then take this 10-question quiz. To earn the Wireless Protocol VI Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.&lt;/p&gt;
&lt;p style="clear:both;"&gt;&lt;div class="voltquiz" data-formid="96fdcece-f598-4403-8868-59760245a05f" data-formtype="quiz" data-success-message="Q29uZ3JhdHVsYXRpb25zISBZb3UgZ290IGEgcGVyZmVjdCBzY29yZSE=" data-fail-message="U29ycnksIHlvdSBkaWRuJ3QgZ2V0IDEwMCUgb24geW91ciBzY29yZS4gUGxlYXNlIHRyeSBhZ2Fpbi4=" data-pass-mark="OTk=" &gt;&lt;/div&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: low power, network topologies, zigbee, wireless protocol, ess_module&lt;/div&gt;
</description></item></channel></rss>