Arduino Nano 12V via VIN pin. Weird behavior with relay.

Hi, I am using Arduino Nano.

I wired 12V power supply to VIN/GND pins. And trying to use 5V pin to power a relay module. Wiring this way, the relay module behaves strangely when powering the nano with 12V, the behavior is random, sometimes switches on for one second then relay loses power, or sometimes lasting longer before losing power again.

If I power the Nano and Relay with usb cable (while I was uploading the codes), the relay functions as expected.

Am I doing anything wrong with the VIN/GND wiring with 12V?

Thanks.

The relay is using somuch power that the Power regulator on the NANO cant keep the power due to overheat.
Use a 5 Volt power supply, also when you bring down the voltage from 12 Volt to about 7 Volts will help with heat dissipation on your NANO.

12volt is to high for a Nano, and destructive if you are trying to use it as a power supply for a relay.
Try powering the Nano with a 5volt cellphone charger, connected to the USB socket.
Leo..