I have a Raspberry Zero connected to the SO pulse output of an energy meter (ABB C13) using a direct connection to GND and GPIO13 configured as input with pull-up resistor, and a Python program with the standard setup of GPIO-event callback on a falling edge. I have an inkyPHAT as display which is updated in a separate thread. The main program just waits around. I.e. like
GPIO.setmode(GPIO.BCM) GPIO.setup(PULSE_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(PULSE_GPIO, GPIO.FALLING, callback=getpower, bouncetime=200) try: while running: time.sleep(10) except KeyboardInterrupt: running = False
In the callback I have
newtime=time.time() deltime=newtime-oldtime oldtime = newtime
and some data calculation and dumping to a file.
I measure the power use of my EV car charger (and I am not charging...), which in standby uses about 1.7 W. The meter gives 1000 pulses/kWh, so the interval is about 35 minutes.
This may stop after some hours, but sometimes I just loose patience and reboot and restart.
Do I need to/could do something in the callback to ensure the integrity of GPIO-event or whatever?
Should I skip the internal pull-up and use external parts instead? I haven't tried to "reverse" the circuit (connect to 3.3 V and GPIO and use pull-down, because the voltage outputs are used/blocked by the display)
I notice the erratic behaviour starts after 18:00, but I do not know of any events in the power usage in my home that changes dramatically at that time. The connection to the SO output is simple twisted pair, no shielding or otherwise.
Trying @joan suggestion, I added pigpiod and monitor.py and got this result which I read as a nice and steady signal:
(I suppose its ticks in microseconds, and the interval is about 2400 s with a 100 ms pulse.)
However, I see several callbacks between each 2400 s period for about three hours after which it settles again !?
So if the pulse is OK what else can trigger the callback?