Hi Guys,
I am currently developing a project using esp32, but I encountered the problem of insufficient pins. I originally planned to use the PCF8575 module to add pins to control the relay, but I found that using PCF8575 cannot control the switch of the relay (but the control of the LED) The switch is OK), this seems to be a problem of insufficient voltage. Is there any way to solve this problem? Or can replacing PCF8575 with mcp23017 solve this problem?
Thanks
I moved your topic to an appropriate forum category @tn13.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Tell us what the relay voltage and current requirements are and I'm sure someone will come up with a simple solution
A PCF8575 can source a max 100uA and sink a max of 20mA per pin. That is, any significant load must be connected between Vcc and the PCF8575 pin.
Are you using raw relays or relay modules? Most relay coils consume more than 20mA. Anyway, post a link to these.
This is the relay module I use:
Trigger current: 5mA
Module operating voltage: 5V
And I have been using the DM7407N IC for testing these days.
It was found that it can be opened (but only when the IC is only connected to the positive pole (5V) and not the negative pole), but it can only be fully opened or fully closed.
But this is not the result I want
The DM7407N is an open collector device. That is it can only sink current, not source it. As you have found, the relay module trigger (actually the Opto-coupler led) has to be wired from the positive power rail to the DM7407N pin (just like the the PCF8575 would have to be).
If your relay module has a fixed common ground for the Opto-coupler led pins, you have a problem. However, there appears to be a set of 8 jumpers which could allow you to so configure it. Unfortunately, I can't find a schematic which matches your module.
I don't think the DM7407N brings anything here. It is described as
Hex Buffers with High Voltage Open-Collector Outputs sinking up to 30 volts. Further, the way you have drawn it together with what looks like a PCF8575 will not work because you need pullup resistors on the PCF8575 pins. Anyway, cascading a PCF8575 and a DM7407N is unnecessary in this case.
This type of relay will work with either a PCF8575 or a DM7407N because it it is made to
work by sinking the trigger pin. http://wiki.sunfounder.cc/index.php?title=2_Channel_5V_Relay_Module
It is not clear to me what options you have on that 8 way relay board with all those jumpers (no relay board schematic available). You may be lucky that it can be jumpered to trigger the relay when the trigger pin is pulled low.
This should be the circuit diagram of the relay module I use for your reference. Is this the picture you want to see?
That schematic of the relay module is not close enough because (a) it does not have opto-isolators and (b) it does not appear to have jumpers.
In the meantime I have seen at least a higher definition picture of your relay module but unfortunately no schematic. DEBO RELAIS 8CH: Entwicklerboards - Relais-Modul, 8 Channel, 5 V, SRD-05VDC-SL-C bei reichelt elektronik I think I see how the jumpers are to be set.
Here is something to try with 1 channel on the PCF8575 and 1 relay on that 8 way module. I'm assuming that the PCF8575 is correctly wired to the MCU. To me it appears that the I2C connections are missing.
Simply connect channel P01 on the PCF8575 to trigger IN1 on the relay module. Move the jumper marked S1 so it connects common to LOW. You should separate the red power wires so 3v3 should go from the MCU to the PCF8575 and 5v from the MCU to the relay module. Attempt to control channel P01 from your code on the MCU. The DM7407 is not used here.
Let me share how I successfully tested it:
First, let me explain that the relay module I use has two modes:
One is called high level and the other is called low level.
The two modes should work like this:
High level: open when 5v is input, closed when 0v is input
Low level: Close when inputting 5v, open when inputting 0v
As shown below:
I used to use Low-level mode (because it was in low-level mode when I bought it), and then switching to High-level mode solved the problem.
Then there are two ways in total:
The first way is to use a transistor(npn) to raise the voltage to about 5v, which can solve the problem, as shown below:
The second way is to use 7407. In fact, 7407 can solve the problem. You just need to adjust the relay module to high level mode. 7407 can be grounded or not, as shown below:
However, if you use the second method, in the program code, it will become LOW to open the relay, and HIGH to close the relay. I don't know why this is the case.
Here is the code:
#include "Arduino.h"
#include "PCF8575.h" // https://github.com/xreef/PCF8575_library
// Set i2c address
PCF8575 pcf8575(0x20);
void setup()
{
Serial.begin(9600);
// Set pinMode to OUTPUT
pcf8575.pinMode(P1, OUTPUT);
pcf8575.pinMode(P2, OUTPUT);
pcf8575.pinMode(P3, OUTPUT);
pcf8575.pinMode(P4, OUTPUT);
pcf8575.pinMode(P5, OUTPUT);
pcf8575.pinMode(P6, OUTPUT);
pcf8575.begin();
}
void loop()
{/*
static int pin = 0;
pcf8575.digitalWrite(P1, HIGH);
pcf8575.digitalWrite(P2, HIGH);
pcf8575.digitalWrite(P3, LOW);
pcf8575.digitalWrite(P4, LOW);
pcf8575.digitalWrite(P5, HIGH);
pcf8575.digitalWrite(P6, HIGH);*/
delay(1000);
pcf8575.digitalWrite(P1, LOW);
pcf8575.digitalWrite(P2, LOW);
pcf8575.digitalWrite(P3, HIGH);
pcf8575.digitalWrite(P4, HIGH);
pcf8575.digitalWrite(P5, LOW);
pcf8575.digitalWrite(P6, LOW);
delay(1000);
// pin++;
// if (pin > 7) pin = 0;
}
We had no success finding a schematic for that multi-channel relay module but, if you are able set the trigger to HIGH or LOW per channel, then I'm guessing that each channel has a circuit similar to the following. Special is that the opto-coupler is an AC type with two mutually inverted LEDs.
.
.
Can you read the markings on the opto-couplers ? These are the white, 4 pin ICs:
.
.
edit
In the meantime I found this single channel board schematic which could scale up to multiple channels at K6JCA: Schematic, Amazon Relay Module: 1 Channel, Optocoupler Isolation Hi/Low Trigger
.
.
.
.
Indeed it uses an AC type optocoupler (EL354)
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.