Notifications
Clear all

Using a 3.3V relay board with ESP 32

28 Posts
5 Users
18 Likes
4,991 Views
(@davee)
Member
Joined: 3 years ago
Posts: 1607
 

Hi @inq @zander,

re:

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???

The gate voltage required for an n-channel MOSFET to turn on depends on the design of the particular device.

Power devices typically require at least 5V-10V,  because they are optimised for factors like very low current when gate voltage is zero, good switching peformance and minimal on resistance. It is accepted they require 5-10V gate swings and in many cases specialised drivers are used to create that gate drive.

However, some devices are optimised for lower gate voltage operation, with compatibility to 3.3V logic being one of the obvious 'sweet spots' that are available.

The FET in this particular case is driving a relay coil ... and as I have mentioned in my other posts above, I am guessing it is switching about 120 mA.

I hope that calms a few concerns.

Best wishes all, Dave


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

@davee Well I learn something every day. I was under the assumption that the diagram you are showing was for AC relays and DC were just coil to pin. I obviously misunderstood and thought the entire purpose of the MOSFET alternative was to minimize the pin current to almost zero as opposed to the coil current. Now I need to start learning all over again.

So is there any appreciable current drain on the device in the diagram above? I know for a MOSFET it is very close to 0, just a voltage.

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: 6662
 

@davee And apparently there are such things as charge pumps to boost the 3.3 to 5 and another approach I can't now remember.

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: 1607
 

Hi Ron @zander 

 

  • re: I don't use relays anymore since I was educated about MOSFET's

I agree semiconductor solutions have much to offer and I too would normally look to MOSFETs for many switching problems.

In this case, I was trying to help someone who is hoping to use the relay board he hads bought ... I don't know what the ultimate use of the board is, but the first problem is getting it to respond on a bench .. which for some reason it wasn't, in part because 'handy' boards are being sold with minimal information and even less support.

In some cases, relays offer a very simple solution to a problem that is far more difficult to solve with semiconductors ... so I am happy for them to stay in the range of options to consider.

Good luck with your projects and take care, Dave


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

@davee After hearing of Ted's problems, I am glad I stayed away from relays, I did notice there were an awful lot of varieties out there.

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.


   
DaveE reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1607
 

Hi Ron @zander

Re your message starting ...

Well I learn something every day....

As both @inq and I have mentioned, we have no idea what @tedbear is hoping to switch with his relay contacts ... I obviously hope it is within the capability of the relay concerned, but that question has not been raised or considered. The original question referred to just trying to get the relays to operate on the bench.

A bare relay of the type on the board requires about 360mW (coil power) to operate, and although they now appear to be available with 3V coils, this amount of power is clearly above a typical microcontroller GPIO pin capability. Hence small boards with a MOSFET or biploar transistor to switch the relay coil current are being widely sold through the usual bazaars.

Regretably, the information and documentation for these boards is worse than back of an envelope standard ... and there are lots of small variations between apparently similar boards, so confusion is rife.

Whilst it might be expected that the base/gate input could be connected directly, to provide a little more flexibility it seems to be 'fashionable' to have an opto-isolator as well.

re: is there any appreciable current drain on the device in the diagram above? 

Current drive requirement for the opto-isolator input is typically a few mA .. and that is what an ESP GPIO pin would need to provide as a sink with circuit shown, but with other variants of board it becomes a source.

However, to keep the relay in the switched state, then clearly the relay coil current must be maintained  .. I am guessing around 120 mA for each 3V relay, based on the data I reported. This must be supplied as part of the 3.3V power supplied to the board. Hence, when the board has 8 relays, a current of about 1 Amp is required when they are all in the switched state. With simple, 'flimsy' wiring of the type often used for Arduino and similar lash ups, this is enough current to cause a voltage drop that could result in problems.

I hope that answers your query, but please ask more if I have missed the point.

Best wishes, Dave

 


   
Inq reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1607
 

Hi Ron @zander 

Re  And apparently there are such things as charge pumps to boost the 3.3 to 5 and another approach I can't now remember.

There is a 'world' of methods and products for driving FETs ... and wide range of FETs to suit different situations. I don't pretend to know a lot about them - as far as I can see it is rather specialised field and solutions can be found if you are willing to look.

With switching power controllers/supplies there are gate driver ICs that include charge pumps to generate the necesary gate voltages.

When connecting FETs directly to microcontrollers it is common to choose FETs with compatible gate voltage requirements .. logic compatible' ...  this inevitably means the FET performance is more restricted, which often results in a low voltage/power FET that drives one or more higher power FET devices.

I am sure there are many other tricks around as well!

Best wishes, Dave

 


   
ReplyQuote
(@tedbear)
Member
Joined: 5 years ago
Posts: 61
Topic starter  

Thanks so much for the informative replies.  I did not have time to try a different power supply.  As stated I was using a header type power supply for testing so no ESP32 was involved at that time. I will not have time for further testing for a couple of days.

The suggestion was made to abandon the idea of using relays and use a more eloquent approach.  My project is working with yet another door opener.  I need a total of 6 relays BUT only one is ever activated at a time and then only for a second or two.  This has to do with creating a brief pulse to start the OPEN, CLOSE or STOP sequence of the opener(s).  A set of relays seemed a simple approach since they had been successful for many years in another somewhat similar situation.  The reason for purchasing the 3.3V board was to simplify the connection between the eventual ESP32 and 6 of the 8 relays.  For another fairly similar situation I purchased an ESP32 with external antenna and 4 built in relays all on one board.  That works fine.  What I really wanted was an ESP32 with external antenna and 6 or more built in relays on one board but I could not find one so I hit upon the idea of using an ESP32 with external antenna and a separate 3.3V relay board with at least 6 relays.  I had used an ESP32 with external antenna, a Darlington array and a separate 5V relay board but my connection were unreliable.  It worked much of the time. 


   
Inq reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1607
 

Hi @tedbear,

  When you have time, please report how you get on repeating your simple relay test, but with a more robust power supply. And also confirm which board you have with (say) a clear photo of the board or a link.

If everything had been 'playing nicely', I can't see why your test should not have worked as you expect. So I can only assume something was 'playing up', and the power supply is the obvious first suspect, but as in all the best 'whodunits', the first suspect is not always the culprit!

Obviously, solid state electronics can often substitute for a relay, and may offer advantages. However, it can also introduce new problems and challenges. For example, a relay naturally provides electrical isolation. If your ESP32 system and the 'door opener' are separate electronic boxes with independent power arrangements, that isolation automatically reduces the chance of 'unexpected' problems, such as earth loops. Whilst I cannot vouch for the quality of products bought from 'unknown' sources, in general, relays are a simple, well-known technology, which can give reliable service for many years - premature failures are often attributable to 'misuse', such as the contacts being inadequate for the type of load. So whilst I would encourage you to explore new technologies, I would also suggest that if you have a 'proven' strategy using relays and just want to produce 'yet another door opening system that works', then don't feel you are obliged to change course at this point.

Your reasons for trying the 3 Volt relay board seem sound. My comments about driving all 8 relays might not apply this time, but as I didn't know the application, I thought it useful to bear in mind for projects in general.

----------

You say "but my connection were unreliable", without being clear about which connection you are discussing. My first guess is the WiFi link, but you may have meant something else. If you could you please clarify, you may get a useful suggestion to improve the situation.

The ESP32 boards provide a lot of computing for a low price, but the price constraint seems to mean their power supply arrangements are 'on the edge', possibly because of the WiFi power demand transients. If I was trying to make a 'reliable box product', then I would consider providing a separate 3.3V regulator with a higher current rating, with short, adequate connections to the board. I haven't tried it, but if your supply voltage is 5V, something like:

https://www.mouser.co.uk/ProductDetail/Microchip-Technology/MCP1827S-3302E-AB?qs=Fxu3fLyJv8cg9pQdVCKssg%3D%3D

might be a good place to start. The regulator, together with the associated capacitors can simply be soldered to a small 'perf' board or similar. If the incoming voltage is 5V, then I don't expect it to get hot in your case, but please check, and if it does get hot, bolt on a small piece of metal (or a proprietary clip) to act as a heat sink. Remember the tab is usually connected to one of the pins, so don't short it to an earthed metal box!

It might not make any difference, but dating back to my early experience with a Z80, a generously specified power supply is a good start to producing a reliable computer.

Good luck with your project.

Best wishes, Dave


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

The reason for purchasing the 3.3V board was to simplify the connection between the eventual ESP32 and 6 of the 8 relays.

Sound logic to me.  Like your version with the integrated ESP32/relays, the WeMos relay shields take care of all those little hardware details that I would not know how to do.  Once you get your final solution working with the separate components, please detail them here.  I might need to do more than one relay at some time and as @davee pointed out, it's a real crap shoot out there and reading between the hardware lines is not in my bag of tricks.

Posted by: @tedbear

What I really wanted was an ESP32 with external antenna

I've read some Internet articles where they were getting "miles" of range.  What kind of real-world range are you getting with the external antenna?  I have some ESP-07 with a separate little 2-3" antenna, but haven't checked their range.  Most of my projects are just fine with the built-in, but I have some projects in mind that need to go out several hundred yards and aren't cutting it with the built-in.

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
(@tedbear)
Member
Joined: 5 years ago
Posts: 61
Topic starter  

Had some time today.  I connected the 3.3V relay board to my Power Supply Breadboard box from Tech School.  This was our first project and we used it for many of our later projects. It has two variable power supplies that can handle a reasonable amount of current and also a well regulated 5V output among Pots etc.  I set the DC output for 3.3V and connected to the relay board.  I put a jumper on one of the Input pins and when I touched ground, the relay cycled and its LED lit.  No buzzing with this arrangement.   I purposely reduced the power to 2.5 V and things still worked as expected. 

I then attached the board to my power supply of the other day.  Again I got the loud buzzing sound.  I concluded that for some reason that power supply is not adequate although doing a voltage check even with the relay buzzing still shows 3.1 V.  Maybe it isn't regulated well enough. 

I then got brave and tried the actual ESP32 board that I will eventually be using with the relay.  I connected the ESP32 via USB to my computer.  I connected the 3.3V out pin and ground to the relay board.  Shorting any on the Input pins causes its relay to cylce and LED to light.  I am now reasonably confident that it will work under program control when I connect the IN pins to the appropriate GPIO pins on the ESP32.

Its starting to look like if I had just gone ahead and wired it like I thought without doing the testing with the weak power supply things might have been just fine.  Maybe I should have jumped into the deep end of the pool right away rather than testing the water on the shallow end. Thanks for the comments, I learn from them even if they don't help the immediate problem. 


   
Inst-Tech reacted
ReplyQuote
(@tedbear)
Member
Joined: 5 years ago
Posts: 61
Topic starter  

Thanks for the replies.  I was able to test the project yesterday and I'm fairly confident of its success although obviously it hasn't "stood the test of time" at this point.  I'm using an ESP32 Dev board powered by a 110VAC to 5VDC power adapter.  I connected a 3.3V output and ground from the ESP32 board to the 3.3V relay board.  Since this board is active low, I had to reverse the output logic in my sketch from before. I use 6 of the GPIO pins on the ESP32 board to 6 of the 8 input pins on the relay board.  I used Inputs 1-3 and their associated relays to control my West Shop Door Opener which ties into its OPEN, CLOSE, STOP control box.  I used Inputs 6-8 in the same way to control my South Shop Door Opener.  Inputs 4-5 are not used.  This seems to work well.

Someone asked about range.  The board I used was set up to use an external antenna.  I can count on reception at 300' or more.  This is very acceptable for my purposes.  Greater range might be undesirable for this project since from a safety standpoint I should be in visual range of the doors before operating them.

Someone mentioned a potential safety issue. Although certainly possible, I'm not too concerned about it happening with my intended mode of interaction.

Here's the potential problem, suppose I use my phone to start the "CLOSE" sequence and while the door is closing I notice a problem.  I could push the STOP button on my phone app which should stop the downward travel.  However, if the phone lost communication between starting the "CLOSE" sequence and the need to STOP, the phone app would not STOP the door from continuing to close.  The STOP button on the original 3 button box by the door would still STOP the action but I might not be able to reach it in time to prevent a problem.  The openers themselves have a built in feature that prevents one from going from OPEN to CLOSE accidently without going to STOP first but that would not prevent the above.  Obstacle sensors (not installed) would help.

Here's a few pictures.  The first is the ESP32 with relay board.  This is installed in a weatherproof enclosure on the outside of the building.  Power/ground and 8 other wires lead through the wall to inside of the building for the 5V power and connections to the original door opener boxes.

The second picture is the opening screen of the RemoteXY app on my phone. Notice I have 3 different setups.  One is for my Shop, another for my Old Shed and a Third for testing my farm sprayer.

The third picture is the operational screen for working for the two doors described above.

IMG 1326[1]
IMG 1328[1]
IMG 1327[1]

   
DaveE and Inst-Tech reacted
ReplyQuote
(@tedbear)
Member
Joined: 5 years ago
Posts: 61
Topic starter  

The above has been in service no for several days and seems to work fine.  The range between my phone and the ESP32 varies.  As expected a "line of sight" attempt at a reasonable range seems to be very reliable.  Attempting to use the phone when I'm not on a "line of sight" is less reliable which is fine and maybe even desirable for this application.  I am calling the project a success after a few (now obvious) mistakes. I might be a bit prejudiced.  Thanks for the informative replies along the way.


   
Inq reacted
ReplyQuote
Page 2 / 2