Help with esp32 + 4CH relay 12v + PC Fan 12V

Hello!

I am having a hard time understanding what is happening here, I don’t know much about electronics, been learning by myself and playing with the wiring/coding as many others here :smiley_cat:

Here is what I have :

  • Esp32 + USB 5V power supply
  • Relay 4 Channel 12V
  • 12V PC Fan’s
  • 12V power Supply

The examples I have sawed in many websites are with a 5V and no external power needed, In my case using computer fans I think I will need the extra 12V power supply because the ESP32 can’t power the 12V fans (correct me if I’m wrong pls)

I have been trying to wire this with 2 different power supply (I have 2 to test with) and also different wiring positions and I think I have burned some fans trying because they smell like fried and if I connect them directly to the power adaptor won’t work now, so now I have tested the ones I have, and I have others that still work :sweat_smile:

The first power adaptor in the labbel puts :
AC ADAPTOR
Model no : AA-121A2
Input: 120VAC 60hz 20W
Output: 12VAC 1.2A
class: 2
note: In this one I can find easy the positive(red) and gnd(black) using a tester

The second power adaptor:
Switching Adapter
model: DSA-12CA-12
Input: 100-240V~ 50/60hz 0.3A
Output: +12V 1A
note: both cables show positive when testing :sweat_smile: , I think it is related with the AC DC type (?)

I think the first one will work better and have more power , one doubt I have is that the power adaptor says AC and the computer Fan say DC , will this be a problem ?




This is the diagram that I think should work since that’s how the examples I saw on most websites






But also I found this one ( But didnt work :roll_eyes:)





I feel it is something related with power because I don’t hear the click on the relay when I click on home assistant switches to enable relay channels , I see the light/led under the relay board turning on and logs under ESPHOME are fine too(sending ON and OFF states), so the code and the integration is working fine.

I can’t get the fans to turn on or control them

Give me some ligth here pls :pray:

I believe the relays in the first pic require 12v to switch the relay, you are supplying only 3.3v with the esp32.

EDIT not so sure that is so now.

Thanks! I had that question but didn’t know if that will burn the board , we’ll now with you answer I have 2 questions

  1. there are 3 VCC pins on the relay board ( 2 pins under the jumper VCC and JD-VCC, the last VCC is on the relay header) on which pin do I have to add the power 12v cable from the power adapter?

  2. Should I move the gnd from the relay to esp32 - to the Gnd from the power adapter or I can leave it as it is?

You have two relay boards in your pictures, so what exactly is the board you have? And what is written on the relays?

I have the first one , the one with 4 channels and jumper :point_down:

The code :

esphome:
  name: test

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

# server            
web_server:
  port: 80


ota:
  password: !secret

wifi:
  ssid: !secret
  password: !secret
  
 # Optional manual IP
  manual_ip:
    static_ip: !secret
    gateway: !secret
    dns1: !secret
    subnet: !secret

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: !secret
    password: !secret

captive_portal:


switch:
  - platform: gpio
    pin: GPIO23
    inverted: true
    name: "switch 1"
    id: switch1
  - platform: gpio
    pin: GPIO21
    inverted: true
    name: "switch 2"
    id: switch2
  - platform: gpio
    pin: GPIO18
    inverted: true
    name: "switch 3"
    id: switch3
  - platform: gpio
    pin: GPIO26
    inverted: true
    name: "switch 4"
    id: switch4

I really got a bit lost researching these relays! But I think I am right in saying that they should be powered by 12v, and the IN should be triggered off 5v (and should work with the esp32).

I would play around with some bits of wire and try triggering them rather than risking the esp32 GPIOs.

Yep I’m lost looking at the examples that I have find , I want to know now in which pin I set the 12v , thanks for the help though <3

Is there a voltage convertor attached to VCC?

No , only the ones in the picture

On a similar one I have, the JD-Vcc pin is connected to one of the coil pins of all the relays.

So you need to connect 12V to that pin. You will need a common ground for your relay power and the 5V running the ESP.

If the information posted is correct, then the first adapter listed (used) is AC, not DC. Could explain the burned smell of the fans.

I don’t see how polarity of the leads could be identified with a tester. If a voltmeter was used, I would expect the meter to behave like the note listed with the second adapter, not this one.

Thanks for the reply guys <3

@gaz99
So you are saying The +12v line from the power adaptor goes to the JD-VCC pin on the replay board lile the next image , the next one I leave it empy and the one VCC from the relay header to the esp32 ?

@rcblackwell
About that yeah like I said ( dont know much about electronics ) I have used this tool (image) to test on both cables from the 2 power adaptors , on the first one the tool show me the +12V line and the other cable dont show any value just a litle ray (so for me that was the gnd/negative) but with the secound power adaptor both cables show +12V that what I mean on the first post

My advice, ditch that silly little gizmo and purchase a proper multi-meter.

1 Like

Could it be something about the code ? I been testing and still not able to work this out :frowning:

The only thing I notice is that if I change the red cable from fan on Normally Close(NC) to Normally Open (NO) the fan will turn on at power on but I wont be able to turn it off it will just spin , from home assistant I turn on/off and see the logs and led (from relay) turning on/off but nothign on fan

Any ideas ? thanks

Update:

I am now trying with a 1 channel 5V relay and I having the same result so im doing something wrong here…

this is how im connecting the new 5V relay :
Red led (power) turns on , and also the red led turns on when switching on from home assistant , but no fan spinning or relay click sounds, have tested the fan and it is working

Are you sure that it is 5v could it possibly be 12v? 5v will light the led but not switch the relay. Do you have a multi meter? What is the voltage coming from the signal pin of the esp? An under sized power supply probably would have similar results.

Hey! thanks for the reply! , I made it work! finally ( the new 5V ) not the 12V , on this 5V it was the wiring ( I mess the fan cable position) , Yes I have a multimeter (also trying to use it more since I dont have the basic electronic theory I have to play with the little knowlage I have , thanks ) I will try to mirror the same wiring on the 12V relay but I suspect it wont work because the ESP32 not able to send a PWR signal (12V) from the esp32 to the relay I think I will need a convertor o something else here to make that work