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

User avatar
By array81
#82232
rudy wrote: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.


I will try with GPIO12-14
User avatar
By ryan780
#92799
array81 wrote:
Good Science For You wrote:You want a pull up pin on startup.


D3 IO, 10k Pull-up GPIO0
D4 IO, 10k Pull-up, BUILTIN_LED GPIO2

Also in the setup() set the pin to HIGH to start.

digitalWrite(pin, HIGH);

Then change to LOW as needed in the main loop.


Thanks for your replay.

I just use D3 and D4 to control my relay and I set digitalWrite(pin, HIGH); on setup but this not works. I relay is active for a fraction of a second on device start. After this all work.
I have read on other forum that for this scope is not possible use the internal pull-down resitor but I need add an external (I don't know why, maybe the resistance is too small) but I don't understand the scheme. I just have use pull-down resister for button but not with relay. I need connect PIN with GND by resister before relay?


You cannot use a pull-down resistor on D3 or D4 as both pins must be high to boot into the normal program. Pulling pin D3 (GPIO0) will put the d1 mini into flash mode.

If you used D1, D2, D5, D6 or D7 instead you will not get the momentary trip of your relay when your board boots because those pins will be high at boot. You also can't use D8 because that pin has a built-in pull-down and boot will fail if that pin is pulled high, which it would be if you connected your relay board (the signal pin from the board is high and your esp board pulls it low to turn it the relay "on".