12V relay with esphome for 12V fan

can I use HL-52S relay to control 12V fans with esphome?

Yes, certainly.

how to wire it up, VCC is 3.3V GND is GND In1 — GPIOXX. how to connect on the the 12V side?

The terminals on the left side of the photo is where the switched contacts are. Those can handle the 12v switching of the fan. Between the ESP and the relay you will be using the 3.3V

Looks like the module has 5V relays so probably won’t work with 3.3V.

You will have to provide the 5V for VCC from somewhere and the 3.3V GPIO signals from the ESP should be fine for switching the relays as there is a transistor buffer for each relay.

Most ESP dev boards use a 5V input from a USB socket so there is a 5V rail available. Depends what ESP device the OP is planning on using.

I mostly use 5V from VCC, this fan will be controlled by esp32 expansion board, which does provide separate 5V output.

Buy a relay module with a 3.3V coil. It will still be able to switch considerably more than 12V and you can wire it direct to GPIOs.

any particular relay to search for?
search came up with this

and

https://ewall.com.pk/product_view/3.3V-2-Channel-Relay-Module-for-Low-voltage-Trigger/2052

That second one should do nicely.

working.

Just used middle and lateral output pin in 12V line. using tasmota for for prototyping on test esp32 node. Using esphome on production node.

so the code for esphome will be ?

# Example configuration entry
switch:
  - platform: gpio
    pin:
      number: 27
      inverted: true

============

Final code used, only switching brine shrimp light now. will add fan afterwards.

yaml
# dual 12V relay
switch:
  - platform: gpio
    id: brinelight
    name: "Brine light"
    pin:
      number: 17
      inverted: true       


Shipping :man_facepalming:

Note that 3.3V relays draw quite large current, so if you use onboard 3.3V regulator it maybe won’t be enough for esp and relays (on link above it stated more than 100mA…).
No need for buying 3.3V relays if you have 5v available. Remember: lower relay voltage, bigger relay current (and vice versa).