nodemcu with 8input and 8output (pcf8574)
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
nodemcu with 8input and 8output (pcf8574)
hi, i need to have this setup:
8ch relay
8 switch input
1 nodemcu esp8266
not used serial
i used this configuration:
GPIO10 = d2 = switch1
GPIO5 = d1= switch2
GPIO4 = d2 = switch3
GPIO0 = d2 = switch4
GPIO2 = d4 = switch5
GPIO14 = d5 = switch6
GPIO12 = d6 = switch7
GPIO13 = d7 = switch8
SDA = GPIO3 = d9
SCL = GPIO1 = d10
and all relays are conected to PCF8574
it's a good configration?
all switches are momentary switches (push buttons) and they are actived only for a while (up/down of blinds) and they are activated when they goes to GND
i tryed to use GPIO16 and GPIO15 but when i put them to GND nothing happened
it's safe using GPIO10 ?
i know that GPIO0 is used for flash, but it's very remote that nodemcu reboot in in this time someone press the corresponded push button...
what's the best usage for this implementation?
thanks to all!
ps. it's falshed in DIO mode
that's better to use DOUT ?
8ch relay
8 switch input
1 nodemcu esp8266
not used serial
i used this configuration:
GPIO10 = d2 = switch1
GPIO5 = d1= switch2
GPIO4 = d2 = switch3
GPIO0 = d2 = switch4
GPIO2 = d4 = switch5
GPIO14 = d5 = switch6
GPIO12 = d6 = switch7
GPIO13 = d7 = switch8
SDA = GPIO3 = d9
SCL = GPIO1 = d10
and all relays are conected to PCF8574
it's a good configration?
all switches are momentary switches (push buttons) and they are actived only for a while (up/down of blinds) and they are activated when they goes to GND
i tryed to use GPIO16 and GPIO15 but when i put them to GND nothing happened
it's safe using GPIO10 ?
i know that GPIO0 is used for flash, but it's very remote that nodemcu reboot in in this time someone press the corresponded push button...
what's the best usage for this implementation?
thanks to all!
ps. it's falshed in DIO mode
that's better to use DOUT ?
Re: nodemcu with 8input and 8output (pcf8574)
Not all GPIO pins on the ESP can be used for switches as some need to have a specific state at boot. (e.g. GPIO 0, 2 and 15)
Also not all pins have a pull-up resistor (e.g. 15, 16) and not all can be used in interrupt driven code (e.g. 16)
See the documentation: https://espeasy.readthedocs.io/en/lates ... on-esp8266
Also not all pins have a pull-up resistor (e.g. 15, 16) and not all can be used in interrupt driven code (e.g. 16)
See the documentation: https://espeasy.readthedocs.io/en/lates ... on-esp8266
Re: nodemcu with 8input and 8output (pcf8574)
Also:
The relays will need to be logic level activated with input currents that do not exceed the PCF8574's recommended output currents: logic low activation that is less than 25mA or logic high that is less than 1mA.
Some 8-channel relay modules are turned on by logic low levels, some require logic high levels. Some relays support either logic that is chosen by some jumpers. And some relays modules are controlled by serial commands rather than logic levels. Be sure you have a compatible relay module for your configuration.
- Thomas
The relays will need to be logic level activated with input currents that do not exceed the PCF8574's recommended output currents: logic low activation that is less than 25mA or logic high that is less than 1mA.
Some 8-channel relay modules are turned on by logic low levels, some require logic high levels. Some relays support either logic that is chosen by some jumpers. And some relays modules are controlled by serial commands rather than logic levels. Be sure you have a compatible relay module for your configuration.
- Thomas
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
hi, yes, i know thatTD-er wrote: ↑15 Mar 2020, 20:24 Not all GPIO pins on the ESP can be used for switches as some need to have a specific state at boot. (e.g. GPIO 0, 2 and 15)
Also not all pins have a pull-up resistor (e.g. 15, 16) and not all can be used in interrupt driven code (e.g. 16)
See the documentation: https://espeasy.readthedocs.io/en/lates ... on-esp8266
and i try as best solution on what i reported.
i tested it and it's working.
bu, i'm asking, if it's only luky or it can be improved.
Last edited by megamarco83 on 15 Mar 2020, 20:46, edited 2 times in total.
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
now i'm using relays that are triggered by low activations. not so confortable, but i use reverse logic, 1=not triggered and 0=triggeredThomasB wrote: ↑15 Mar 2020, 20:37 Also:
The relays will need to be logic level activated with input currents that do not exceed the PCF8574's recommended output currents: logic low activation that is less than 25mA or logic high that is less than 1mA.
Some 8-channel relay modules are turned on by logic low levels, some require logic high levels. Some relays support either logic that is chosen by some jumpers. And some relays modules are controlled by serial commands rather than logic levels. Be sure you have a compatible relay module for your configuration.
- Thomas
it works
i have also 1ch relay with jumper that i can choose type of activation but not yet tested
- budman1758
- Normal user
- Posts: 301
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: nodemcu with 8input and 8output (pcf8574)
Why not use an MCP23017? 16 inputs or outputs or any mixture. Also much more output current available.
"The glass is twice as big as it needs to be".
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
hi, thanks for suggestion!!budman1758 wrote: ↑16 Mar 2020, 20:11 Why not use an MCP23017? 16 inputs or outputs or any mixture. Also much more output current available.
so now i have
n°8 switches (input)
and n°8 relay (output)
every blind need 2ch relay and 2 switched, so with MCP23017 what configuration you suggest to control blinds?
i mean where i should connect input and output considering GPIO of nodemcu and 16 gpio of MCP23017 ?
thanks
- budman1758
- Normal user
- Posts: 301
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: nodemcu with 8input and 8output (pcf8574)
I imagine you can hook it up in whatever way is easiest. Use it for relays and switches and you could free up some GPIO in the nodemcu for other uses. You only need 2 GPIO for the I2C bus. You can also gang up as many MCP23017 as needed. Have fun!!i mean where i should connect input and output considering GPIO of nodemcu and 16 gpio of MCP23017 ?
"The glass is twice as big as it needs to be".
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
hi, i bought two mcp23017 one with pcb green and one with black pcb.budman1758 wrote: ↑17 Mar 2020, 18:12I imagine you can hook it up in whatever way is easiest. Use it for relays and switches and you could free up some GPIO in the nodemcu for other uses. You only need 2 GPIO for the I2C bus. You can also gang up as many MCP23017 as needed. Have fun!!i mean where i should connect input and output considering GPIO of nodemcu and 16 gpio of MCP23017 ?
green pcb was avaliable so i have on my hands only this one now.
i see that there are differences on pins name in this two configuration board.
can you please help me on wiring boths?
with the greeen pcb i see that on right side (two raw pins)
there are: VCC -> noedmcu 3,3V
GND -> nodemcu GND
SCL -> SCL gpio on nodemcu
SDA -> SDA gpio on nodemcu
then i would like to use PA0 to PA7 for switches and PB0 to PB7 for output relay
my switches are push buttons and i need short perss and long press:
if i'm not wrong i have to set the tasks like:
task name= B_UP
switch button type=normal switch
long press event= acive on low & hight event = 10 or 11
values=B_UP
on rules i can use:
Code: Select all
//short press
on B_UP#B_UP=0 do
Publish domoticz/in,'{"command":"setuservariable","idx":7,"value":"blind_1;Up;0.5"}'
endon
//long press
on B_UP#B_UP=10 do
Publish domoticz/in,'{"command":"setuservariable","idx":7,"value":"blind_1;Up;42"}'
endon
Code: Select all
on sniff#blind_1_Up=0 do MCPgpio,9,1
on sniff#blind_1_Up=1 do MCPgpio,9,0
because as far as i understand from 1 to 8 => PA0 to PA7
and from 9 to 16 => PB0 to PB7
correct?
and from wiring point of view
- push button -> one wire connected to PA0 and another wire connected to GND
- relay -> IN1 connected to PB0 and GND to GND and VCC to VCC
correct?
where i need to connect:
RST
ITA
ITB
???
now talk abot black board of mcp23017:
here i have A1 A2 A0 this three shoul connect to GND, correct?
where i have to connect RESET?
thanks
Re: nodemcu with 8input and 8output (pcf8574)
Hello
RST : connect it to EPS gpio only if you have any reason to reset the MCP board. I never had the need.
ITA, ITB those are interrupt pins. You can safely ignore them.
A1 A2 A0 : are for the I2C address. No need to do anything if you only have 1 x MCP in the same I2C bus.
-D
RST : connect it to EPS gpio only if you have any reason to reset the MCP board. I never had the need.
ITA, ITB those are interrupt pins. You can safely ignore them.
A1 A2 A0 : are for the I2C address. No need to do anything if you only have 1 x MCP in the same I2C bus.
-D
-D
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
ok, understand, thanks a lot!iron wrote: ↑18 Mar 2020, 15:28 Hello
RST : connect it to EPS gpio only if you have any reason to reset the MCP board. I never had the need.
ITA, ITB those are interrupt pins. You can safely ignore them.
A1 A2 A0 : are for the I2C address. No need to do anything if you only have 1 x MCP in the same I2C bus.
-D
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
but, another question related to MCP23017
if i wuold like to use it to control lights (on/off) and pushbuttons related to this, and send the status of relay to domoticz, so i can control the light using pushbuttons (gpio of mcp) or remotly using domoticz.
how i can do if i have only 12 tasks?
mcp has 16gpio
nodemcu has al least 6 usable gpio
in total 22 task should need.
because i guess that i have to create a task for relay, where i set the IDX of domoticz, so it can be aware about the relay status, and a task for every pushbutton. correct?
thanks
if i wuold like to use it to control lights (on/off) and pushbuttons related to this, and send the status of relay to domoticz, so i can control the light using pushbuttons (gpio of mcp) or remotly using domoticz.
how i can do if i have only 12 tasks?
mcp has 16gpio
nodemcu has al least 6 usable gpio
in total 22 task should need.
because i guess that i have to create a task for relay, where i set the IDX of domoticz, so it can be aware about the relay status, and a task for every pushbutton. correct?
thanks
Re: nodemcu with 8input and 8output (pcf8574)
Hello,
For output (mcpgpio,x,y) does not require to be set on any TASK you can just trigger it on demand.
For input you can set them on task but even that is not required if you monitor the pin on boot
monitor,mcp,#
-D
For output (mcpgpio,x,y) does not require to be set on any TASK you can just trigger it on demand.
For input you can set them on task but even that is not required if you monitor the pin on boot
monitor,mcp,#
-D
-D
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
thanks for explanations
but....at least i need to have inside the task for every relay, otherwise how i can set the IDX of domoticz?
i mean i have to comunicate to domoticz the status, and if i trigger the relay in domoticz, espeasy should be aware of that and should trigger in proper way the relay. i'm wrong?
related to pushbutton, ok, i think that i can use rules to monitor the status of input of MCP or GPIO directly connected to nodemcu and than switch the conresponded relay.
i'm not sure to understand how the monitor cn work for this purpose ???
i have in mind for example:
but it means that i have to use one tast for SW1 (pushbutton)
and a task for relay (RL1)
i think that a task for relay RL1 is needed, so i can set there the IDX of domoticz
i can skip the task for pushbutton, but how i have to setup the rules using monitor function i do not understand, sorry for that.
another question, is it possible withput a task for the pushbutton, use insede the rules the longpress action?
//short press
on SW1#state=0 do
....
//long press
on SW1#state=10 do
....
thanks
but....at least i need to have inside the task for every relay, otherwise how i can set the IDX of domoticz?
i mean i have to comunicate to domoticz the status, and if i trigger the relay in domoticz, espeasy should be aware of that and should trigger in proper way the relay. i'm wrong?
related to pushbutton, ok, i think that i can use rules to monitor the status of input of MCP or GPIO directly connected to nodemcu and than switch the conresponded relay.
i'm not sure to understand how the monitor cn work for this purpose
Code: Select all
monitor,mcp,#
i have in mind for example:
Code: Select all
On SW1#Switch=1 do
If [RL1#Switch]=1
mcpgpio,9,0
else
mcpgpio,9,1
Endif
Endon
and a task for relay (RL1)
i think that a task for relay RL1 is needed, so i can set there the IDX of domoticz
i can skip the task for pushbutton, but how i have to setup the rules using monitor function i do not understand, sorry for that.
another question, is it possible withput a task for the pushbutton, use insede the rules the longpress action?
//short press
on SW1#state=0 do
....
//long press
on SW1#state=10 do
....
thanks
Re: nodemcu with 8input and 8output (pcf8574)
That's were you need to start monitoring the MCP pins on bootmegamarco83 wrote: ↑19 Mar 2020, 14:24
another question, is it possible withput a task for the pushbutton, use insede the rules the longpress action?
//short press
on SW1#state=0 do
....
//long press
on SW1#state=10 do
....
on System#Boot do
monitor,mcp,1
monitor,mpc,2
monitor,mcp,3
endon
Then you can handle the gpios in your conditions
-D
-D
-
- Normal user
- Posts: 230
- Joined: 13 Apr 2017, 23:09
Re: nodemcu with 8input and 8output (pcf8574)
sorry, not understand how it can work.iron wrote: ↑19 Mar 2020, 18:58That's were you need to start monitoring the MCP pins on bootmegamarco83 wrote: ↑19 Mar 2020, 14:24
another question, is it possible withput a task for the pushbutton, use insede the rules the longpress action?
//short press
on SW1#state=0 do
....
//long press
on SW1#state=10 do
....
on System#Boot do
monitor,mcp,1
monitor,mpc,2
monitor,mcp,3
endon
Then you can handle the gpios in your conditions
-D
maybe i'm missing someting
Code: Select all
on System#Boot do
monitor,mcp,9
monitor,gpio,0
endon
on gpio#0 do
if [gpio#0]=1
mcpgpio,9,0
else
mcpgpio,9,1
endif
endon
mcpgpio,9 is the output (inverted relay 1=off 0=on)
but it's not working
that's the log with only one press of push button:
Code: Select all
1696476: EVENT: GPIO#0=0
1696537: ACT : mcpgpio,9,1
1696538: Command: mcpgpio
1696543: MCP : GPIO OUTPUT 9 Set to 1
1696555: EVENT: MCP#9=1
1696609: SW : GPIO=0 State=0 Output value=1
1696656: EVENT: pulsante_mcp1#State=1.00
1696876: EVENT: GPIO#0=1
1696937: ACT : mcpgpio,9,1
1696939: Command: mcpgpio
1696944: MCP : GPIO OUTPUT 9 Set to 1
1696953: EVENT: MCP#9=1
and the mcpgpio is always set to 1
in fact the relay is never trigger on
Re: nodemcu with 8input and 8output (pcf8574)
1.
You do not realy need to monitor the mcp gpio in your application.
2.
You can catch the action only once by :
you may also use mcpgpiotoggle,x instead of doing it manually
You do not realy need to monitor the mcp gpio in your application.
2.
This condition is met twice given you have a push button so it will return. (once when gpio,0 goes high when you press it and then again when it goes low when you release it)on gpio#0 do
You can catch the action only once by :
Now you only trigger the event when the input is low (or the opposite)on gpio#0=1 do
you may also use mcpgpiotoggle,x instead of doing it manually
-Don gpio#0=1 do
mcpgpiotoggle,9
endon
-D
Who is online
Users browsing this forum: Bing [Bot] and 98 guests