Guide no. 4
A switch operated by an electromagnet: it separates the control circuit (coil) from the power circuit (contacts).
By Ada Intelisano · informaticait.it technical team
In short
- The coil draws I = V / R: a 5 V relay with a 70 Ω coil draws about 71 mA.
- A microcontroller pin is not enough (20 mA recommended): you need a transistor or a relay module.
- A diode must always sit across the coil (cathode to +): it protects the transistor at switch-off.
- Contacts: COM common, NO normally open, NC normally closed.
Pin high → the transistor conducts → the coil is energised and COM moves from NC to NO. The flyback diode absorbs the voltage spike the coil generates when it switches off.
Worked example. SRD-05VDC relay: 70 Ω coil → I = 5 / 70 ≈ 71 mA, power 5 × 0.071 ≈ 0.36 W. NPN transistor with forced gain 20 → IB ≈ 3.6 mA → RB = (5 − 0.7) / 0.0036 ≈ 1.2 kΩ → 1 kΩ. It also works with a 3.3 V pin (IB ≈ 2.6 mA).
Reading relay data
| Data | Example | What it means |
|---|---|---|
| Coil voltage | 5 V DC | control voltage; from 3 to 48 V, also AC versions |
| Coil resistance | 70 Ω | sets the current drawn: I = V / R |
| Contact rating | 10 A 250 V AC 10 A 30 V DC | with DC the allowed voltage is much lower (arcing) |
| Configuration | SPDT (1 changeover) | COM, NO, NC; DPDT = two changeovers switched together |
| Drop-out voltage | ≥ 10% of nominal V | below this voltage the relay releases |
Contacts at rest and with the coil energised
Relay modules and solid-state relays
- Relay modules already include transistor, diode and LED; some also an optocoupler.
- Many modules are active low ("low level trigger"): the relay switches with the pin at 0.
- On optocoupled modules the JD-VCC jumper lets you power the coil separately.
- Solid-state relays (SSR) are silent and wear-free, but they get warm, have a small leakage current, and triac types work on AC only.
Common mistakes
- Driving the coil directly from the pin: too much current, the pin gets damaged.
- Forgetting the diode or fitting it backwards: in the first case the transistor fails, in the second it is a short circuit.
- Using the contacts at full rating with motors, lamps or power supplies: the inrush current is many times the nominal one. Choose a relay with margin.
- Treating the 230 V side like the 5 V side: clearances, insulation and a suitable enclosure are required.
Warning: connections to 230 V mains are dangerous and must be made by qualified personnel, according to local regulations.
Sources: Songle SRD-05VDC-SL-C datasheet · onsemi BC547 and 1N4007 datasheets
Useful products
PCB relay SRD-05VDC-SL-C, 5 V coil, 5 pins, SPDT, 10 A 250 V AC contact
Codice mepa: MIC1772IT
Posizione: C2
Quantità disponibili: 187
€1.31
1-channel 24 V optoisolated relay module with high/low trigger, 10 A 250 V AC contacts
Codice mepa: MIC521IT
Posizione: VET3
Quantità disponibili: 66
€4.55
Solid state relay (SSR) Omron G3MB-202P, 12 V DC control, 240 V AC 2 A load, 4-pin
Codice mepa: MIC1887IT
Posizione: C1
Quantità disponibili: 73
€3.90
Rectifier diode 1N4007 1000 V, 1 A, DO-41 Diotec (pack of 10)
Codice mepa: MIC11718IT
Quantità disponibili: 29544
€1.80
NPN transistor BC547B 45 V 100 mA TO-92
Codice mepa: MIC2224IT
Posizione: CASS4
Quantità disponibili: 89
€0.65
Other guides
- Resistor colour code and tolerances
- N-channel and P-channel MOSFETs
- Bipolar transistor (BJT) or MOSFET?
- THT and SMD/SMT components
- XIAO board pinouts
- LEDs: forward voltage and series resistor
- The multimeter: measuring voltage and current
- Wemos D1 mini: first steps
- MOSFET module with Arduino and ESP32
- Relay module with Arduino and ESP32
- 3D printing filaments: PLA, PETG and fibre-filled versions
- Analog and digital: the differences
- ADS1115: 16-bit converter with Arduino and ESP32
- From bits to real values: converting sensor readings
- DS3231 RTC clock with Arduino and ESP32
- Linear or switching regulator: which one to choose
- Step-down, step-up and buck-boost: choosing the right module
- Voltage divider: reading voltages higher than 5 V or 3.3 V
- Pull-up, pull-down and bounce: wiring a button properly
- 3.3 V and 5 V logic levels: getting an ESP32 and an Arduino to talk
- The I²C bus: addresses, pull-ups and the scanner
- Lithium batteries: voltages, charging and protection
- ESP32 power consumption and deep sleep: how long the battery lasts
- Temperature sensors compared
- ESP32: which pins to use and which to avoid
- Getting started with the ESP32 in Arduino IDE 2 and PlatformIO
- SSD1306 OLED display and 16×2 I²C LCD with Arduino and ESP32
- PIR motion sensor and HC-SR04 ultrasonic sensor
- Date and time from the Internet with the ESP32: NTP, Italian time zone and daylight saving time
- MicroSD data logger: saving measurements to CSV
- Solar-powered ESP32: panel, charger and the numbers for Italy
- Web server on the ESP32: control a relay from your phone
- Your first LED: wire it up and make it blink
- The button: let Arduino decide
- The potentiometer: turn a knob and read its value
- Soft light: adjusting the brightness of an LED
- The buzzer: playing notes and melodies
- The traffic light: three LEDs in sequence
- The thermometer: reading the temperature with the TMP36
- The servo motor: moving an arm with Arduino
- The night light: the photoresistor and your first decision
- The relay: switching on a light bulb with Arduino
- The LCD display: making Arduino write
- The electronic dice: your first complete project
- The RGB LED: every color from three lights
- The joystick: two-axis control with a shield
- The LED ring: twelve colors from a single pin
- The DC motor: driving it with a MOSFET
- Soil moisture: the plant that asks for water
- The stepper motor: turn exactly as far as you want
- The parking sensor: faster and faster beeps
- The 7-segment display: big, bright numbers
- Automatic watering: the plant that waters itself
- The keypad: a lock with a secret code
- Networked weather station: values and chart on your phone
- A Telegram bot on the ESP32: your home from your phone
- MQTT with the ESP32: the language of connected devices
- Updating the ESP32 over Wi-Fi (OTA)
- ESP-NOW: two ESP32 boards talking without a router
- WebSocket with the ESP32: the LED that follows the slider
- Readings on a Google sheet, with deep sleep
- WiFiManager: choose the Wi-Fi from your phone
- Bluetooth LE with the ESP32: the phone without a network
- The camera in your browser with the ESP32-S3
- A portable Bluetooth speaker you build yourself
- Bluetooth desktop speakers, 2 × 20 W
- Stereo MP3 player with two buttons
- The shelf that plays music: a Visaton exciter
- How to solder well
- How much does it draw? Current and power with the INA219
- Load-cell scale with the HX711
- CO2 traffic light: when to open the windows
- RFID card door opener
- GPS: track logger on microSD
- LoRa: how far does it go? A range test with two boards
- Battery weather sign with an e-paper display
- Web radio with an ESP32 and an I2S amplifier
- Getting started with the Raspberry Pi Pico 2 in MicroPython
- Your first amplifier: the LM386 and a speaker
- Talking Arduino: the DFR0760 speech synthesis module
- The spectrum of your music on an LED matrix
- Drawing with 64 LEDs: the 8×8 matrix with the MAX7219
- A real voltage: the 12-bit MCP4725 DAC
- Your own macro keyboard: four NeoKey keys and the QT Py RP2040
- The Maqueen robot with the micro:bit: follow the line, avoid obstacles
- A two-way speaker with a Visaton woofer, tweeter and crossover
- A 120-LED NeoPixel strip, powered the right way
- A linear actuator to open a lid
- The heartbeat on Arduino: an ECG with the AD8232
- The infrared remote: controlling Arduino from the couch
- The electronic spirit level: tilt and impacts with the ADXL345
- Your first oscilloscope: seeing a signal
- The bench power supply: voltage, current limit, safe tests
- Hot air for SMD: removing and refitting an IC