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.
⚠️ THIS FEATURE IS AVAILABLE IN THE PREMIUM VERSION
![PCF8583. Typical configuration](https://ptvo.info/wp-content/uploads/2021/03/pcf8583.png)
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.
![](https://ptvo.info/wp-content/uploads/2021/03/pcf8583-schematic.png)
![](https://ptvo.info/wp-content/uploads/2021/04/pcf8583-counter.png)
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
Pedro
It is possible to set the counter via ZHA (Zigbee Home Automation)? I was able to write the value via “Manage Zigbee Device” but after a pulse, the device restores the previous value + 1.
Owner
It is possible only if you add your code to a custom converter generated in the configurator. Currently, you can set the counter in Z2M only.
Pedro
I have add a “quirck” as custom converter to my ZHA and I can confirm that is loaded on the device page. Looks like it just assume the new value few seconds after a power cycle.
Hablahab
I tried connecting to of the these, one with A0 connected to ground, one with A0 connected to 3.5V. The second one works with adress 81 however the first one with adress 80 does not work. Anyone got two of these running? Also I would like them to count and report values every 60s or so in PSM Mode. Any suggestions how to reset them every time after they reported?
Damian
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.
Damian
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)
Owner
The standard address is 0x50 (hex) or 80 (dec) in the firmware.
Damian
Thanks, on address 80 it is working… Strange that in PCF8583 platformio library I must enter 0xA0 (8 bits, not 7)…
Owner
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.
Damian
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)?
Owner
Yes, it requires the premium version.
Damian
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
Owner
Could you please share a schematic? I’ll add an alternative on the page.
Damian
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)