GPIO inputs

Inversed – By default, the firmware interprets the LOW state on the input pin as a pressed state of a button. If this option is enabled, the HIGH state means the pressed button.

Link – The input immediately controls the state of the corresponding output (e.g. Input 1 – Output 1). The device sends the on/off state of the output to a coordinator. Otherwise, the input is independent.

Long – The firmware detects and reports to the coordinator a long click (2000 ms).

Double – The firmware detects and reports a double click (max 500 ms between clicks).

Triple – The firmware detects and reports a triple-click (max 500 ms between clicks).

Switch – an input works as a switch. Only ON (pushed) / OFF (released) states.

Toggle – this options appears for a switch input. The switch works as a toggle button. But because the ON/OFF state can be changed via external commands, a physical button position may differ with an output state.

Note: Input 1, if it is defined as a click button, also acts as a system button and allows you to reset the device if you press and hold that button for 10 seconds. After resetting, the device start a paring process.

Zigbee cluster: ZCL_CLUSTER_ID_GEN_MULTISTATE_INPUT_BASIC
Zigbee attribute: ATTRID_IOV_BASIC_PRESENT_VALUE
Data type: UINT8 (1 – single click, 2 – double click, 3 – tripple click, 4 – long press (more than 1500 ms))

GPIO outputs

Inversed – By default, the firmware sets the output pin to HIGH when a logical state is ON. You may invert that logic using this option.

Remember state – The firmware saves the output state to NVRAM and restores it after power off/on. Also, this option works for some sensors (counter, PWM)

Zigbee cluster: ZCL_CLUSTER_ID_GEN_ON_OFF
Zigbee attribute: ATTRID_ON_OFF.

Zigbee2MQTT commands

on/off – sets the output to the HIGH or LOW state
Topic: z2m/[friedly_name]/[channel]/set
Channel: l1, l2, l3 … l8
Payload: ON or OFF

read – sets the output to the HIGH or LOW state
Topic: z2m/[friedly_name]/[channel]/get/state
Channel: l1, l2, l3 … l8
Returns: The channel state {“state_[channel]”: “ON”}

trigger – sets the output to the HIGH state for N seconds, then resets to LOW. Topic: z2m/[friedly_name]/[channel]/set
Channel: l1, l2, l3 … l8
Payload: {“trigger”, 5000}

Analog inputs (ADC)

You may define up to 8 analog inputs in the configuration. You must connect analog inputs to pins P00 .. P07.

The firmware reads analog values when it sends a periodic report to a host. When the periodic report is disabled you should send the “read” request for the configured endpoint.

Analog input, accurate (max 1.15V) – the pin uses internal reference voltage that is more precise than a source voltage.

Analog input, (max 3.3V) – less accurate, but it can measure higher voltage.

Source voltage – reports source power voltage. It can be used to monitor a battery level. You may assign this sensor to any unused pin.

Internal temperature – reports the temperature of the CC2530 chips. You may assign this sensor to any unused pin.

Zigbee cluster: ZCL_CLUSTER_ID_GEN_ANALOG_INPUT_BASIC
Zigbee attributes:
ATTRID_IOV_BASIC_PRESENT_VALUE – the sensor value (single precision float).
ATTRID_IOV_BASIC_DESCRIPTION – the value units (V – voltage, C – temperature).

Zigbee2MQTT commands

read – immediately reads the analog input value
Topic: z2m/[friedly_name]/get/[channel]
Channel: l1, l2, l3 … l8
Payload: 1
Returns: The channel state {“[channel]”: float_value}

UART

The UART interface is designed to send text or hex commands between an external device (e.g. Arduino) and a host.

The maximum command size is 127 bytes. Every command line may terminate with a special configurable byte: CR (0x0D), LF (0x0A) or 0x03 (ETX). The firmware also adds the ending signature to each of the commands that the device receives from a host and outputs to UART. If the end signature is not defined, the firmware waits 300 ms and outputs the whole buffer to a host.

UART uses P02 and P03 pins (3.3V). You should enable UART on P02 on an output pin in the configuration.

You can also select a baud rate for the UART interface in the firmware configuration.

UART configuration. P02 is required. P03 is optional.

Zigbee cluster: ZCL_CLUSTER_ID_GEN_MULTISTATE_VALUE_BASIC
Zigbee attributes: ATTRID_IOV_BASIC_STATE_TEXT – UART data. You should use the “ZCL_DATATYPE_OCTET_STR” (0x41) or “ZCL_DATATYPE_CHAR_STR” (0x42) data types for this attribute.

Zigbee2MQTT commands

write – sends data to a UART.
Topic: z2m/[friedly_name]/set/action
Payload: text command
The following command allows you to send any bytes. The first byte in the array (2) is the number to bytes following the length.
Topic: z2m/[friedly_name]/set
Payload: {“action”: [2, 0, 0]}

External sensors

The firmware supports up to 8 external sensors of different types. Keep in mind, that CC253x has limited performance. You cannot attach 8 sensors, 4 inputs, UART and get a good result. Some sensors cannot co-exist with each other.

Common Zigbee information for all external information:
Zigbee cluster: ZCL_CLUSTER_ID_GEN_ANALOG_INPUT_BASIC
Zigbee attributes:
ATTRID_IOV_BASIC_PRESENT_VALUE – the sensor value (single-precision float).
ATTRID_IOV_BASIC_DESCRIPTION – the value units (V – voltage, C – temperature, % – humidity, m – altitude, ppm – air quality, CO2, TVOC).
Zigbee commands: read

I2C sensors

You should define a pin for a sensor first. It is the SDA pin. Then you should define the SCL pin. For example, output 4 – BME280, and output 5 – I2C SCL.

I2C configuration for a sensor

If you connect several sensors on one bus (pin) you may define the SCL pin only once.

This image has an empty alt attribute; its file name is img1-4.png
I2C configuration for sensors on one bus

Zigbee: Accepts the “read” and “write” commands on the endpoint for the SDA pin.

CCS811

The sensor requires environmental temperature and humidity for better results. The example above shows that several I2C sensors are connected on the same bus. They provide the necessary data. These sensors should be defined first. If they are defined after CCS811, environmental info will be ignored by CCS811.

You may also send temperature and humidity from a higher system.

Analog value: 65NNN where NNN is a humidity value, for example, 65050 for 50%. Humidity range: 0 … 50.
Analog value: 64NNN where NNN is a temperature value, shifted by 25. For example, 64000 for -25C, 64025 for 0C, 64050 for 25C. Temperature range: -25 … 100.
Analog value: 0 .. 63999 – baseline value (see docs for CCS811).

Zigbee2MQTT commands

write – writes calibration data.
Topic: z2m/[friedly_name]/set/[channel]
Channel: l1, l2, l3 … l8
Payload: value

DS18B20

The firmware supports up to 4 sensors on one line. If you didn’t specify the sensor ID in the settings, the firmware sends all values to one endpoint but with a different description like “C,00-00-00-00-00” (unit, comma, device ID).

You may specify the same pin number, sensor type, and sensor ID on different endpoints. In this case, the firmware will send the sensor value to the corresponding endpoint.

Pulse generator

You may use this generator to wake-up Atmega-based external sensor. The external sensor should measure value and output it to a UART port.

Pulse counter

It is 32 bit counter with the 10 milliseconds debounce interval. Therefore it cannot be used for high-frequency signals. If an interval is defined, the counter automatically resets after that interval and reports the counted values to a coordinator.

Zigbee2MQTT commands

read – immediately reads the counter value.
Topic: z2m/[friedly_name]/get/[channel]
Channel: l1, l2, l3 … l8
Payload: 1
Returns: The counter value {“[channel]”: float_value}
write – resets the counter
Topic: z2m/[friedly_name]/set/[channel]
Channel: l1, l2, l3 … l8
Payload: 0

MHZ19, Senseair S8

These sensors work in the UART mode and you should connect sensors to UART pins. Therefore you cannot use the UART interface in the same configuration. (CC2530 P0.2 -> MH-Z19 RX, CC2530 P0.3 -> MH-Z19 TX).

Bistable relay

You should define the ON pin first. For example, output 7 – Bistable relay ON, and output 8 – Bistable relay OFF.

Bistable relay configuration

Zigbee: Look for commands and examples for GPIO outputs. The firmware accepts all commands on the “Bistable relay On” endpoint.

PWM

The firmware supports two PWM types: software and hardware.

Software, configurable 1 kHz, 2 kHz, 3 kHz, 5 kHz – the firmware can generate the PWM signal on any pin. The higher frequency requires more CPU resources. The frequency may slightly float. You may configure up to 2 PWM outputs in the configuration.

Hardware, configurable 1 kHz, 2 kHz, 4 kHz, 8 kHz, 16 kHz, 32 kHz – the firmware uses the hardware PWM generator on the chip. The PWM duty cycle has 256 states (8 bits). It is precise and does not use CPU resources, but it can work on the following pins only:

PWM #1 pins: P13, P14, P16, P17 (one of these pins)
PWM #2 pins: P10, P11, P20, P23 (one of these pins)

If a PWM output is linked to a corresponding input (e.g. Input 2 – Output 2), the input can control the PWM value (12 steps, cyclic, 0 – 20 – 40 .. 240 – 255 0).

Zigbee cluster: ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL
Zigbee attributes: ATTRID_LEVEL_CURRENT_LEVEL (uint8)
Zigbee commands: read, write, moveToLevel, moveToLevelWithOff

Zigbee cluster: ZCL_CLUSTER_ID_GEN_ANALOG_INPUT_BASIC
Zigbee attributes: ATTRID_IOV_BASIC_PRESENT_VALUE (float, range: 0-255)
Zigbee commands: read, write

Zigbee2MQTT commands

on/off – Look for commands and examples for GPIO outputs.
write – sets the PWM duty cycle.
Topic: z2m/[friedly_name]/[channel]/set/brightness
Channel: l1, l2, l3 … l8
Payload: value
Topic: z2m/[friedly_name]/set/[channel]
Channel: l1, l2, l3 … l8
Payload: {“brightness”: value, “transition”: 3}
value – 0 .. 254.
transition – (optional) the transition time in seconds between states.
read – reads the current value
Topic: z2m/[friedly_name]/[channel]/get/brightness
Payload: none
Returns: {“brightness_[channel]”: value}


Comments
Harvey Specter
Posted at 22:52 July 4, 2020
Alan
Reply
Author

Hi. Could you please clarify under the section GPIO Outputs / Zigbee2MQTT commands what would be the channel number of Output 1 with the configuration shown here: https://www.dropbox.com/s/qq1edgmqzifd0qz/ptvo%20configuration.jpg?dl=0

At the moment l1 is the Input 1 Counter and l2 is Input Temperature.

Also, Input 1 Counter is linked to Output 1. Does linking work for Counters? At the moment an LED on Output 1 is always ON but the Input 1 is low (OFF). [Output 1 Inverse is not selected].

Thank you
Alan

Harvey Specter
Posted at 07:38 May 25, 2020
Andreas
Reply
Author

Leave a Reply