Rofo
(Ro)
October 10, 2025, 12:23pm
1
As a backup for my heating system, I want a way to switch a sonoff mini-d as if it were hard wired to a physical switch.
The ‘switch’ in this case, would be some available pin headers on the WT32 SC01 PLUS.
With no idea how to do this, I asked chatgpt, which suggested a needed a relay in between.
Coincidentally, I have some spare of these which I think might work:-
https://www.aliexpress.com/item/32888878613.html
However, at this point I’m lost as to how to wire this whole thing together, and what ESPhome code I need. Chatgpt is also talking about needing resistors.
I know this is a big ask, but has anyone else tried something like this ?
Karosm
(Karosm)
October 11, 2025, 10:27am
2
Should be doable.
What exact relay module you have?
How are you powering Sonoff, mains or DC?
Rofo
(Ro)
October 11, 2025, 10:54am
3
This is the relay:-
https://www.aliexpress.com/item/32888878613.html
The mini-d is already powered separately via the mains as its in use to toggle my boiler.
Karosm
(Karosm)
October 11, 2025, 11:50am
4
Your link gives 10 options…
Rofo
(Ro)
October 13, 2025, 11:18am
5
They are all the same device, just with one or more relays in line.
I just need a single relay version:-
Karosm
(Karosm)
October 13, 2025, 12:05pm
6
They are not, not even close.
The relay above is not compatible with Esp32 (3.3V trigger) and it doesn’t have optocoupler.
This instead has optocouplers and it can be wired for 3.3V trigger (removing the jumper). Just for my experience, description says: 5 V-12V to TTL control signal
Rofo
(Ro)
October 13, 2025, 5:52pm
7
@Karosm - that tells you how little I know!
Please recommend a relay and then how I might wire it up.
Karosm
(Karosm)
October 13, 2025, 5:54pm
8
Almost whatever 5V relay module that has “JD-VCC” or “HIGH-LOW” jumper would likely work. Post here what you find available.
That connection to Sonoff could be done even without relay, but it’s not beginner task and I have no sonoff to guide you here…
Rofo
(Ro)
October 14, 2025, 8:03pm
9
I’m looking at getting one of these, I assume the 5V version?:-
DC 5V 1 CH Optocoupler Relay Module High Low Level Triger Relay Action Indicator. 2, Using SMD optocoupler isolation, driving ability, stable performance ; trigger current 5mA;. Optocoupler Relay Module x 1.
Karosm
(Karosm)
October 14, 2025, 8:07pm
10
Yep, the 5v version should be ok.
Rofo
(Ro)
October 14, 2025, 8:09pm
11
Perfect… so how would I wire up a spare GPIO on the WT32 to this, and then onto the sonoff mini-d ?
Looking at the data sheet for the WT32, these are the available GPIO Pins I could use:-
Karosm
(Karosm)
October 14, 2025, 8:32pm
12
There are many ways. Preferred would be this, but you need to take 3.3V from the debug header.
If you prefer not, wire GND to the middle pin instead of 3.3V.
Use any available Gpio for trigger.
1 Like
Rofo
(Ro)
October 14, 2025, 9:20pm
13
Thanks for your help thus far.
I’ve read the esphome page on exposing a gpio pin as a switch, but I’m not familiar with some of the terms.
Chatgpt has suggested this epshome code:-
switch:
- platform: gpio
name: "Sonoff Mini-D Trigger"
id: sonoff_trigger
pin:
number: GPIO25 # Adjust this pin as wired
mode: OUTPUT_OPEN_DRAIN # safer with Sonoff pull-up
inverted: false
restore_mode: ALWAYS_OFF
on_turn_on:
- delay: 500ms # press duration
- switch.turn_off: sonoff_trigger
Karosm
(Karosm)
October 14, 2025, 9:41pm
14
Just pick one free gpio from your datasheet.
switch:
- platform: gpio
pin:
number: GPIOXX
inverted: true
Go with Chatgpt or stay here.
Rofo
(Ro)
October 14, 2025, 9:42pm
15
I’d prefer the advice of a real human…
I was curious about this line which I didnt fully understand:-
mode: OUTPUT_OPEN_DRAIN # safer with Sonoff pull-up
Karosm
(Karosm)
October 14, 2025, 9:46pm
16
It’s likely related to approach to control sonoff without relay (not beginner task) and likely not correct…
Rofo
(Ro)
October 14, 2025, 9:48pm
17
I’ll post back on this thread when all the parts have arrived and I’ve set it all up. Ty for your time and patience helping me get to this point.
Karosm
(Karosm)
October 14, 2025, 9:52pm
18
No problem. Asking before fried components/person is preferred way…
For your curiosity, Sonoff S1/2 can be triggered without relay, but it’s likely bonded to AC mains, so without documentation/experience i’m not guiding anyone to that path.
giacrossi
(Giacomo Rossi)
October 30, 2025, 10:06am
19
Sorry for my question, but why do you need the relay? Wouldn’t be enough to use a physical switch (like one used for lights) and a smart switch with dry contact (as shelly 1/1 mini Gen4)?
Rofo
(Ro)
October 30, 2025, 4:56pm
20
You don’t need a relay if you’re using a physical switch. I need a relay because I’m triggering the switch from a GPIO pin on the WT32 spare pins.