Back

Z_Wave

Loading views...

Z-Wave

Overview

Z-Wave is a sub-GHz wireless mesh protocol designed for home automation. It operates at 868.42 MHz (EU) or 908.42 MHz (US), avoiding congestion at 2.4 GHz used by Wi-Fi and Zigbee. Each device acts as a mesh repeater.


1. Theory & Fundamentals

  • Sub-GHz (868/908/916 MHz); less interference than 2.4GHz
  • Range: 30m indoor per hop; mesh extends to 200+ nodes
  • Data rate: 9.6 kbps (Z-Wave), 40/100 kbps (Z-Wave Plus)
  • Max network: 232 nodes
  • Device types: Controller (primary/secondary), Slave, Routing slave
  • Power: Battery-powered FLiRS devices wake every 250ms to check for messages
  • Z-Wave Plus (Gen5) mandatory since 2013

2. Frame / Packet Structure

Z-Wave frame (MAC layer):
  Home ID(4B) | Source ID(1B) | Frame Control(1B) | Length(1B)
  | Dest ID(1B) | Command Class(1B) | Command(1B) | Parameters | Checksum(1B)

Command Classes (key examples):
  0x20 = Basic
  0x25 = Binary Switch
  0x26 = Multilevel Switch
  0x31 = Sensor Multilevel
  0x98 = Security
  0x9F = Security S2

3. Protocol Mechanics

  • Mesh routing: Source routing; controller knows full route
  • ACK: Every unicast frame acknowledged
  • Routed ACK: End-to-end acknowledgment through mesh
  • Security S2: AES-128 CCM with ECDH key exchange (mandatory in Z-Wave 700+)
  • Z-Wave Long Range (700 series): Up to 1.6km, 4000 nodes

4. Hardware Implementation

  • Z-Wave SoC: ZM5202 (Silicon Labs 500 series), ZGM130S (700 series)
  • Antenna: PCB monopole or helical for 868/908 MHz
  • Crystal: 16 MHz; 32.768 kHz for sleep timing
  • Module options: ZMEERAZ2, UZB (USB Z-Wave controller)
  • SDK: Silicon Labs Z-Wave SDK (formerly Sigma Designs)

5. Register-Level / Configuration

// Z-Wave 700 series (Silicon Labs SDK)
// Init controller
ZAF_Init();
ZW_SendDataEx(destNodeId, data, len, txOptions, callback);

// Command class handler
void handleBasicSetCommand(uint8_t value) {
    if(value == 0xFF) relay_on();
    else relay_off();
}

6. Driver / Software Development

  • Initialize hardware peripheral or SoC block
  • Implement send/receive with interrupt or DMA
  • Handle errors: timeout, CRC, NAK, bus-off
  • Use circular buffers for RX data flow
  • Implement retry logic for reliability

7. Debugging & Testing

  • Z-Wave PC Controller tool for network management and frame capture
  • Z/IP Gateway: IP interface to Z-Wave network
  • Common issues: Node not included in network; routing failure (add repeaters); S2 bootstrapping failure
  • Z-Wave Sniffer (UZB + software) for frame capture

8. Real-World Applications

  1. Smart home door locks
  2. Lighting and dimmer switches
  3. Thermostats and climate control
  4. Garage door openers
  5. Motion and flood sensors

9. Advanced Topics & Edge Cases

  • Z-Wave Long Range (ZWLR): 1.6km, no mesh needed, 4000+ nodes
  • Z-Wave vs Zigbee: Z-Wave uses dedicated sub-GHz band; less interference but proprietary
  • S2 Security: Mandatory for Z-Wave Plus v2; ECDH exchange prevents eavesdropping
  • SmartStart: QR code provisioning for easy device inclusion

10. Standards & Variants

Spec Z-Wave Classic Z-Wave Plus Z-Wave LR
Freq 908 MHz 908 MHz 912 MHz
Speed 9.6/40 kbps 100 kbps 100 kbps
Range 30m/hop 30m/hop 1.6 km
Nodes 232 232 4000

💡 Practical Examples

Ex 1: Include device

Put controller in include mode, press button on device — controller assigns Home ID and Node ID.

Ex 2: Set binary switch

uint8_t cmd[] = {0x25, 0x01, 0xFF}; // Binary Switch Set ON
ZW_SendData(targetNode, cmd, 3, options, cb);

Ex 3: Get sensor value

uint8_t cmd[] = {0x31, 0x04}; // Sensor Multilevel Get
ZW_SendData(sensorNode, cmd, 2, options, cb);

🧪 Practice Questions

Beginner

  1. What frequency does Z-Wave use in Europe?
  2. What is the maximum number of Z-Wave nodes?
  3. What makes Z-Wave less prone to interference than Zigbee?
  4. What is FLiRS mode?
  5. What is a primary controller?

Intermediate

  1. Explain Z-Wave source routing.
  2. How does Z-Wave S2 security work?
  3. Implement a Z-Wave binary switch command class handler.
  4. How does SmartStart simplify device inclusion?
  5. What is the difference between Z-Wave 500 and 700 series?

Advanced

  1. Design a Z-Wave network for a 50-room hotel.
  2. Implement Z-Wave Long Range node for outdoor sensor.
  3. Build a Z-Wave to MQTT gateway.
  4. Implement S2 key exchange and secure command handling.
  5. Debug Z-Wave mesh routing failure.

Projects

  1. Smart Lock: Z-Wave door lock with Z-Wave hub integration.
  2. Climate Node: Temperature + humidity sensor with Z-Wave reporting.
  3. Gateway: Z-Wave USB stick + Node-RED + MQTT bridge.

Checklist

  • [ ] Explain Z-Wave network inclusion/exclusion
  • [ ] Initialize Z-Wave SoC with SDK
  • [ ] Implement Basic command class
  • [ ] Implement Sensor Multilevel command class
  • [ ] Add S2 security to device
  • [ ] Use PC Controller for network management
  • [ ] Capture frames with Z-Wave sniffer
  • [ ] Build Z-Wave to MQTT gateway
  • [ ] Handle FLiRS wakeup beam
  • [ ] Integrate with SmartThings or Home Assistant