This project will provide a Battery Monitor application that supports both series 1 SoCs and series 2 SoCs. The following steps will also show that how is the implementation of this Zigbee battery monitor application.
Here is how the application works:
On the End Device side
- We use the PRS to associate the radio signal
Radio Tx Complete
with a GPIO pin. So that when a packet is sent to the air, the GPIO pin will go high. - Then we configure the GPIO to generate an interrupt when the level goes high.
- When serving the interrupt, an event is activated. Then we start to read the ADC or IADC.
- The PRS channel and the GPIO pin used here are both configurable.
- The end device periodically sends a power configuration report to the coordinator.
On the Coordinator device side
- The Coordinator periodically hears a report from The end device.
- Analyze the power configuration report to get the battery voltage.
Gecko SDK Suite 4.4.0
EFR32MG21 Wireless Gecko Starter Kit
Board ID | Description |
---|---|
BRD4161A | EFR32MG12 2.4GHz 19 dBm Radio Board- BRD4161A |
BRD4180A | EFR32xG21 2.4 GHz 20 dBm Radio Board-BRD4180A |
The following picture shows the hardware for this application.
To create a Coordinator, you can either create a project based on an example project or start with a "Zigbee - SoC ZigbeeMinimal" project based on your hardware.
-
From the Launcher Home, add hardware to MyProducts tabs, click on Start, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with the filter "battery monitor coordinator".
-
Create a Zigbee - Battery Monitor Coordinator project in Simplicity Studio. This example projects creation dialog pops up -> click Create and Finish and the project should be generated.
- Build and flash this example to your board.
-
Create a Zigbee - SoC ZigbeeMinimal project in Simplicity Studio.
-
Copy all attached files in src/coordinator/ folders into the project root folder (overwriting existing files).
-
Open the .slcp file:
-
Select the SOFTWARE COMPONENTS tab and install these software components:
- [Zigbee] → [Zigbee 3.0] → [Find and Bind Target]
- [Zigbee] → [Zigbee 3.0] → [Network Creator]
- [Zigbee] → [Zigbee 3.0] → [Network Creator Security]: make sure the 'Network Creator Security' component is also installed.
- [Zigbee] → [Utility] → [Zigbee Device Config]: change [Primary Network Device Type] : coordinator or router.
-
Select the CONFIGURATION TOOLS tab and open Zigbee Cluster Configurator:
- Select Endpoint 1:
- [Power Configuration cluster]: enable the client side.
- [Identify cluster]: enable server side.
- Select Endpoint 1:
-
Copy all attached files in the config/coordinator/zcl folder into the project folder (overwriting existing).
-
Build and flash this project to your board.
To create a Sleepy End Device, you can either create a project based on an example project or start with a "Zigbee - SoC ZigbeeMinimal" project based on your hardware.
-
From the Launcher Home, add your hardware to MyProducts, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with the filter "battery monitor".
-
Based on your hardware, the Zigbee - Battery Monitor (Series 1 Devices) example or Zigbee - Battery Monitor (Series 2 Devices) example will appear. Click Create button on it. This example projects creation dialog pops up -> click Create and Finish and the project should be generated.
- In the battery_monitor.c, change the channel, Port, and Pin compatible with your board.
- Build and flash this example to your boards.
-
Create a Zigbee - SoC ZigbeeMinimal project in Simplicity Studio.
-
Copy all attached files in src/end_device folders into the project root folder (overwriting existing):
- With series 1 devices: src/end_device/series_1
- With series 1 devices: src/end_device/series_2
-
In the battery_monitor.c, change the channel, Port, and Pin corresponding with PRS module on your board.
- Open the .slcp file:
-
Select the SOFTWARE COMPONENTS tab and install these software components:
- [Zigbee] → [Stack] → [Pro Core] → uninstall [Pro Stack]
- [Zigbee] → [Stack] → [Pro Core] → install [Pro Leaf Stack]
- [Zigbee] → [Zigbee 3.0] → [Network Steering]: make sure the 'Network Steering' component is installed.
- [Zigbee] → [Zigbee 3.0] → [Find and Bind Initiator]
- [Zigbee] → [Cluster Library] → [Common] → [Reporting]
- [Zigbee] → [Utility] → [Zigbee Device Config]: change [Primary Network Device Type] : Sleepy End Device.
- [Zigbee] → [Utility] → [End Device Support]
-
Select the CONFIGURATION TOOLS tab and open Zigbee Cluster Configurator:
- Select Endpoint 1:
- [Power Configuration cluster]: Enable Server side.
- [Identify cluster]: enable Client side.
- Select Endpoint 1:
-
Copy all attached files in the config/end_device/zcl folder into the project folder (overwriting existing).
-
Build and flash this project to your board.
-
Form a network with the coordinator, also open the network and bind with the incoming device at the same time with the following command.
plugin network-creator start 0
plugin network-creator-security open-network
plugin find_and_bind target 1
-
In the sleepy end device side, start to join into the network and bind endpoint 1 of the sleepy end device to the coordinator by the following command.
plugin network-steering start 0
- After joining the network, the sleepy end device will periodically report its battery voltage in less than 10 seconds.