You may define up to 8 analog inputs in the configuration. You must connect analog inputs to pins:
CC2530, CC2531: P00 .. P07
CC2652, CC1352: P23 .. P30
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.
All analog inputs have a 12-bit resolution.
The firmware configures an ADC pin with the special “3-state” mode. The unconnected pin has a high level (3.3V).
⚠️ CC253x: If you configure another GPIO pin after ADC on the same port (P0x) with the “pull-down” mode, the unconnected ADC pin will have about 0.2V.
Analog input, accurate (max 1.15V) – the pin uses an 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. The device with the PSM firmware reports the battery state automatically without this sensor configured.
Internal temperature – reports the temperature of the chip. You may assign this sensor to any unused pin.
Scale factor – it is the optional scale factor. The scale factor cannot be zero. The firmware multiples the measured value by this scale factor before sending a value to a coordinator.
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: zigbee2mqtt/[friedly_name]/get/[channel] Channel: l1, l2, l3 … l16 Payload: 1 Returns the channel state: {"[channel]": float_value}
Krisztian Willinger
Hi,
I’m using PSM. All is working great but I can’t get the source voltage. You state “Source voltage – reports source power voltage. It can be used to monitor a battery level. You may assign this sensor to any unused pin. The device with the PSM firmware reports the battery state automatically without this sensor configured.”
I just can’t see this beeing reported. Is there a trick to it?
Thank you!
Owner
Please test the latest version. Previous versions didn’t work properly.
Krisztian Willinger
Thank you. The latest version is sending the voltage now, however the percentage is always 100% and the voltage 3400. I changed the power supply voltage between 2.5V – 3.3V but the reported values never change. The values is the same even if the device is powered on with 2.5V as a test.
Owner
Sorry, I cannot confirm it. The firmware works as expected.
Goridat
I am using a CC2530 in PSM mode and defined an “ADC (accurate, max 1.15V)” input on pin P00. There are no other inputs defined and two outputs on pins P10 and P11. Thus, I would expect to get a resolution of 1.15V/2048, right? Unfortunately, when I try to measure a voltage of 0.96v, as reported by all of my multimeters, the voltage reported in z2m is 0.902v. Am I using the wrong pins? Is there a way to calibrate this?
Owner
You can define ADC on any output. There you can specify additional parameters (shift and scale).
Zmiteri
Hi! Can you tell me about “Analog input, accurate (max 1.15V)” – what a resolution of ADC in this mode? I read datashet for cc2530 and a lit bit confused. range is 7bit-12bit, with effective number even smaller. Does it mean, that a minimal registered voltage is about 1mV resolution?
Owner
The firmware uses a 12-bit resolution. The full scale is 2048 bits, so one bit is 1.15V/2048.
frederic
Hello.
Just FYI and for the documentation.
I have been testing the “Analog input (max 3.3V)” mode.
(I suppose that to be more precise, this mode is “AVDD5 max.” mode).
I have been testing with AVDD5 (and all other VDD pins) around 3.3V.
The range I get is 0 to 2047.
2047 = 11 bits at “1”
So (at least for my CC2530), the resolution is 11 bits.
Alex
Hi, thanks for the great firmware. Couple questions related to voltages on the chip:
(1) Do you where where the about 0.2V comes from on the ADC inputs when nothing is attached?
(2) I heard from Doublet in the thread related to the moisture sensor that you’re currently building the configurable firmware to allow for battery operated Zigbee chips, is this true?
Thanks a lot!
Owner
Hi,
1. Sorry, but I don’t know.
2. Yes, I’m working on it.
Alex
Can you briefly explain what the issue is with using a battery? I seem to be able to get reports through z2m just fine when supplying 5V from batteries to my CC2531 chip.
Owner
The main problem is power consumption.
Alex
Hi,
Can you explain why the max 1.15V and max 3.3V for the analog input options?
Thanks!
Owner
It is a hardware limitation of the chip.
Doublet
This basic feature enabled me to build a Zigbee moisture sensor: https://community.home-assistant.io/t/diy-zigbee-capacitive-soil-moisture-sensor/251031. Thnx keep up the good work!
Owner
Thank you for the great example!