ElectronicsInfoline

Resources · Checked 10 October 2026

Relay module or SSR for Arduino and ESP32: which one, and the 3.3 V trap

The Songle SRD relay and the Omron G3MB SSR, read from their data sheets

By Bulan Sarkar, founder of ElectronicsInfoline (since 2000), Durgapur · Every rating from the maker's data sheet, 10 October 2026 · About a 12-minute read

Two boards come up whenever an Arduino or ESP32 has to switch something on mains: the blue relay board with a Songle SRD cube on it, and the black solid-state relay board built on Omron's G3MB. This page compares the two parts from their data sheets, and covers the low-voltage side: the pin, the coil or the SSR input, and the board.

For a lamp, fan or pump switched a few times a day, use a relay. The SRD's own data sheet caps its changeover contacts at 800 VA of switching power, which is about 3.5 A at 230 V, whatever the 10 A on the case says.

For a heater or anything switched every few seconds, use an SSR. The G3MB-202P switches 0.1 to 2 A (23 to 460 W at 230 V), AC only, with no contacts to wear out.

From a 3.3 V ESP32, drive neither one straight from the pin. The SSR needs up to 4 V to switch on, a 5 V coil needs up to 3.75 V, and a 5 V relay board can sit half on when the pin says "off". A 2N2222A, or the board's JD-VCC jumper used the right way, fixes all three.

Which one, in four questions

Ask the questions in this order. Start with the first, because an SSR of this kind cannot switch DC at all.

DC load (strip, pump)?yesMOSFET, or a relaynoDim a lamp, set fan speed?yesneither: phase controlnoSwitches often, 0.1-2 A AC?yesSSR, 23-460 WnoA few times a day?yesrelay, ≤ 3.5 A at 230 V
Figure 1. The order we ask the questions in. The SSR is the G3MB-202P, the relay the SRD on a hobby board.

For the DC case, our MOSFET guide picks the part and works out the heat. A relay switches DC too, but its contacts are rated far lower there for inductive loads (3 A at 28 VDC on the SRD changeover contacts).

The two parts, from their data sheets

The 5 V versions are the ones on hobby boards: SRD-05VDC-SL-C (the 0.36 W coil) and G3MB-202P with the 5 VDC input.

What you need to knowSongle SRD-05VDC-SL-C relayOmron G3MB-202P SSR, 5 VDC
Control sidecoil 70 Ω, 71.4 mA at 5 V (0.36 W)input 440 Ω ±20 %, about 11.4 mA at 5 V
Turns on by3.75 V on the coil (75 %, max)4 V on the input (max)
Turns off below0.5 V (10 %, min)1 V (min)
LoadAC or DC; Form C: 800 VA / 240 W switching power, inductive 3 A (120 VAC, 28 VDC); approval line 10 A 250 VACAC only, 75 to 264 VAC, 0.1 to 2 A; tungsten lamps 1 A and motors 1.6 A (UL, 240 VAC)
Losses when oncontact 100 mΩ max1.6 V RMS drop, max
When offan open air gapup to 1.5 mA leaks (at 200 VAC)
Speedoperate 10 ms, release 5 ms maxat the next zero crossing: up to 11 ms at 50 Hz
Wear100,000 operations electrical, 10,000,000 mechanical (min)no contacts; surge 30 A for one cycle
Isolation, coil or input to load1500 VAC for 1 minute2500 VAC for 1 minute

Read from both data sheets on 10 October 2026; the sources name the documents.

One line in the SRD sheet needs a closer look. Its approval list says 10 A at 250 VAC, and the case says the same. Its own contact table for the changeover (Form C) version gives a maximum switching power of 800 VA and 3 A for inductive loads. Both can't hold at once: 10 A at 250 V is 2,500 VA. We plan to the smaller number, 800 VA ÷ 230 V = 3.5 A, and smaller still for a motor.

Our take: the 10 A on a hobby relay cube is a headline. Size the load to 3.5 A at 230 V, and the board's thin tracks and screw terminals deserve the same caution.

Driving a bare relay from a pin

The coil wants 71.4 mA. An ATmega328P pin is rated 40 mA at absolute maximum, and an ESP32 pin is quoted at 40 mA typical, with no guaranteed figure. Neither drives a coil on its own, so a transistor does the switching and the pin only feeds its base.

  1. Base resistor. We aim for a base current one tenth of the coil current, the ratio the 2N2222A's saturation voltage is specified at. From an UNO (high at least 4.2 V under load) that is 390 Ω: 7.7 mA at the worst corner, 11.3 mA at the best. From an ESP32 (high at least 2.64 V) it is 180 Ω: 8 mA to 15 mA.
  2. Coil from +5 V to the collector, emitter to ground. With the transistor saturated the coil sees at least 4.7 V, well above the 3.75 V it needs. The transistor dissipates about 35 mW, a 7 °C rise.
  3. Diode across the coil, cathode to +5 V. When the transistor turns off, the coil's 71.4 mA has to go somewhere. Without the diode it drives the collector far past the 2N2222A's 40 V rating. With it, the current dies away round the loop. The flyback diode lesson works through the spike.
  4. Grounds joined. The board's ground and the relay supply's ground meet, or the base current has no way home.
+5 Vcoil70 Ω, 71.4 mA1N4007cathode to +5 V2N2222Apin180 Ω (ESP32)its contactsCOMNONCmains side:qualified personpin ground and relay supply ground joined
Figure 2. A bare SRD on a pin: 180 Ω from an ESP32 (390 Ω from an UNO), a 2N2222A, the coil from +5 V and a diode across it. The contacts are the mains side.

The coil's own limits explain the most common ESP32 mistake: powering a 5 V relay from the board's 3V3 pin. The data sheet promises pull-in only by 3.75 V. At 3.3 V the relay may click on your bench and stay silent on the next one, or drop out when the supply sags. Figure 3 shows where each voltage falls.

eitherpulls in5 V rated3V3 pin: not guaranteed4.7 V through a 2N2222A01234567volts across the coilreleases below 0.5 V · pulls in by 3.75 V · 6 V max
Figure 3. The SRD 5 V coil: guaranteed to release below 0.5 V, guaranteed to pull in from 3.75 V, 6 V maximum. Between 0.5 V and 3.75 V it may do either.

Relay boards and the 3.3 V trap

Most relay boards already carry the transistor and diode, plus an optocoupler in front. Their input is usually "low trigger": the board's VCC feeds the optocoupler's LED through a resistor, and pulling IN to ground lights it. On a 5 V UNO that works as sold.

On an ESP32 the "off" state goes wrong. A high pin sits at 3.3 V, not 5 V, so 1.7 V is still left across the LED and its resistor. With the 1 kΩ most boards use and a PC817's typical 1.2 V forward drop, about 0.5 mA still flows. Sharp warns that the PC817's gain spreads more below 1 mA, so whether that trickle holds the relay, buzzes it or does nothing depends on the board in front of you. That is not something to build on.

Three fixes, in the order we'd try them:

  1. Split the supplies with the JD-VCC jumper. On boards that have it, take the jumper off, feed JD-VCC (the coil side) from 5 V and VCC (the LED side) from the ESP32's 3.3 V. A high pin then leaves no voltage across the LED, and a low pin gives about 1.8 mA. This is also the only way the optocoupler isolates anything.
  2. Pull IN low with a transistor. A 2N2222A with 3.9 kΩ in its base sinks the 3.5 mA LED current. When it is off, IN floats up to VCC and no current flows at all. The pin now drives the relay active-high, so flip the logic in the sketch.
  3. Buy a high-trigger or 3.3 V board. Read the seller's schematic before trusting the label, and test it with the steps below.
5 V board, pin low (on)3.5 mA5 V board, 3.3 V high (off?)0.5 mAVCC 3.3 V, pin low (on)1.8 mAtransistor on IN, off0 mAmA in the optocoupler LED
Figure 4. Current in a relay board's optocoupler LED, from VCC − pin − 1.2 V across 1 kΩ. The red bar is a pin meant to say "off".

Our take: on an ESP32, pull the JD-VCC jumper and power the two sides separately. It costs nothing, and the off state then holds on every board.

Our level shifting guide covers the same 3.3 V and 5 V mismatch for logic inputs.

The SSR: what it can and can't switch

Inside the G3MB, an LED shines on a phototriac, which fires the output triac. No metal touches metal, so there is no click and no contact wear. A triac has its own rules, though, and they shape what you can plug into it.

  • AC only. A triac stops conducting when the current through it passes zero, which AC does 100 times a second. On DC it never passes zero, so the load stays on after the input goes off.
  • A floor as well as a ceiling. Omron rates it from 0.1 A. At 230 V that is 23 W. A 9 W LED bulb draws about 39 mA, below the floor, and the 1.5 mA that leaks through an "off" SSR can be enough to make it glow or flicker.
  • The ceiling is 2 A (460 W), lower when the air around it is warm. Mount more than three together with poor airflow and Omron says to halve the current, to 1.0 A each. A 1 kW heater (4.3 A) is beyond it.
  • Surges. It survives 30 A for one cycle, once. If the surge repeats at every switch-on, keep it to 15 A. UL lists filament lamps at 1 A and motors at 1.6 A running current for this part.
  • Motors and transformers need help. The G3MB has a snubber built in but no overvoltage absorber; for an inductive load Omron asks you to add one. That is a mains-side component, for the person wiring that side.
  • The input wants 4 V. The 5 V version must switch on by 4 V, drawing 9.5 mA to 14.2 mA. An UNO pin (at least 4.2 V) does it directly. An ESP32 pin at 3.3 V is below the line, so drive the input through a transistor from 5 V, or use an SSR board that does.
SSR (G3MB-202P)23-460 Wrelay (SRD, planned)up to 800 VA9 W LED bulb1 kW heater1101001000watts at 230 V, log scale
Figure 5. What each part can switch at 230 V, resistive loads, log scale. The SSR has a floor (0.1 A) as well as a ceiling. Dashed: a 9 W LED bulb and a 1000 W heater, our examples.

The G3MB-202P is a zero-cross part. When the input comes on, it waits for the mains voltage to pass through zero before it fires, so the load starts gently and makes little interference. At 50 Hz a half cycle lasts 10 ms, so the output can lag the pin by up to 11 ms. It switches off the same way, at the next current zero.

That same behaviour rules out dimming. A lamp dimmer fires the triac part-way through each half cycle, and a zero-cross SSR refuses to. Omron says to pick a model without zero cross (the G3MB-202PL) for phase control, and the phase control lesson explains the circuit. That is mains-side design work, beyond a pin and a board.

load current flowsinput from the pinwaits for zero010203040ms230 V mains, 50 Hz
Figure 6. A zero-cross SSR at 50 Hz: the pin goes high part-way through a half cycle; the load current starts at the next zero, up to 11 ms later.

Heat: the SSR's hidden cost

Closed relay contacts are a resistor of at most 100 mΩ. An SSR that is on has a voltage drop of up to 1.6 V. So the relay's heat grows with the square of the current from almost nothing; the SSR's grows in a straight line from the first amp.

At 2 A: relay 2² × 0.1 Ω = 0.4 W; SSR 1.6 V × 2 A = 3.2 W, 8 times as much, from a package the size of a stick of gum whose case is its heatsink. Give it air, and keep it off a crowded corner of the board.

01234SSR: 3.2 W at 2 Arelay: 0.4 W00.511.52load current, Awatts in the switch
Figure 7. Heat in the switch against load current: the SSR's 1.6 V drop × I, against the relay contacts' 100 mΩ × I². Both are the data sheets' maximum values.

How often it switches decides it

The SRD sheet promises at least 100,000 operations under load. Switching a lamp twice a day, that is more than a century. A thermostat that clicks the relay every minute uses it up in 69 days of running, and once every 10 seconds in 12 days. The figure is a minimum at the rated load, so a lighter load lasts longer, but the shape holds.

switching every 10 s12 daysswitching every minute69 daysswitching every 10 minutes694 daysswitching every hour11.4 yearsrunning time, log scale
Figure 8. Running time until the SRD reaches its 100,000 rated electrical operations, at one operation per interval, log scale.

Our take: if the sketch switches the load more often than every few minutes, it is an SSR job, or the relay becomes a part you replace.

Controlling a heater with an SSR

Don't feed an SSR from analogWrite(). At 490 Hz the PWM pulses are shorter than a 10 ms half cycle, so whether the SSR fires depends on where each pulse lands against a zero crossing. The heater gets a beat pattern instead of a steady power level.

Use a slow time window instead: keep the output on for a share of a fixed window. A 2 s window holds 200 half cycles at 50 Hz, so the power can be set in steps of 0.5 %. A heater's thermal mass smooths that out. The solid-state relay lesson covers the inside of the part.

Tips and checks

  • Test the board with no mains connected. Use a multimeter on continuity across COM and NO: it should beep with the pin in its "on" state, and go silent with the pin in its "off" state, every time, including straight after a reset.
  • For an SSR, test with a low-voltage AC source if you have one, or let the qualified person check it with the load. A multimeter across an unpowered SSR output tells you nothing.
  • On an ESP32, avoid the pins that change state during boot, so the load does not blink at power-up. Check your board's pinout.
  • Put the relay's coil supply on its own 5 V feed where you can. 71.4 mA per coil adds up fast on a 4-channel board running from USB.
  • The SSR's input has no reverse-polarity protection. Check + and − twice before powering it.
  • Buy from a seller who names the source (our India buying guide lists them). Copies of both parts exist, and the data sheet only covers the real one.

What we'd do: a lamp, fan or pump switched a few times a day gets a relay board, kept under 3.5 A, with JD-VCC split if the controller is an ESP32. A heater or anything cycling every few minutes gets a G3MB-based SSR board, kept under 2.0 A with air around it and driven in a 2 s window. Anything bigger, or anything that dims, gets a properly rated industrial part and an electrician, and stays off hobby boards.

Questions we keep hearing

Can an ESP32 drive a 5 V relay module? Driving the low side, yes, but not as sold. With the board on 5 V, a high ESP32 pin still lets about 0.5 mA through the optocoupler, so the relay may not let go. Remove the JD-VCC jumper and power VCC from 3.3 V and JD-VCC from 5 V, or pull IN low with a transistor.

Why does my relay click on but never turn off? Usually that half-on optocoupler current, from a 3.3 V board on a 5 V low-trigger module. Measure the voltage between VCC and IN with the pin high; anything above a volt or so means the LED is still being fed.

Can a G3MB SSR switch a 12 V DC load? No. Its output is a triac, which only turns off when the current passes zero. On DC that never happens, so the load stays on. For DC, use a MOSFET.

Why does my LED bulb glow when the SSR is off? The SSR leaks up to 1.5 mA when off, and a small LED bulb needs very little to glow. The bulb is also below the SSR's 0.1 A minimum load. Use a relay for small LED lamps.

Is a 10 A relay module good for 10 A at 230 V? Not by the SRD's own contact table, which caps the changeover contacts at 800 VA (3.5 A at 230 V). The board's tracks and terminals set their own limit too. For a big load, use a larger relay or contactor rated for it.

Is there a 3 V relay so I can skip the transistor? The SRD comes in a 3 V version, but its coil draws 120 mA, far beyond any microcontroller pin. You still need the transistor; it just runs from 3.3 V instead of 5 V.

Lessons behind the numbers

Parts used here: the 2N2222 part page has the pinouts and the full switching method.

Sources

Every data sheet read on 10 October 2026 unless the entry says otherwise.

Our own choices, not from any source: 230 V, 50 Hz mains and resistive loads when we turn amps into watts; planning the relay to the 800 VA line; the 1 kΩ optocoupler resistor and the PC817's typical forward drop for the relay board (read your own board); the forced gain of 10 for the transistor; the 9 W and 1000 W example loads; and the 2 s control window. The Songle and Omron documents are copies hosted by Components101, Omron Russia and Digi-Key, because neither maker serves a direct download to scripts.

How this page was checked

Every rating comes from the data sheets above, and every derived number is computed in code from those values, so the text and the figures cannot disagree. We print no prices and carry no affiliate links. Found an error? Tell us.

More guides: Resources · MOSFET for Arduino and ESP32 · 3.3 V and 5 V level shifting