The PCF8583 is a clock and calendar chip. It has an event-counter mode.

The event counter mode counts pulses applied to the oscillator input (OSCO left open-circuit). The event counter stores up to 6 digits of data. The chip saves the counter value in an internal CMOS RAM and saves a value without external voltage. You may use this counter in the power-saving mode.

PCF8583. Typical configuration
PCF8583. Typical configuration

Note: Maybe, you need an external debounce filter (74HC132) for a counter input. Otherwise, the counter will count many noise values. The recommended schematic is shown below.

PCF8583. Schematics.
PCF8583 counter. Schematics without a simple RC debounce filter.

The firmware allows you to set an initial counter value from a coordinator using the “write” command below.

Zigbee2MQTT commands

read - immediately reads the counter value.
Topic: zigbee2mqtt/[friedly_name]/get/[channel]
Channel: l1, l2, l3 … l16
Payload: 1
Returns: The counter value {"[channel]": float_value}
write - resets the counter, or sets any initial value.
Topic: zigbee2mqtt/[friedly_name]/set
Channel: l1, l2, l3 … l16
Payload: {"[channel]": [value]}
Value: 0 or any your number

Comments
Harvey Specter
Posted at 17:33 April 11, 2021
Damian
Reply
Author

I have problem with PCF8583 and CC2530 setup… I’m using like on this example – P15 as SDA and P13 as SCL. PCF8583 address is 0xA0 so 160 in dec. Unfurtanelly I see only 32 value of l1 endpoint all the time, and when I try to set 0 for example to this endpoint, I’ll get immediately status: Failure response.

    Harvey Specter
    Posted at 19:24 April 11, 2021
    Damian
    Reply
    Author

    Same prototype test board works with esp8266 (I just switched SDA and SCL cables from CC2530 to ESP8266 with ESPHome). ESPHome i2c scan shows device at 0x50, but I need to use 0xA0 address in PCF8583 lib – https://platformio.org/lib/show/535/PCF8583, in PCF8583 datasheet also references to 0xA0 address when A0 pin isn’t connected to VCC)

      Harvey Specter
      Posted at 03:47 April 12, 2021
      Owner
      Reply
      Author

      The standard address is 0x50 (hex) or 80 (dec) in the firmware.

        Harvey Specter
        Posted at 06:32 April 12, 2021
        Damian
        Reply
        Author

        Thanks, on address 80 it is working… Strange that in PCF8583 platformio library I must enter 0xA0 (8 bits, not 7)…

    Harvey Specter
    Posted at 03:49 April 12, 2021
    Owner
    Reply
    Author

    The firmware accepts commands in the PSM mode for a short time (about 1 second) after the last report.
    FYI: the standard address is 0x50 (hex) or 80 (dec) in the firmware.

Harvey Specter
Posted at 13:07 April 11, 2021
Damian
Reply
Author

PCF8583 requires premium version (I can’t save firmware in generator when PCF8583 is chosen). Can I test it first before buying (I want to build battery powered device but it would be nice to test it first without PSM)?

    Harvey Specter
    Posted at 14:09 April 11, 2021
    Owner
    Reply
    Author

    Yes, it requires the premium version.

Harvey Specter
Posted at 16:33 April 7, 2021
Damian
Reply
Author

I’m still waiting for my CC2530, and meanwhile i’ve build such counter on esp8266 – it works just fine with one PCF8583 and 1K resistor + 100nF capacitor as RC filter before PCF8583 and input signal, so 74HC132 (or any other NAND gate) is not really necessary for counting pulses not faster that about 20 ms each

    Harvey Specter
    Posted at 03:30 April 8, 2021
    Owner
    Reply
    Author

    Could you please share a schematic? I’ll add an alternative on the page.

      Harvey Specter
      Posted at 07:29 April 8, 2021
      Damian
      Reply
      Author

      Yes, it’s very simple:

      https://ibb.co/S39VNRS

      It is working with photoresistor module since yesterday and it counts very well LED pulses from energy meter (6400 pulses per kWh)

Leave a Reply