Notifications
Clear all

Using a 3.3V relay board with ESP 32

28 Posts
5 Users
18 Likes
5,531 Views
(@tedbear)
Member
Joined: 5 years ago
Posts: 62
Topic starter  

I have a fair amount of experience with relay boards with Arduinos.  I am now using an ESP 32 for a project and purchased a 3.3V relay board with 8 relays.  My thinking was that I could use the GPIO outputs from the ESP32 directly to this board.  The loose board has  8 - 3.3V relays on it with an opto isolator beside each one.  There are pins for Gnd, In1, In2, In3, In4, In5, In6, In7, In8 and Vcc.  The relays are SPDT and marked 3.3V.   I tried testing the relays with a power supply to check out their operation.  I connected Vcc to 3.3V, Gnd to Ground, and a jumper to IN1,  I touched the other end of the jumper to the 3.3 source to simulate a HIGH output Trigger for the coil.  I expected the relay to "click" and then the COM terminal would be connected to the N.O. terminal.  Instead the board made a buzzing sound.  The LED for the relay did come ON but the buzzing sound didn't seem right,  I checked to output for continuity between the COM and N.O. while the relay was buzzing.  There was no continuity between COM and N.O.  I repeated the test with a different IN pin with the same results.

I'm also confused about the jumper between Vcc and JVcc on the board. I tried various combinations with the JVcc but no success. Shouldn't this entire board be able to "live" on 3.3V?


   
Quote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Any relays I've used only have the logic side of ground and signal.  They don't need voltage.  

Could it be that it still needs a 5V input on that Vcc... that although 3.3V can trigger it, it needs 5V on that rail to actually energize the coil????

A link to your board will be helpful.  I looked the other day and could find no boards using 3.3V triggering, except the single relay shields for WeMos ESP8266 boards.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech and Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6965
 

Are there NC contacts, and when there was no continuity between COM and NO was there between COM and NC? That would indicate that the relay had not 'picked'. I assume you have googled the board name etc.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Dug into the ones I have a little.  I was wrong!

https://www.circuitbasics.com/wp-content/uploads/2015/11/SRD-05VDC-SL-C-Datasheet.pdf

The "SRD-05VDC" indicates the coil voltage to energize.

The WeMos shield relays need this 5VDC to energize, but have a built-in DC to DC converter on the shield.  So they handle the 3.3V logic, but energize with 5V.  They work even when powered by an external 3.3V power supply.  All that is hidden.  I just wrongly assumed I only needed Gnd/3.3V trigger.

I recently got these with Moisture gauges and they also need SRD-05VDC to energize and don't have to have DC to DC.  I just tried them and these require 5V on logic pin and 5V on the VCC pin to activate for use with Arduino UNO, etc.

image

I looked on line and some of the relays like this one have SRD-12VDC on them to activate with 12VDC.  But they still use 5V logic.  So I think there are tons of different versions.  

But it seems whatever is on the Blue relay box SRD-X is the voltage it needs on the VCC pin no matter what logic pin voltage is needed.

But double check, I'd hate to be wrong again and you burn something up.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech reacted
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 
Posted by: @inq

Dug into the ones I have a little.  I was wrong!

https://www.circuitbasics.com/wp-content/uploads/2015/11/SRD-05VDC-SL-C-Datasheet.pdf

The "SRD-05VDC" indicates the coil voltage to energize.

The WeMos shield relays need this 5VDC to energize, but have a built-in DC to DC converter on the shield.  So they handle the 3.3V logic, but energize with 5V.  They work even when powered by an external 3.3V power supply.  All that is hidden.  I just wrongly assumed I only needed Gnd/3.3V trigger.

I recently got these with Moisture gauges and they also need SRD-05VDC to energize and don't have to have DC to DC.  I just tried them and these require 5V on logic pin and 5V on the VCC pin to activate for use with Arduino UNO, etc.

image

I looked on line and some of the relays like this one have SRD-12VDC on them to activate with 12VDC.  But they still use 5V logic.  So I think there are tons of different versions.  

But it seems whatever is on the Blue relay box SRD-X is the voltage it needs on the VCC pin no matter what logic pin voltage is needed.

But double check, I'd hate to be wrong again and you burn something up.

VBR,

Inq

@Ing, Found this link ; https://diagramweb.net/srd-05vdc-sl-c-wiring-diagram.html showing the connection diagram for the SRD-05VCC relay..You are correct, 5V is needed to the VCC , and the IN1 is also triggered by a  digital pin on the Arduino uno  pulled low..

Here's a schematic of one I found with dual relays opto-coupled..

image

 

 

mystry solved..

regards,

LouisR

 

LouisR


   
Inq reacted
ReplyQuote
(@tedbear)
Member
Joined: 5 years ago
Posts: 62
Topic starter  

I'll try to get an actual picture.  My relays were advertised as 3.3V.  Where other relays have had 12V or 5V written on the relay these have 3.3.  While mowing the lawn I thought about my test arrangement.  I was using one of those power headers on a breadboard that can output 5V or 3.3V to the power rails.  My meter showed only 3.1 which I thought should be good enough.  I have a better power supply from my Tech school days where I can dial in the 3.3V.  Actually on my prior test, I powered the Vcc with 5V and the relay behaved the same and just buzzed.  The buzzing only occurs when the Trigger is at logic HIGH. 

I believe this sounds like the COM is not making contact with either the N.O. or N.C. when the buzzing sound is present.  With no power COM connects to N.C. as expected.

I'm still unsure of the purpose of the GND, Vcc, JVcc pins.  A jumper is installed between Vcc and JVcc.  I read that this then supplies the board (opto couplers etc.).  I tried different combinations with it also.  Thanks for the help.  I thought this would be an easy way to use several relays with an ESP32.  Guess not. 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6965
 

@tedbear Either a picture or a link or just write it but finding the datasheet and website should solve any mystery re the pins. Don't make the mistake I made yesterday when I destroyed 2 of my 4 Arduino Pro-Micros with the wrong voltage (2 are 5V, 2 were 3.3V)

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1680
 

Hi @tedbear et al,

  I found this product on the web ... at first glance, it matches your ( @tedbear's)  description

https://www.elecbee.com/en-28869-8-Channel-3-3V-Relay-Module-Optocoupler-Driver-Relay-Control-Board-Low-Level-for-Arduino-products-that-work-with-official-Arduino-boards

Obviously, I have only that web page .. and a little imagination to go on ... so these comments could be mistakes .. no responsibilty accepted for any mistakes on my part .. especially the 'options' below!

(I haven't tried to follow the PCB tracking ... just using the component shapes and general 'flow' of the layout.)

  1. Relays have a type number suggesting (as tedbear said), that they are 3V.
  2. Parts look like common layout for each relay having an opto coupler for input, a FET to drive the relay coil, and diode across the relay coil to absorb the back emf. In addition, gate resistor for Fet and Resistor + LED to indicate status
  3. No sign of power supply to generate 5V or any other voltages.

Unfortunately, the website is 'brief' on details .... but it does say:

8 relay output module, relay output contact 250A 10A.
Input IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8 signal line low level effective.VCC, GND power input,
relay can be supplied separately to relay power input terminal JD-VCC.

Which matches up with @inst_tech's schematic above, assuming JD = Relay

i.e. options appear to be:

  1. Use jumper to Link Vcc to JDVcc ..  and supply 3.3V to Vcc pin (which is next to the In8 pin) in the centre of the card. This means this one pin Vcc supplies both the LED in each opto isolator and the relay coil.
  2. Discard the jumper. Need both 3.3V supply to the Vcc pin (which is next to In8 pin) AND 3.3V supply to JVcc pin to power the relay coils.

If you adopt either of these schemes, please check it matches your board as much as you can before switching on!

------

One thing you need to watch ... you potentially have 8 relay coils in parallel across the 3.3V supply .. I haven't found a coil resistance for the 3V relay, but a table for this general type of relay is shown at https://www.aliexpress.com/item/1005003025355512.html

Looking at the table, these relays take about 360mW ... which at 3V would be 120mA

Thus, when all 8 relays are energised, you would need about 1 Amp.

That means be careful with your power supply and wiring ... 1 Amp can easily cause voltage drops on the 3.3V and 0V wiring that could 'upset' other parts of your circuit ... of course, this depends on the detail of your wiring, etc. and I have no idea what that looks like.

--------

Good luck and best wishes,  Dave

 


   
Inst-Tech reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @davee

Looking at the table, these relays take about 360mW ... which at 3V would be 120mA

Thus, when all 8 relays are energised, you would need about 1 Amp.

That means be careful with your power supply and wiring ... 1 Amp can easily cause voltage drops on the 3.3V and 0V wiring that could 'upset' other parts of your circuit ... of course, this depends on the detail of your wiring, etc. and I have no idea what that looks like.

@davee - Software guy asking Noob hardware question...

IF @tedbear (I imagine he didn't, but I might have if I was using this thing) was just using the 3.3V output pin out of ESP32 while running it off just the USB connection... and because it can't supply that much current, wouldn't...

  1. the voltage drop
  2. causing the relay to open
  3. causing the voltage to rise,
  4. causing the relay to close
  5. ad nauseum??? - aka - "buzzing"

OR... would it simply blow-out the USB 5V to 3.3V converter???

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6965
 

@davee Well that's going to be a BIG problem since an ESP32 is limited to 40ma per pin MAX.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6965
 

@davee The first link you posted shows 5ma to trigger, that is well within specs, but 120 is 300% of max.

I don't use relays anymore since I was educated about MOSFET's. I am putting together one today to turn on lights based on the RCWL0516 input. It's a complete module that will handle up to 10A at 100V. I could also build the little module using another MOSFET that handles 62A at 30V. Lot's of choices.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @zander

@davee The first link you posted shows 5ma to trigger, that is well within specs, but 120 is 300% of max.

I don't use relays anymore since I was educated about MOSFET's. I am putting together one today to turn on lights based on the RCWL0516 input. It's a complete module that will handle up to 10A at 100V. I could also build the little module using another MOSFET that handles 62A at 30V. Lot's of choices.

Hey @zander,

What Mosfet(s), gets fully energized with a 3.3 volt pin supplying the trigger?  Are there any handling serious voltages and/or currents... say 100 amps???

But... we don't know what @teadbear or anyone else is using the relays for.  A Mosfet isn't much good for 120/240 AC.

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6965
 

@inq If they need more than 3.3v then there are ways to get 5V. Sometimes at 3.3 it delivers enough current. I have several in operation. The most current I have in inventory is 62A but I am sure there are plenty bigger. True about the AC though, I use different devices for that.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1680
 

Hi @inq,

Re:

IF @tedbear (I imagine he didn't, but I might have if I was using this thing) was just using the 3.3V output pin out of ESP32 while running it off just the USB connection... and because it can't supply that much current, wouldn't...

  1. the voltage drop
  2. causing the relay to open
  3. causing the voltage to rise,
  4. causing the relay to close
  5. ad nauseum??? - aka - "buzzing"

OR... would it simply blow-out the USB 5V to 3.3V converter???

Your sequence 1-5 is quite plausible in the right circumstances ... and it was my first thought as well, although I my initial 'understanding' was that he was only activating one relay in that test, and he said he was using a power supply and a simple jumper

The small converters used are supposed to to include protection against over current and over heating .. I haven't any direct experience of how they perform, albeit others on the forum have reported frying one or two. Over the years I have replaced a few 7805s or similar 'old -timers' which also claimed protection .. I 'suggest' (on very weak evidence) that the protection often protects against an occasional overload, but repeated overloads are likely to hasten its demise. As this was a one-off test, then I think it is more likely to shutdown.

The shutdown mechanism could also cause a 'shutdown -- power up' looping oscillatory effect, but I speculate the loop time to be more like seconds than the milliseconds of a buzz.

Frankly, I am not clear what was going on, but in the absence of being able to see it first hand, we are all in the dark. (This is the kind of case a 'scope' can save a lot of chasing shadows! 😀 )  But, I don't even know if the advertised product I found is the same as @tedbear's, let alone chasing the problem on the bench!

Best wishes, Dave


   
Inst-Tech reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1680
 

Hi Ron @zander.

re:

@davee Well that's going to be a BIG problem since an ESP32 is limited to 40ma per pin MAX.

Sorry, perhaps I didn't explain clearly enough ... my sermons are too long already!

[ Note, for this discussion. I am assuming @tedbear's board is similar to the one I found on the web and reported previously! ]

The relay coil is not driven directly by the ESP ... as @InstTech showed in his schematic clip about 10 messages ago. .. The ESP only drives an opto-coupler which only needs a few mA.

 

EXPLANATION

@InstTech's diagram copied here for convenience:

image

Although I suspect @tedbear's board has some minor differences to this circuit, the principle is the same. 

  • @tedbear's board has a relay status LED, but it is different from this diagram. Assume the LED IN1 (& LED IN2) are shorted out, so the connection point, also labelled IN1 (!) connects directly to the cathode of the LED inside the opto coupler.
  • Hence the ESP output drives the LED part of the opto coupler ... to be more precise, the diagram shows the anode of the LED connected to Vcc (assumed to be 3.3V in this case) and the cathode is pulled to 0V by the ESP output (when instructed by ts program) to cause the opto-LED to (internally) illuminate.
  • That opto-LED light then falls on the phototransistor within the opto coupler, allowing it to conduct a current.
  • The phototransistor is connected across from Vcc to base of a small power transistor (or more likely Vcc to gate of a FET) , causing it to conduct. The collector (or drain) is connected to the relay coil.

So my estimate of 120mA per relay coil only passes through the small power transistor on the relay board. 

The ESP only has to sink enough current to activate the opto-coupler's LED ... this current will be determined by a combination of Vcc (3.3V), R1 (probably less than indicated 1k for the 3.3V version) and the LED forward voltage drop ... I would expect it to be a few mA, which should be fine for most microcontroller GPIO pins ... and roughly an order of magnitude less than 40mA!

I have tried to be brief but hope you can decipher it!

Best wishes, Dave

 

 


   
Inst-Tech reacted
ReplyQuote
Page 1 / 2