I leave an image of the relay module

Moderators: grovkillen, Stuntteam, TD-er
Code: Select all
on Keypad#ScanCode do
LogEntry,"Key ScanCode: %eventvalue1%"
Let,1,-1 // No key pressed
if %eventvalue1%=10
Let,1,0 // PCA Port nr
elseif %eventvalue1%=11
Let,1,1 // PCA Port nr
// add more elseif clauses when needed
endif
// Valid key?
if [var#1]>-1
PcfGpioToggle,[var#1] // Flip output state
endif
endon
Yes, I2C devices are connected with parallel wiring to SDA and SCL.
As already stated above, you need to upgrade your MCU with one of the TEST_A..E builds of ESPEasy, as that has the plugin for MCP23017 (keypad) included.
Code: Select all
on System#Boot do // At startup of the ESP, activated once
MonitorRange,mcp,0,15 // 16 pins
endon
// When using momentary push-buttons use "on mcp#0=0 do", "on mcp#1=0 do" etc., to respond to push-down only, not again on release
// When using on/off flip switches, use "on mcp#0 do", "on mcp#1 do" etc., to respond to each flip, on and off
on mcp#0=0 do
PcfGpioToggle,0 // Mapping is 1:1, mcp pin 0 to pcf pin 0, toggle output-pin state
endon
on mcp#1=0 do
PcfGpioToggle,1
endon
// copy/paste/adapt for all mcp input- and pcf output-pins
Code: Select all
on mcp#2=0 do
PcfGpioToggle,2
endon
on mcp#3=0 do
PcfGpioToggle,3
endon
Code: Select all
on mcp#0=0 do
LogEntry,"MCP PA0 toggle PCF pin 0"
PcfGpioToggle,0
endon
That looks as it should, but still, the relay isn't working. Have you tried to toggle pin 2 instead of 3? (as you are using pcapwm,2,4095 below)
I don't understand why you use a pcapwm command to "switch on" a pin, that should normally be a pcfgpio or pcfgpiotoggle, I think, for switching on/off a pin.esptita wrote: ↑30 Mar 2022, 06:13 However, when I enter the command in the google browser in the address bar, the following is taken; http://192.168.0.104/control?cmd=pcapwm,2,4095 the relay works perfectly.
then something is wrong that prevents the pca from communicating with the mcp.
The problem is in the connection to the relays, not in connecting the boards to the ESP.esptita wrote: ↑30 Mar 2022, 06:13 the physical electrical connections are as follows on the pca9685-mcp23017 board and the mcu8266; the SCL and the SDA are in parallel in the mcp and the pca.
after the mcu8266 SDA: GPIO-4 (D2)
SCL: GPIO-5 (D1) to pca9685 board.
pca and mcp are powered by the mcu8266 with the 3.3v and GND in common on the 3 boards and also with the 4ch relay module.
The PCA* and PCF* commands are somewhat intertwined, they both control the PCF board.
Since the "Switch input - MCP23016" does not support the button type "push button active high" / "push button active low" maybe you could add this information to// When using momentary push-buttons use "on mcp#0=0 do", "on mcp#1=0 do" etc., to respond to push-down only, not again on release
// When using on/off flip switches, use "on mcp#0 do", "on mcp#1 do" etc., to respond to each flip, on and off
Users browsing this forum: No registered users and 12 guests