Page 1 of 1

Relais switching on at boot up MCU

Posted: 07 Oct 2018, 11:29
by Sasch600xt
Hello All,

i have a ralais board with 8 relais as "active low"
From my Lolin Nodemcu V3 i go from GPIOs to an ULN2803 Transistor Array because of 3.3V to 5V converting.
So far all works great.
So if i set GPIO to "High", the ULN2803 sets the input on the raleisboard to "LOW" an the Relais switches ON.

My problem now is, a few relais switching to "LOW" (ON) at bootup of the MCU for a part of a second.
This is happan to all my nodes with relais connected to.

This is not very good for my outdoor fridge for example or a water pump.

i used hardwaresettings for gpio ports like "GPIO Boot = Active LOW.
But it did not change anything.

Is there someting like:

Code: Select all

digitalWrite(gpioX, LOW); // prevents relay from activating after power-on
pinMode(gpioX, OUTPUT);
So important here is to give the gpio FIRST the "LOW" and then set it to Output.

Thank you for your answeres
Sascha

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 15:45
by enesbcs
Sasch600xt wrote: 07 Oct 2018, 11:29 Hello All,

i have a ralais board with 8 relais as "active low"
From my Lolin Nodemcu V3 i go from GPIOs to an ULN2803 Transistor Array because of 3.3V to 5V converting.
So far all works great.
So if i set GPIO to "High", the ULN2803 sets the input on the raleisboard to "LOW" an the Relais switches ON.

My problem now is, a few relais switching to "LOW" (ON) at bootup of the MCU for a part of a second.
This is happan to all my nodes with relais connected to.
There are a few GPIO's, that has alternative functions with all ESP8266 based devices, and has a default state on boot up such as: GPIO0, GPIO2 and GPIO15
It does not matter what do you do in your own sketches, this functions exists in a lower hardware level...
If you need to use them as output, please read how to do it:
https://www.instructables.com/id/ESP826 ... as-inputs/

I also succesfully redefined "RX" pin (GPIO-3) for output. (+1gpio)

OR you can buy an I2C port extender, OR you can use an ESP32 chip, that has a lot more real GPIO's.

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 17:33
by Sasch600xt
thank you very much for showing me not one, a few solutions to my problem.

i have an I2C port extender here and will try to get it to work.

brilliant ideas, thank you again!

Greetz
Sascha

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 17:59
by Sasch600xt
Sorry, i have one more question:

i found this page:
https://www.letscontrolit.com/wiki/index.php/PCA9685

but for me as a beginner the informations are not exact enough.

how would a http command looks like to set for example PCA9685 pin 3 to "HIGH" ? (for switching relays i do not need PWM, a simple "HIGH or 1" or "LOW or 0" will do the job.
So what do i have to put in the browser and hit enter ?

Thank you very much !

Greetz
Sascha

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 18:36
by Shardan
Sasch600xt wrote: 07 Oct 2018, 17:59 Sorry, i have one more question:

i found this page:
https://www.letscontrolit.com/wiki/index.php/PCA9685

but for me as a beginner the informations are not exact enough.

how would a http command looks like to set for example PCA9685 pin 3 to "HIGH" ? (for switching relays i do not need PWM, a simple "HIGH or 1" or "LOW or 0" will do the job.
So what do i have to put in the browser and hit enter ?

Thank you very much !

Greetz
Sascha
Sorry, but the PCA9685 is a PWM circuit (Pulse Width Modulation). It is usually for LED dimming or servo driving, I won't use that for relays at all even if that might be possible with some tech tricks.
For relays use PDF8574 or MCP23017.
The commands for these are quite simple. See
https://letscontrolit.com/wiki/index.php/MCP23017 for the MCP23017 and
https://letscontrolit.com/wiki/index.php/PCF8574 for the PCF8574.

Both circuits are connected via I2C-Bus. Further Info about I2C, addressing a port etc at https://letscontrolit.com/wiki/index.ph ... he_I²C_Bus

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 19:41
by Sasch600xt
ok, thank you for the informations.


Greetz
Sascha

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 20:07
by Sasch600xt
me again....sorry for 1000 questions :(

at the moment i use "monitor gpio" in rules to get feedback back to MQTT server about the state of my relays or at least the state of the gpio pins.

but with a portextender i guess i can not do it like this ?

or can i monitor the gpios of a portextender ?

goal would be to send a http command to the portextender and get a MQTT message of the status back.
(at the moment thats it like it works with the internal gpios rght now)

Greetz
Sascha

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 21:07
by grovkillen
Not a stupid question. Not yet merged but soon: https://github.com/letscontrolit/ESPEasy/pull/1848

Re: Relais switching on at boot up MCU

Posted: 07 Oct 2018, 22:57
by Sasch600xt
"soon" is enough for me......i also need time to build the devices :)

Thank you !

Greetz
Sascha

Re: Relais switching on at boot up MCU

Posted: 21 Oct 2018, 18:47
by Sasch600xt
Hello all,

may i ask for a documentation for this ?

or can you help me to get it to work ?
Probably i am the problem :)

I hooked up an MCP23017 to my node via SDA/SCL
I did config a device for "MCP23017 Input" at address port 32 (0x20, i made a scan first to get the address)

So now i have a switch which shows up always "0"
my goal would be to have all 16 Inputs via MQTT Message in my MQTT Broker.
Is this possible ?
Or do i have to get the state manually by active asking the ESPEasy with a command ?

Thank you so much for your help
Sascha
20181020.bin /4096 Normal

Re: Relais switching on at boot up MCU

Posted: 21 Oct 2018, 22:12
by grovkillen
You should use rules to publish the states of the GPIOs .

Re: Relais switching on at boot up MCU

Posted: 21 Oct 2018, 22:23
by Sasch600xt
ok, thank you

do you have a little example to do so ?

Thank you :)
Sascha

Re: Relais switching on at boot up MCU

Posted: 21 Oct 2018, 22:29
by grovkillen
Sasch600xt wrote: 21 Oct 2018, 22:23 ok, thank you

do you have a little example to do so ?

Thank you :)
Sascha
For publishing a state of the plugin for the hardware PCF8574 (as an example):

Code: Select all

On MQTT#Connected Do
 Publish,%sysname%/GPIO62/state,[plugin#pcfgpio#pinstate#62]
EndOn
More examples and events is found in the wiki pages.

Re: Relais switching on at boot up MCU

Posted: 21 Oct 2018, 22:41
by Sasch600xt
thank you very much :)