So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By parachutesj
#68943 Dear all,
I am after more than a year back with ESP. In the meantime I advanced with Arduino and think I know mostly what I do.
However I wanted to realize something with ESP8266 (Wemos or NodeMCU) and currently stuck.

I do have a simple circuit with a dual relay connected to PINs D5 & D6 plus a switch which has positions off, up, down (basically either both are off, or one of them are on)
The intention is to drive a rollershutter.
The switches are connected to ground and the other pin to D3 and D4 and each with a resistor to VCC.

Basically it works. However during startup of the node, the swich needs to be in the off position otherwise it ends in a endless loop and never starts up.
So I figured, that on D3 and D4 if it is LOW, it does not boot.
However I cannot prevent that during boot the switch is always in the off position. Is there a way around this?
Potentially are other PINs than D3/D4 better suited?

A workaround could be having two resistors in different values connected to analog and compute. However in the end I wanted to have at least 4 relays with 4 directional switches connected.

Thanks a lot
Cheers,
SJ
User avatar
By DTrain123
#69022 The esp8266 uses 3 GPIO pins to select its boot mode.

See here: https://github.com/esp8266/esp8266-wiki ... ot-Process

A normal startup will boot from SPI flash, so needs GPIO15 = Low, GPIO0 = High and GPIO2 = High.

I'm not sure exactly what board your using but on the Wemos D1 R2:
D8 = GPIO15, D3 = GPIO0 and D4 = GPIO2

So D8 needs to be low and D3 and D4 both need to be high on startup.

This causes problems when using them as inputs, because if they are in the wrong state at startup it will change the boot mode.

There is a workaround you can do, where you connect one side of the switch to D3 or D4 (with a pull up resistor) then connect the other side of the switch to a third GPIO (instead of connecting to ground).
On startup the third GPIO will act as an input with high impedance so the switches won't affect the boot mode. Then once the program starts you can reconfigure the third GPIO as an output and switch it to Low. The third output then becomes the ground for the circuit and allows the switches to change the D3 and D4 inputs.

This method is explained here: https://www.forward.com.au/pfod/ESP8266 ... index.html