[SOLVED] Could you check my circuit? - push on, dynamic off, with relay

Hi, gentle men and ladies.
First, forgive my short English.

I'm new in microcontrollers, electric parts.
I wanna turn off my arduino in sorce code.

So, I did this

push the button to switch relay, (keep push while arduino doing setup)
then arduino output D2 HIGH.
D2 keep switch on.
And make it LOW after several jobs,
then turn off arduino.

It works.
But I'm not sure its safe.
Is there something wrong in circuit?
kind of electric problem?
or could you give me some advices to improve its safety.

Thanks all of you.

Currently with the circuit that you have, you will power the Arduino through the output pin just for a moment when you hit the button. This could possibly hurt the Arduino.

If you run the black wire or negative power through the relay, instead of the red wire which is positive, the Arduino will be protected at least until it has power to it.

With the negative disconnected at the relay, the Arduino will not be able to see the button voltage so Arduino will not get hurt.

to cyclegadget

Thank you.
I didnt know that.
I have no idea about electricity.

You mean
when arduino has negative connection and no postive power,
positive to D2 makes problem.
right?

So,
like this?

Thank you. you saved my life.

But.
I do worry about positive.
I can't explain,
I just know(think? heard?) that everything has ground.

I think
Device connected GND only - Hmm, It's OK. It has no electricity.
Device connected Positive only - Oh, It's dangerous! it will be fire!
am I wrong?

===
I did wire it as new one.
It has problem.
If i connect power to new wiring,
then tick,tick,tick,tick,tick,tick,tick, relay switch rapidly.
I dont know why.
if I push the button to turn on arduino, it works.
And LOW to D2(close relay, turn off arduino),
then tick,tick,tick,tick,tick,tick,tick, switch rapidly again.

Add a diode in series with the D2 wire.
Anode to the D2 pin cathode to the relay pin.

Show us a schematic for the relay board.

5 volts to the Arduino jack will not power the UNO.

.

To larryd.

Thanks for your concern!
I dont know what diode is,
but, will try to figure it out.

need spec of that relay?
Im gonna look for that.

BTW,
in your opinion,
second one is better, too?

5 volts to the Arduino 'power jack' will not power the UNO.

Make sure your power supply is regulated 5VDC !

Hook up things as in the attached image.

To larryd.
You will never know how much i appreciate.

First,
these are my boards. and i need a diode.

i can't find spec of relay yet.

Your image says
5VDC power to 5V,GND pin of arduino?
not DC jack?
is it OK?

The DC jack voltage has to be between 7V to 12V for the UNO on board regulator to work.

If you put 5V into the DC jack, you will have problems getting the UNO working.

If your external power supply is regulated 5 volts, you can connect it to the 5V and GND pins on the Arduino as in my image.
Remove these connections when powering the Arduino from the USB connector.

.

To larryd.
Oh your Highness.

I got these now.

  1. I need a diode to prevent power to D2.
  2. In that wiring, use 5V,GND pin instead of DC jack.
    because 5V is too weak to run arduino through DC jack.
    So, It must be sure 5V power source.

Thank you.

Can I ask more?
If I do not cut 5V,GND when connect USB,
what hanppen?
is it dangerous? may burn arduino or relay or plug? shut down whole electricity in the house?

"1. I need a diode to prevent power to D2.
2. In that wiring, use 5V,GND pin instead of DC jack.
because 5V is too weak to run arduino through DC jack.
So, It must be sure 5V power source."

Yes

Sorry to bump.

Can I ask more?
If I do NOT cut 5V,GND when connect USB and switch relay on,
what hanppen?
is it dangerous? may burn arduino or relay or plug? shut down whole electricity in the house?

Your house will be okay.

However, it is not recommend to power the UNO from 'both' the USB connector and the 5V pin at the same time.

To larryd.
Thank you again.

Im gonna edit title to SOLVED.

Take care.