Wednesday, February 24, 2021

Project Connected Home over IP (ProjectCHIP) demonstration with EFR32 as ProjectCHIP node, Raspberry Pi as OTBR, and Ubuntu VM as chip-tool

 The follow steps show you how to setup Project Connected Home over IP (ProjectCHIP) demonstration with EFR32 as ProjectCHIP node, Raspberry Pi as OTBR, and Ubuntu VM as chip-tool like in the diagram.



1. Install VirtualBox and Ubuntu 20.04 on your Desktop. Remember select "Bridged Adapter" in your network settings of VirtualBox/Ubuntu.

2. Setup environment (run the following commands in Ubuntu terminal) for building CHIP examples on Ubuntu VM.

    2.1 sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev unzip

    2.2.1 cd ~
    2.2.2 git clone https://github.com/SiliconLabs/sdk_support.git
    2.2.3 cd sdk_support
    2.2.4 git checkout ff45be117a5a1a20d27296628b0632523f65c66a

    2.3.1 cd ~
    2.3.2 git clone https://github.com/project-chip/connectedhomeip.git
    2.3.3 cd connectedhomeip
    2.3.4 git checkout 122da92801fd38f49b8fe3db397ccaa4eb0e4798
    2.3.5 source scripts/activate.sh
    2.3.6 gn gen out/host
    2.3.7 ninja -C out/host

3. Build and download CHIP lock-app for EFR32 (In my examples, I use BRD4180A with BRD4001A to act as Thread node running CHIP protocol)

    3.1 cd ~/connectedhomeip/examples/lock-app/efr32
    3.2 git submodule update --init
    3.3 source third_party/connectedhomeip/scripts/activate.sh
    3.4 export EFR32_SDK_ROOT=~/sdk_support
    3.5 export EFR32_BOARD=BRD4180A
    3.6 gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\""
    3.7 ninja -C out/debug
    3.8 Using Simplicity Studio Commander to download chip-efr32-lock-example.s37 under out/debug folder into BRD4180A.

4. Refer to "Running OpenThread Border Router and device with Raspberry Pi and Silicon Labs EFR32 Kits" to setup OpenThread Border Router on Raspberry Pi.

5. Run the following commands in OpenThread Border Router terminal to setup Thread network for commission.

    5.1.1 sudo ot-ctl dataset init new
    5.1.2 sudo ot-ctl dataset channel 13
    5.1.3 sudo ot-ctl dataset panid 0xface
    5.1.4 sudo ot-ctl dataset extpanid face1111face2222
    5.1.5 sudo ot-ctl dataset networkname OpenThreadYKTest
    5.1.6 sudo ot-ctl dataset masterkey 00112233445566778899aabbccddeeff
    5.1.7 sudo ot-ctl dataset commit active

    5.2.1 sudo ot-ctl prefix add 2001:db8::/64 pasor
    5.2.2 sudo ot-ctl ifconfig up
    5.2.3 sudo ot-ctl thread start
    5.2.4 sudo ot-ctl netdata register
    5.2.5 sudo ot-ctl state
    5.2.6 sudo ot-ctl ipaddr


    5.3.1 sudo ip addr add dev eth0 2002::2/64

 
6. Run the following commands on terminal of EFR32 CHIP lock-app device (build and download in step 3)

    6.1 factoryreset
    6.2 dataset channel 13
    6.3 dataset panid 0xface
    6.4 dataset masterkey 00112233445566778899aabbccddeeff
    6.5 dataset commit active
    6.6 ifconfig up
    6.7 thread start
    6.8 ipaddr

7. Try to ping EFR32 CHIP lock-app device from Raspberry Pi border router to make sure it respond.


8. Add route (enp0s3 might be different on your VM) on Ubuntu VM to access to EFR32 CHIP lock-app device

    8.1 sudo ifconfig enp0s3 inet6 add 2002::1/64
    8.2 sudo ip route add 2001:db8:0:0::/64 via 2002::2
    8.3 sudo ip route add fd38:117c:3b66::/64 via 2002::2


     8.4Try to ping EFR32 CHIP lock-app device from Ununtu VM terminal this time to make sure it respond.

 


9. Build and run chip-tool on Ubuntu VM

    9.1 cd ~/connectedhomeip/examples/chip-tool
    9.2 git submodule update --init
    9.3 source third_party/connectedhomeip/scripts/activate.sh
    9.4 gn gen out/debug
    9.5 ninja -C out/debug

    9.6 run "./chip-tool onoff on 2001:DB8::C6CC:14E9:E7D1:A3EA 11097 1" to send onoff command on Ubuntu VM terminal to control EFR32 CHIP lock-app device

 


    9.7 Using J-link RTT Viewer to check if EFR32 CHIP lock-app device receives CHIP command.


P.S. This demostartion is based on steps in https://www.silabs.com/documents/public/training/wireless/chip-connected-home-over-ip-lab.pdf. However, there are some typo and ambiguous in the document and here I share the whole steps again according to my test.

Sunday, February 7, 2021

Comparision on Zigbee, Z-Wave, and Z-Wave Long range.

 This article tries to discuss differences of Zigbee, Z-Wave, and Z-Wave Long range on network Topology, radio coverage, and number of nodes supported in single network, security, power consumption, interoperability, logistics, prone to interference, chip vendor...

1. Network topology, radio coverage, and number of nodes supported in single network

Both Zigbee and Z-wave support mesh network but Z-Wave Long Range only support star network. 

For Zigbee, radio coverage of single hop would be about 50-250 meters in line-of-sight test and it's usually not recommended to have more than 5 hops in Zigbee mesh network. In this way, the radio coverage in line-of-sight test would be able to reach 1.5KM. Since Zigbee runs on 2.4GHz band which is prone to interference by WiFi, BLE, or other 2.4GHz equipment so the radio coverage might be smaller. In theory, a single Zigbee network can have max 65535 nodes.

For Z-Wave, radio coverage of single hop in would be about 30-100 meters in line-of-sight test and Z-Wave mesh supports max 4 hops. In this way, the radio coverage in line-of-sight test would be able to cover 500 meters. However, a single Z-wave mesh network only supports max 232 nodes.

For Z-Wave Long Range, it only supports star network, but it can have radio coverage upto1600m in line-of-sight and can support max 4000 nodes in a single network. It is amazing on radio coverage but currently only support US market.

2. Security

Basically, Zigbee and Z-wave use AES-128 to do network and application packet encryption. Different key exchange process in Zigbee/Z-wave provides different level of security.

Previous Zigbee HA profile 1.2 supports well known TC link key to exchange single network key for all joined device and this is less secure. With latest Zigbee 3.0, it enable Install code/Variable TC Link Key with variable network key for different joined device and it provides best security for now.

Z-wave provides S0, S2 non-Auth, S2 auth, and S2 Access. For backward compatibility, Z-wave protocol has to support S0 but it's recommended to use S2 auth at least for secure connection.

Z-Wave Long Range only supports S2 auth and S2 Access which provide best security for now.

3. Power consumption

Zigbee and Z-Wave have developed for more than 10 years so there are different chip generations for two protocols.

For Zigbee, previous generation (such as Texas Instruments CC2530 or Silicon Labs EM35x) consumes higher power (battery power can last about 2-5 years depending on different applications). New generation (such as Texas Instruments CC2652 or Silicon Labs EFR32) improves lots on power consumption and battery power (CR2032 also applicable) can extended to about 4-10 years depending on different applications.

For Z-wave, previous generation (500 series) also consumes higher power and battery power can last about 2-5 years depending on different applications. New generation (700 series) also improves power consumption and battery power (CR2032 also applicable) can extended to about 4-10 years depending on different applications.

Z-Wave LR offers up to 10-year battery life on a single coin-cell battery by leveraging dynamic power control. This new feature enables the Z-Wave Long Range device to automatically adjust and optimize the radio output power at every transmission.

4. Interoperability, logistics, and Prone to interference

Before Zigbee 3.0, there are different Zigbee profiles and products of different profiles cannot interoperate to each other. Zigbee 3.0 unifies this for better interoperability. Current Zigbee products run on unified 2.4G Hz frequency band so it's easier for logistics. However, there are lots other 2.4G Hz protocol such as WiFi and BLE or other 2.4G Hz equipment so Zigbee is prone to interference.

Z-wave is always an unified protocol (products need to be certified by Z-wave alliance before releasing to market) and providea best backward compatibility for different protocol generation. Since Z-wave works on sub GHz ISM band so different region needs to use different frequency band. This usually causes complex logistics if you support world-wide products but sub GHz ISM band would avoid prone to interference on 2.4G Hz interference.

Z-Wave Long Range and Z-Wave are also designed to co-exist on the same network, with LR network nodes reserved for new or existing Z-Wave mesh network devices to preserve both backwards and forwards compatibility and sustain interoperability between certified Z-Wave devices.

5. Chip vendor and chip/module cost

For Zigbee, there are different chip and stack vendors such as Silicon Labs, Texas Instruments, NXP,etc. Due to open competition, Zigbee chip is usually cheaper.

For Z-Wave and Z-Wave Long Range, Silicon Labs is the only chip/stack vendor. Because of no competition on chip vendor, Z-Wave chip/module price is usually higher in comparison to Zigbee chip/module.

To conclude, there is no superior or best protocol for smart home for now. Even with most popular Zigbee and Z-wave protocol, they have advantage and disadvantage for your own choice. Later in 2021, OpenThread and CHIP (connected home over ip) are trying to unify everything. OpenThread is still based on 2.4G Hz 802.15.4 protocol and has similar advantage and disadvantage with Zigbee so I don't think it might unify or dominate the market. From my personal point of view, smart home would be still  a versatile and open market for a long while.

Tuesday, December 22, 2020

How to create a delay event in Simplicity Studio v5 and EmberZnet 6.9.0.0

You can use the following steps to create a delay event in Simplicity Studio v5 and EmberZnet 6.9.0.0 when press PB0 on BRD4001A to trigger a delay event.

1. New eventYKDelay as Command and eventYKDelayHandler as Callback in Event Configuration of Includes tab in isc file to generate related codes.

2. Add the following code in button-interface.c

EmberEventControl eventYKDelay;

void eventYKDelayHandler(void){
  emberEventControlSetInactive(eventYKDelay);
  emberSerialPrintfLine(APP_SERIAL, "2000ms delay event");
}

3. Add the the following line in emberAfPluginButtonInterfaceButton0PressedEventHandler to trigger eventYKDelayHandler after 2000 ms.

emberEventControlSetDelayMS(eventYKDelay, 2000);

4. Build and download code into EFR32 radio board.

5. Run the application and press PB0. You will see "2000ms delay event" printed on console 2 seconds later, which shows delay event works.




Monday, December 21, 2020

Create IAS CIE coordinator and IAS Zone Door Sensor using Silicon Labs EmberZnet

The following steps show you how to create IAS CIE coordinator and IAS Zone Door Sensor using Silicon Labs EmberZnet 6.9.0 

1. Create and run IAS CIE coordinator for BRD4180A.

    1.1 Using the following steps to create CIE project for BRD4180A.

    1.2 Select "HA IAS Control and Indication Equipment" as ZCL device type, "Coordinator or Router" as Zigbee Device type, and enable  IAS Zone Client/Network Creator related plugin.


 

    1.3 Generate code to build firmware and download firmware into BRD4180A.

    1.4 Launch console and use CLI command "plugin network-creator form 1 0x5678 13 13" to form centralized Zigbee 3.0 network.

    1.5 Use CLI command "plugin network-creator-security open-network" to allow IAS Zone device to join.


2. Create and run IAS Zone Door Sensor device for BRD4161A.

    2.1 Using the following steps to create IAS Zone project for BRD4161A.

    2.2 Select "HA IAS Zone" as ZCL device type, "Sleepy End Device" as Zigbee Device type, use 0x0015 as zone type, enable "Security Sensor Interface" and "Network Creator..." related plugin.

 

    2.3 Add the following pin defines in hal-config.h to simulate PB1 on BRD4001A as reed switch of door sensor.

            #define GPIO_SENSOR_PIN                       (7U)
            #define GPIO_SENSOR_PORT                      (gpioPortF)

    2.4  Generate code to build firmware and download firmware into BRD4161A.

    2.5 Launch console and use CLI command "plugin network-steering start 0" to join centralized Zigbee 3.0 network that is formed and opened in step 1.4 and 1.5.

 


    2.5 In sniffer log, you would see the following event that show you IAS Zone sensor works with CIE. Press PB1 on BRD4001A would send IAS Zone status change notification.