2

I am trying to make a smart plug that activates a relay when it receives a certain message via MQTT. It works, but the Pi shuts down randomly, both when the relay is active and when everything is just idling. It seems to happen more often when it's active, but I haven't really kept track of it.

Here is the circuit:

enter image description here

When an MQTT message within a certain range is received, GPIO27 is set to high, which activates the gate on the transistor (2SC9013), completing the circuit to the solid state relay (Fotek SSR40 DA). There is an LED connected to the TX pin for a status light, and a shutdown button that uses the script provided by Howchoo.

I'm running off a clean install of Buster lite. The Pi is a wifi hotspot that I set up using the rasberrypi.org doc. Besides that, the only other things running are a mosquitto broker, my Python relay script, and the power button script.

Troubleshooting:

Google says that the two most common causes for this problem are overheating and power supply problems.

I started logging the temperature and checking CPU usage with top. Temp floats around 46C and CPU usage occasionally spikes to 20%, but mostly stays around 1%.

Everything is sealed up with shrink tubing and the only place I can access the incoming power is the lugs on the SSR. Voltage consistently levels out at 4.86V from around 4.7V when the relay is activated. I got the same reading even on one of the instances where the Pi shutdown.

There are no errors in syslog. When the Pi shuts down, it has time to shutdown some services, but it doesn't look like it shuts down as many as it does during a regular shutdown. I can post the log info, but it is about 50 lines long. The log entry before the shutdown ones occurs much earlier and doesn't seem to be related.

I thought maybe the power-off script was being triggered somehow, so I added logging to that, but it doesn't log anything unless I actually press the button.

I also tried redoing the whole project on another SD card. Same results.

Questions:

The obvious culprit here is the power supply. I know cell phone chargers are not stable, but I'm need something small. If I am reading 4.86V, is that what the Pi is really getting, or is a voltage dip possibly causing the shutdown?

I chose that transistor mostly because that is what I had lying around. Could the transistor be the problem?

Or, is there something else I am missing completely?

Thanks for any suggestions.

1 Answer 1

1

Insufficient current would seem to be the problem (a symptom being the low voltage).

1 amp at 5 V should be enough. It seems unlikely that your phone charger is actually supplying that. I think you need to try a different charger.

1
  • Thank you for the reply. I just tried using a benchtop regulated switching power supply. With the power supply set to 5V, I measure about the same voltage when the switch is activated (~4.85V). Bumping the voltage up to 5.1V and 5.2V gives me 4.96V and 5.06V. The supply is showing current between 0.16 and 0.2 amps. Curiously, the Pi is shutting down even faster for the benchtop supply than with the phone charger. Could it be something shorting out in my wiring only when things "heat up" a little (usually after about 45 minutes sitting idle or 5 or 6 activations of the the relay)
    – makerws
    Oct 14, 2020 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.