Automation Phat and power saving?


Raspberry Pi Zero, running raspbian Jessie, with an Automation PHat. Outputs connected to an rgb LED, input to PIR, and the relay in use.
I have a script that listens for the PIR on the Automation PHat input, and triggers the relay and the outputs (to light up the LED). It works fine! For about a half hour. After this the PIR input works, but the relay and LED stops working- the code thinks it is triggering them, but nothing happens. Is there some kind of power saving?

I’ve even put the relay on a loop- checking the state and trying ‘’ repeatedly- but it stays off (as does the LED).

Any ideas? Logs to look in, things to try? A command to reset automationPhat if it stops responding?



This is definitely not normal. Have you installed any other boards on your Pi? It sounds like some other software is running and causing a pin state change, or perhaps something crashing in Python itself.

What do you have to do to get the relay switching and the LED lighting up again? Do you quit and re-run the Python program, or does it require something more drastic?


There are two other things on the gpio - an i2c real time clock- which should just be used when the pi boots to set the time, and a htu21d humidity/temp sensor- called every hour, it saves temp information to the database- wander if the time it runs corresponds to automationphat stopping working! I think it uses pigpio, so maybe a conflict of things all wanting the gpio. Shall turn it off and see!

The script runs as an idle systemd script- it runs a loop forever looking for PIR input. The same problem happens if I just run the python script manually too. It works again if I restart the script.


This was indeed the problem- two separate scripts trying to use automationHat libraries- so when the second sensor-script ran, it was overwriting things in the first continuously-running script just by importing the libraries, which were never reset.

Does mean you can’t use different parts of the board in different scripts, but working around that is easier and better than having everything stop working every half hour! I could possibly rewrite the continuous-script to redeclare which pins should be doing what every loop, have a second i2c ADC for the sensor attached to the automationPhat, or use the continuous-script to do the sensor-reading as well at appropriate times!


I’d probably check the time in the continuous script and have that do the sensor readings too. It’s certainly possible to use different parts of Automation HAT with different scripts, but not via the standard Python library. It’s designed to be as simple as possible and set everything up automatically when it’s imported so yes it’ll definitely clobber itself if you run more than one instance :D