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}
Aldo
Hello,
I’m starting with you software and it is great !
The voltage reported to my Zigbee2Mqtt in “ADC max3.3V” or “Analog input, accurate (max 1.15V)” is only 1 decimal digit. Is there a way to get more digits ?
Is there a way to get the “Analog input, accurate (max 1.15V)” in raw value ?
Thanks
Owner
Sorry, rounding is implemented in Z2M, and yes, it is 1 digit after a decimal point for voltage.
But a workaround is possible. You can change it in Z2M:
1. Go to zigbee-shepherd-converters – converters – fromZigbee.js
2. Find the function “ptvo_switch_analog_input”
3. Change the row:
let val = (0, utils_1.precisionRound)(valRaw, 1);
to
let val = (0, utils_1.precisionRound)(valRaw, 2);
Michael
Hi. @Owner Is it possible to add an average function to improve the stability of the measurement and remove the fluctuation ? The input of this function will be the number of value we want to use to calculate the average.
Thank you
Owner
I think, it is a job of a higher level system.
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!