Electronic problem with a relay controlled servo motor

Hello everyone,

I want to control a servo motor to open a door in the morning and close it in the evening.
I got it to work by simple getting the time with an DCF77 module and connecting the servo motor to 5V, GND and an Arduino PWM pin. This is shown in the attached circuit diagram with the hardware switch in position 2. So far so good.

Because the servo motor tends to buzz while it is not moving I want to disconnect it from 5V when it is not used.
Therefore I added the hardware switch that is shown in the circuit diagram. Putting the switch to Position 1 interposes a relay between the 5V pin and the servo motor. The relay is switched by a digital Arduino pin by means of a transistor.

In my opinion this should work, too.
But I experience a very unstable behaviour of the board that is not quite predictable.
Somtimes the relay toggles again and again after turning on the Arduino and serial communication with the board is no longer possible.

Does anyone have an idea what I am doing wrong here.
I appreciate any help or comments.


Arduino_Sketch_150.tif (80.7 KB)

Does anyone have an idea what I am doing wrong here.

Powering heavy loads like servos and possibly the relay from the arduino is not a good idea. You can use the servo detach function to probably stop the servo buzzing (which normally occurs when the servo is under some type of load).

The servo and the relay together don't consume more than 200 mA, so this should not be the reason for my problem. But nevertheless your suggestion to detach the servo solved the problem.

Thanks, A