Use of a relay for a complicated scenario

My project has to imitate pressing a physical button that closes a 220v circuit on schedule.

I will be using a relay connected to the leads behind the button.

The problem is I need the relay to leave the circuit open both when power to the Arduino (and subsequently to the relay) is off, and when the Arduino is on but the relay is not yet triggered by the scheduler. I cannot allow even a momentary closing of the circuit as the Arduino powersup (e.g., after a power outage), because this will imitate pressing the button at the wrong time.

My initial thought was to add another relay that will power up the button-connected relay only when needed. However, I was wondering if there's a more elegant way of achieving the same goal without complicating the hardware? Does an Arduino Nano have a port able to provide constant voltage for a relay only upon a software instruction?

Show a schematic of how the relay is wired and the code to control it. It may be as simple as adding a pullup or pulldown resistor to keep to Arduino output in a state that keeps the relay off until the code in the setup function gets control of the pin.

Standard wiring and code from circuito.io: https://www.circuito.io/app?components=514,11022,3061987

Naturally I implemented that code in my sketch where it was needed.

The easier that you make it to help you the more help that you will get. Making us go to site to find your stuff is not making it any easier.

Naturally I implemented that code in my sketch where it was needed.

Naturally we need to see your code to help you with your code.

Why do u need to turn the Arduino off ?
Might there be a better way , such as a latching button just driving the relay , or a latching relay that only needs a pulse to turn on or off

Relays or opto-isolated relays don't do anything till current flows, so this should be a complete non-issue.

At reset/power up the Arduino output voltages are floating, but no current flows until one is set as an OUTPUT.

The one subtlety is with opto-isolated relay modules which use +5V supply for the opto isolator LED anodes,
this 5V must be connected to the Arduino 5V, not some other supply that is on with the Arduino is off.

MarkT:
At reset/power up the Arduino output voltages are floating, but no current flows until one is set as an OUTPUT.

Which gives me an idea -- I can move the call to pinMode away from setup so the relay module does not receive current at that stage.
Then, I can do a pinMode call only when the scheduler has to drive the relay, or, even better, connect the button's wires inversely to what I intended, let the pinMode call close the circuit on schedule, and later drive the relay to LOW.
I will give that a try and report back.

groundFungus:
The easier that you make it to help you the more help that you will get. Making us go to site to find your stuff is not making it any easier.
Naturally we need to see your code to help you with your code.

While I appreciate your willingness to help, I don't see how such a general question requires uploading any code. That's why I provided a link to the standard use of Arduino with a relay module. I (or anyone else) could have asked the same theoretical question before writing any code, and wouldn't be hard to answer to anyone experienced with relays.

DaveUnbound:
While I appreciate your willingness to help, I don't see how such a general question requires uploading any code. That's why I provided a link to the standard use of Arduino with a relay module. I (or anyone else) could have asked the same theoretical question before writing any code, and wouldn't be hard to answer to anyone experienced with relays.

Dave, by the same reasoning, you could just as easily have tested your theories yourself and learned a lot in the process.

Paul

Paul_KD7HB:
Dave, by the same reasoning, you could just as easily have tested your theories yourself and learned a lot in the process.

Paul

By the same reasoning, these forums should be shut down because newbies should learn the hard way.

I'm returning to share the solution to this problem, despite the unhelpful attitude by some posters.

I called a friend to ask the question, and he provided the answer without having to look at my code or electrical diagrams.

Turn out that, prior to calling the pinMode function at setup, one should digitalWrite HIGH to the pertinent relay module. This ensures the relay module does not change states when powering up.
For example:

#define RelayModule  2
void setup()
{
  digitalWrite(RelayModule, HIGH);
  pinMode(RelayModule, OUTPUT);
}
void loop()
{
  // Drive relay LOW and HIGH as needed
}

I suspect that whether the relay should be initially driven to HIGH or LOW depends on the exact type and model, but my electronics knowledge is limited and I have no way to confirm this. The above was tested on this 4-channel module.

void setup()
{
  digitalWrite(RelayModule, HIGH);
  pinMode(RelayModule, OUTPUT);
}

When the processor is reset all IO pins default to INPUT. Writing HIGH to an INPUT pin turns on the internal pullup resistor on that pin.

groundFungus:
When the processor is reset all IO pins default to INPUT. Writing HIGH to an INPUT pin turns on the internal pullup resistor on that pin.

Thank you for the explanation. So, if I understand correctly, the internal pullup resistor stays on even after I set the relevant pin to OUTPUT?

Yes.