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

User avatar
By rudy
#82146 GPIO4 and GPIO5 both do not have the internal pull up resistor enabled at startup. They are the only two pins that do not need any special handling. They will be floating and should not provide any current to turn on a transistor.

With GPIO12,13,14 a strong pull down would be required.
User avatar
By array81
#82153
btidey wrote:A lot of the GPIO pins go high through a weak internal pull up of around 36K until the device has booted and you set the pinMode yourself.

If your relays are set to be active high then you need the GPIO to be low during the boot up period to avoid the relay being set on during this period.

In general try to avoid using GPIO 0 and 2 (D3, D4) as these have to be high during the boot period for normal use.

GPIO15 (D8) would be a good pin to use as it has to be low during the boot period and the board will have an pull down already on the board.

For other pins you need to use a separate external pull down resistor which needs to go from the pin to 0V as well as the pin being connected to the relay input. So for example, use GPIO4 (D2) and a pull down resistor of say 4K7 to 0V.


My 2 channel relay is active LOW, so on start I set "digitalWrite(pin, HIGH);" for D3 and D4. However you have wrote that D3 and D4 have to be high during the boot and this should help me but relay is active so D3 and D4 go in LOW status for some ms.
User avatar
By btidey
#82154 Active low should be less problematic but obviously now you should avoid GPIO15.

Are you doing the digitalWrite(pin,1) before doing the pinMode(pin, OUTPUT)? That ensures that when you do the pinMode the state won't change.

The other thing to try is to see what active LOW means on the relay. This can vary a bit dependent on the relay input circuitry. Often it will be done with an opto isolator with a pull up through a diode/LED but there are variations. Without connecting the relay to the nodeMCU check what the relay does with an o/c input and what value of resistor to ground is needed on the relay i/p to turn it on.
User avatar
By rudy
#82160 If your relays turn on with a low then use GPIO12-14 if they are available. They are pulled up and there are no other conflicting operations with those pins at startup.

GPIO02 had been used to output serial diagnostic information at startup in the past. I'm not sure if that has changed. That would cause unexpected outputs.