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}

Comments
Harvey Specter
Posted at 17:42 April 9, 2024
Aldo
Reply
Author

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

    Harvey Specter
    Posted at 05:04 April 15, 2024
    Owner
    Reply
    Author

    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);

Harvey Specter
Posted at 00:04 February 24, 2024
Michael
Reply
Author

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

    Harvey Specter
    Posted at 12:16 February 24, 2024
    Owner
    Reply
    Author

    I think, it is a job of a higher level system.

Harvey Specter
Posted at 08:40 October 24, 2022
Krisztian Willinger
Reply
Author

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!

    Harvey Specter
    Posted at 08:42 October 24, 2022
    Owner
    Reply
    Author

    Please test the latest version. Previous versions didn’t work properly.

      Harvey Specter
      Posted at 10:30 October 24, 2022
      Krisztian Willinger
      Reply
      Author

      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.

        Harvey Specter
        Posted at 03:45 November 1, 2022
        Owner
        Reply
        Author

        Sorry, I cannot confirm it. The firmware works as expected.

Harvey Specter
Posted at 00:25 July 5, 2022
Goridat
Reply
Author

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?

    Harvey Specter
    Posted at 05:41 July 5, 2022
    Owner
    Reply
    Author

    You can define ADC on any output. There you can specify additional parameters (shift and scale).

Harvey Specter
Posted at 16:49 March 11, 2021
Zmiteri
Reply
Author

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?

    Harvey Specter
    Posted at 03:26 March 12, 2021
    Owner
    Reply
    Author

    The firmware uses a 12-bit resolution. The full scale is 2048 bits, so one bit is 1.15V/2048.

      Harvey Specter
      Posted at 13:38 December 16, 2022
      frederic
      Reply
      Author

      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.

Harvey Specter
Posted at 16:04 February 16, 2021
Alex
Reply
Author

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!

    Harvey Specter
    Posted at 11:31 February 17, 2021
    Owner
    Reply
    Author

    Hi,
    1. Sorry, but I don’t know.
    2. Yes, I’m working on it.

    Harvey Specter
    Posted at 13:50 February 17, 2021
    Alex
    Reply
    Author

    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.

      Harvey Specter
      Posted at 14:04 February 17, 2021
      Owner
      Reply
      Author

      The main problem is power consumption.

        Harvey Specter
        Posted at 12:24 February 25, 2021
        Alex
        Reply
        Author

        Hi,

        Can you explain why the max 1.15V and max 3.3V for the analog input options?

        Thanks!

          Harvey Specter
          Posted at 03:46 February 26, 2021
          Owner
          Author

          It is a hardware limitation of the chip.

Harvey Specter
Posted at 20:41 December 1, 2020
Doublet
Reply
Author

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!

    Harvey Specter
    Posted at 04:01 December 2, 2020
    Owner
    Reply
    Author

    Thank you for the great example!

Leave a Reply to Goridat
Cancel Reply