user80548: I am going to connect NodeMCU to a latching relay board like tis one (4 channel version): LINK
Both MCU board and relay board will be powered from the same 5V voltage regulator.
Now I have two problems to solve:
Problem 1 - logic levels
NodeMCU logic level is 3.3V and relays board works in 5V levels.
I can either use logic level converters or simple transoptors. Because I am going to attach NodeMCU to a custom PCB, I think transoptors will be simpler to solder.
Problem 2 - relay triggers with low pulse on the control pin
This relay boards works like this: every time the channel pin (T1 - T4) is connected to ground for few miliseconds - the relay flips to other state.
Here is the question: when the MCU board resets/reboots on power cycle, how do I ensure that the control pins are HIGH from the beginning? If they are not, the relay can flip randomly before my program starts and I will not know the initial state of relay.
What would be the best approch here ?

user60431: Since ports commonly are configured as inputs at reset, you will need to add a pull-up resistor.
Then write your setup so that the pin is high before switching to output mode.
EDIT:
Some microcontrollers have internal pull-ups, that are even activated at reset, see the specific data sheet. (Thanks, Juraj. I don't know NodeMCU enough to go in details. Anyway, my answer might apply to other controllers and other loads, too.)
The value of the pull-up can be determined by the maximum input current for the relay module (or your adapting circuitry) and the respective voltages. To be sure, make it a bit smaller, for example to the next E-series value. Just an example: minimum supply voltage is 3.15V (3V minus 5%), the maximum input voltage to detect "high" is 2.4V and maximum input current is 10 µA. Then the resistor will need to be at most Rmax = (Vdd_min - Vin_max) / Iin_max = (3.15V - 2.4V) / 10 µA = 75kOhm. This value is part of the E24 series, but is can be 68kOhm that is in the E6 series.
However, it seems as if the circuit of the modules contains a simple PNP BJT, a pull-up will not work here, because the input needs to be pulled up to the supply voltage of the module. You need a level converter, this could be a simple transistor. How to design that circuit, is another issue. There are lots of information in the web how to do this.

80548: <p>I am going to connect NodeMCU to a latching relay board like tis one (4 channel version): <a href="https://www.wish.com/product/1pc-5v-12v-flip-flop-latch-relay-module-bistable-self-lock-io25c04-5ddc9180e799ac03db9d54d3?hide_login_modal=true&amp;share=web" rel="nofollow noreferrer">LINK</a></p>
<p>Both MCU board and relay board will be powered from the same 5V voltage regulator.</p>
<p>Now I have two problems to solve:</p>
<p><strong>Problem 1</strong> - logic levels</p>
<p>NodeMCU logic level is 3.3V and relays board works in 5V levels.
I can either use logic level converters or simple transoptors. Because I am going to attach NodeMCU to a custom PCB, I think transoptors will be simpler to solder.</p>
<p><strong>Problem 2</strong> - relay triggers with low pulse on the control pin</p>
<p>This relay boards works like this: every time the channel pin (T1 - T4) is connected to ground for few miliseconds - the relay flips to other state.
Here is the question: <strong>when the MCU board resets/reboots on power cycle, how do I ensure that the control pins are HIGH from the beginning?</strong> If they are not, the relay can flip randomly before my program starts and I will not know the initial state of relay.</p>
<p>What would be the best approch here ?</p>
 60431: <p>Since ports commonly are configured as inputs at reset, you will need to add a pull-up resistor.</p>
<p>Then write your setup so that the pin is high before switching to output mode.</p>
<p><strong>EDIT:</strong></p>
<p>Some microcontrollers have internal pull-ups, that are even activated at reset, see the specific data sheet. (<em>Thanks, Juraj.</em> I don't know NodeMCU enough to go in details. Anyway, my answer might apply to other controllers and other loads, too.)</p>
<p>The value of the pull-up can be determined by the maximum input current for the relay module (or your adapting circuitry) and the respective voltages. To be sure, make it a bit smaller, for example to the next E-series value. Just an example: minimum supply voltage is 3.15V (3V minus 5%), the maximum input voltage to detect &quot;high&quot; is 2.4V and maximum input current is 10 µA. Then the resistor will need to be at most Rmax = (Vdd_min - Vin_max) / Iin_max = (3.15V - 2.4V) / 10 µA = 75kOhm. This value is part of the E24 series, but is can be 68kOhm that is in the E6 series.</p>
<p>However, it <a href="https://arduinodiy.wordpress.com/2018/08/07/re-inverting-an-inverting-relay/" rel="nofollow noreferrer">seems as if the circuit of the modules contains a simple PNP BJT</a>, a pull-up will not work here, because the input needs to be pulled up to the supply voltage of the module. You need a level converter, this could be a simple transistor. How to design that circuit, is another issue. There are lots of information in the web how to do this.</p>
