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.
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 know | Songle SRD-05VDC-SL-C relay | Omron G3MB-202P SSR, 5 VDC |
|---|---|---|
| Control side | coil 70 Ω, 71.4 mA at 5 V (0.36 W) | input 440 Ω ±20 %, about 11.4 mA at 5 V |
| Turns on by | 3.75 V on the coil (75 %, max) | 4 V on the input (max) |
| Turns off below | 0.5 V (10 %, min) | 1 V (min) |
| Load | AC or DC; Form C: 800 VA / 240 W switching power, inductive 3 A (120 VAC, 28 VDC); approval line 10 A 250 VAC | AC only, 75 to 264 VAC, 0.1 to 2 A; tungsten lamps 1 A and motors 1.6 A (UL, 240 VAC) |
| Losses when on | contact 100 mΩ max | 1.6 V RMS drop, max |
| When off | an open air gap | up to 1.5 mA leaks (at 200 VAC) |
| Speed | operate 10 ms, release 5 ms max | at the next zero crossing: up to 11 ms at 50 Hz |
| Wear | 100,000 operations electrical, 10,000,000 mechanical (min) | no contacts; surge 30 A for one cycle |
| Isolation, coil or input to load | 1500 VAC for 1 minute | 2500 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.
- 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.
- 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.
- 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.
- Grounds joined. The board's ground and the relay supply's ground meet, or the base current has no way home.
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.
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:
- 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.
- 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.
- 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.
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.
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.
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.
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.
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.
Lessons behind the numbers
- Relays: coil, armature and contact forms
- Driving a relay: the transistor stage in detail
- Solid-state relay: what is inside the black box
- Triac and diac: why an SSR is AC only
- Phase control: how a dimmer works, and why zero cross can't
- The BJT as a switch: the base-resistor method used above
- Phototransistor and optocoupler: the part behind the 3.3 V trap
- Flyback diode: the spike a coil makes
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.
- Ningbo Songle Relay, SRD series data sheet (copy hosted by Components101), §4 Rating, §6 Coil data, §7 Contact rating, §8 Performance (5 V high-sensitivity coil 71.4 mA, 70 Ω, 0.36 W; pull-in 75 % max, drop-out 10 % min, 120 % max; Form C 800 VA / 240 W switching power, inductive 3 A 120 VAC / 3 A 28 VDC; TÜV 10 A 250 VAC 30 VDC; contact 100 mΩ max; operate 10 ms, release 5 ms max; 10⁵ electrical, 10⁷ mechanical operations)
- Omron, G3MB Solid-state Relay data sheet, catalogue pp. 222-224 (copy on omron-russia.com) (5 VDC input 440 Ω ±20 %, must operate 4 V max, must release 1 V min; G3MB-202P 100-240 VAC, 75-264 VAC range, 0.1 to 2 A, surge 30 A one cycle; zero cross; operate and release half a cycle + 1 ms max; on drop 1.6 V RMS max; leakage 1.5 mA max at 200 VAC; no overvoltage absorber, add one for inductive loads; phase control needs a model without zero cross)
- Omron, G3MB data sheet (Omron Electronic Components LLC edition, copy hosted by Digi-Key), Approvals (UL E64562 at 40 °C, G3MB-202P: general purpose 2 A, tungsten 1 A, motor 1.60 FLA / 9.60 LRA at 240 VAC)
- Sharp, PC817XxNSZ1B Series data sheet, OP18002EN, 15 January 2018, Electro-optical characteristics and notes (VF 1.2 V typ, 1.4 V max at 20 mA; CTR 50 to 400 % at 5 mA, VCE 5 V; CTR variation may increase below 1 mA)
- Espressif, ESP32 Series Datasheet v5.3, Table 5-3 DC Characteristics (3.3 V, 25 °C), p. 52 (VOH min 0.8 × VDD (2.64 V); VOL max 0.1 × VDD; IOH 40 mA typ at VOH ≥ 2.64 V with drive strength at maximum)
- Microchip, ATmega48A/PA/88A/PA/168A/PA/328/P data sheet, DS40002061B (2020), Table 30-1 Common DC characteristics and §29.1 Absolute Maximum Ratings (VOH min 4.2 V at −20 mA, VCC 5 V; 40 mA DC per I/O pin absolute maximum)
- onsemi, P2N2222A/D Rev. 7, pp. 1-2 (as used on our 2N2222 part page, checked 30 September 2026) (VCEO 40 V; VBE(sat) 0.6 to 1.2 V and VCE(sat) 0.3 V max at 150 mA / 15 mA; hFE 50 min at 150 mA)
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