How to power a servo & nano from 1 wall adapter

I have this wall adapter powering a nano and from the nano i draw power for: PIR & Servo. But this makes the servo unstable. This is my setup:

Would I need a capacitor here? How do I calculate it?

Its an MG995 servo.

Your present power supply is how many volts and how many amps ?

Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

Are you counting on the Nano's 5V regulator to power the servo?
Does the sketch seem to restart a lot? Write your sketch to turn on the D13 LED briefly in setup(), see if it comes on a lot. Sketch reset could indicate the regulator dropping out from overheating or overcurrent.
Or maybe your wall regulator is.

An MG995 can take around 1.2A on startup. A Nano 5V pin can only reliably supply less than 400mA, maybe considerably less depending on the specification of "this wall adapter". A capacitor isn't going to help much with that.

Steve

You have not told us how the wall adapter is connected to the nano. If it has a regulated 5v output that is connected to the 5v and GND connections (where the red and black wires connect in your diagram) then the power will go to the servo without having to go through the Arduino.

Of course this assumes the wall adapter can provide enough amps.

...R

The nano is connected to the wall adapter via the USB connector.

Yes I understand the nano cannot supply enough. That's why I'm asking what would be a better way to power both servo and nano.

Marciokoko:
The nano is connected to the wall adapter via the USB connector.

Yes I understand the nano cannot supply enough. That's why I'm asking what would be a better way to power both servo and nano.

And that is why we are asking the capacity of the power adaptor ?

Sorry, thought I had answered that. It was 5v/400mA but I switched to 5V/1A. It works fine now but I still want to know the best way to power the setup.

If it works now then you should probably not change things.

Clearly it was a current shortage which you fixed with a higher rated PSU for that aspect.

Marciokoko:
The nano is connected to the wall adapter via the USB connector.

Consider cutting the connector off the cable from the wall adapter so you can join wires to the cable and connect both to the nano and the other loads.

But FIRST answer the question about the specifications of the wall adapter - in particular the volts and amps it can provide.

...R

He did Robin

It is now 5 volts 1 amp and running fine up from a lowly 400 mA at the same voltage.