Practical case: Lamp control with relay and push button

Schematic — Practical case: Lamp control with relay and push button
Objective and use case

What you will build: A circuit that switches a 230 V AC lamp using a 5 V DC relay actuated by a low-voltage push button. You will check its operation by measuring voltages, coil current, and the lamp’s behavior.

What it is used for

  • Turning on a ceiling lamp in a home-automation model using a safe 5 V push button.
  • Controlling a desk lamp without directly handling 230 V mains cables.
  • Simulating room lighting control from a future microcontroller or PLC.
  • Activating a warning light (beacon) when a remote dry contact closes, for example from another piece of equipment.
  • Replacing a mechanical wall switch with a system providing galvanic separation between low and high voltage.

Expected result

  • V_coil ≈ 5 V DC while the button is held down; ≈ 0 V DC when released.
  • I_coil within the specified range (e.g. 60–90 mA according to the relay datasheet).
  • Voltage at the lamp terminals ≈ 230 V AC when the relay is activated and ≈ 0 V AC when it is deactivated.
  • Clear and repeatable relay click on each press, with no sticking or noticeable bounce at the load.
  • The lamp only turns on while the push button is pressed, with no flicker or abnormal heating in cables or relay.

Target audience: Students and electronics hobbyists beginning with mains load control; Level: Beginner–intermediate.

Architecture/flow: 5 V DC supply powers the push button → push button powers the relay coil → relay contacts open or close the 230 V phase to the lamp → when pressed, the coil is energized, the relay switches and applies 230 V to the lamp; when released, the coil de-energizes and the lamp turns off.

Materials

  • 1 × 5 V DC relay, contacts for 230 V AC (for example, SPST or SPDT, ≥ 3 A).
  • 1 × Normally open (NO) low-voltage push button.
  • 1 × 1N4007 diode (or similar) for coil protection.
  • 1 × 5 V DC power supply (adapter or lab bench, ≥ 200 mA).
  • 1 × 230 V AC lamp (incandescent or LED bulb with base and lamp holder).
  • 1 × 230 V AC mains cable with plug and suitable insulation.
  • Several low-voltage (5 V) connecting wires.
  • Several high-voltage (230 V AC) wires, with suitable insulation.
  • 1 × Breadboard (only for the 5 V part if desired; the 230 V part is better with terminal blocks).
  • 2 × Terminal blocks or connector strip to clearly separate the high-voltage mains side.

Wiring guide

WARNING: The 230 V AC part is dangerous. Make the connections with the power off, double-check them, and if you have no experience with mains electricity, only build the 5 V part and simulate the lamp with an LED and a resistor.

  • Low-voltage power connections (5 V):
  • Connect the positive terminal of the 5 V supply to the +5V node.
  • Connect the negative terminal of the 5 V supply to the GND node.
  • Relay coil and push button connection:
  • Connect one terminal of the relay coil to the +5V node.
  • Connect the other terminal of the relay coil to the VB node.
  • Connect one terminal of the push button to the VB node.
  • Connect the other terminal of the push button to the GND node.
  • Protection (flyback) diode in parallel with the coil:
  • Connect the cathode of diode [D1] (marked with a line on the body) to the +5V node.
  • Connect the anode of diode [D1] to the VB node.
  • Make sure the diode is in parallel with the coil and reversed with respect to the supply polarity (it must not conduct under normal conditions).
  • Lamp and 230 V AC mains connections (power side):
  • Identify on the relay the common contact [COM] and the normally open contact [NO].
  • Connect one conductor of the 230 V AC mains (for example, phase L) to the relay’s [COM] contact.
  • Connect the relay’s [NO] contact to one of the lamp holder terminals.
  • Connect the other lamp holder terminal to the other conductor of the 230 V AC mains (for example, neutral N).
  • Make sure the relay only interrupts one of the conductors (normally the phase) and that the connections are protected and insulated.

Schematic

                               Parte de control (5 V DC, bobina y pulsador)

             +5V
             |
             +-------------------------+
             |                         |
          [Bobina] Relé              [D1] 1N4007
             |                         |
             o VB node                 |
             |                         |
           [Pulsador]                  |
             |                         |
            GND------------------------+

   Parte de potencia (230 V AC, contactos y lámpara)

       Red 230V AC
        L (fase)            Relé (contactos)           Lámpara
          |                      |                      |
          +------------------[COM]                      |
                                 |                      |
                                 o VC node              |
                                 |                      |
                             [NO] contacto              |
                                 |                      |
                                 +------------------[Lámpara]
                                                        |
       Red 230V AC                                      |
        N (neutro)--------------------------------------+
Schematic (ASCII)

Measurements and tests

  • Before energizing (power off):
    • Check push button continuity with the multimeter in ohmmeter mode:
    • Place the multimeter probes on the two push button terminals.
    • Make sure it shows an open circuit (very high resistance) when not pressed and low resistance when pressed.
    • Check relay coil continuity:
    • Measure between the two coil terminals; you should see a resistance of a few hundred ohms (depends on the model).
    • Make sure there is NO direct continuity between the 5 V side and the relay’s power contact terminals.
  • Measurements on the 5 V side (with only 5 V connected, no 230 V AC):
    • Measure the voltage across the coil (V_coil):
    • V_coil = voltage between the +5V node and the VB node.
    • Without pressing the button, V_coil must be ≈ 0 V.
    • While pressing the button, V_coil must be ≈ 5 V (or the supply’s nominal voltage).
    • Observe and listen to the relay:
    • While pressing the button, you should hear a clear “click”; when releasing, another “click” when it returns.
  • Measurements on the 230 V AC side (WITH GREAT CAUTION):
    • Measure the voltage on the lamp (V_lamp):
    • V_lamp = voltage between the two lamp holder terminals.
    • With the relay at rest (push button not actuated), V_lamp must be ≈ 0 V.
    • While pressing the push button, V_lamp must be ≈ 230 V AC (or the local mains voltage).
    • Verify operation visually:
    • The lamp must light only while the push button is pressed and turn off when released.
  • Optional: coil current measurement (I_coil):
    • I_coil = current flowing through the relay coil when the button is pressed.
    • To measure I_coil, set the multimeter to DC ammeter mode in series with the coil:
    • Disconnect the wire going from +5V to the coil.
    • Connect one multimeter probe to the +5V node and the other probe to the coil terminal that was connected to +5V.
    • Press the button and read the value; compare it with the relay’s typical value (see datasheet).

Common mistakes and how to avoid them

  • Connecting diode [D1] backwards:
  • If the diode is reversed (anode to +5 V and cathode to VB), it will short the 5 V supply when you press the button.
  • Always check that the cathode (marked with a band) goes to +5V and the anode to VB.
  • Confusing the relay coil with the contacts:
  • The coil is usually indicated on the package with a coil symbol or specific pin numbers.
  • Check the datasheet or drawing of the relay; do not connect 230 V to the coil.
  • Using a relay not suitable for 230 V AC:
  • Check on the relay case the maximum contact voltage and current (for example, “250 VAC 5 A”).
  • If it is not clearly specified, do NOT use it for mains.
  • Not properly isolating the 230 V AC side:
  • Never mix mains cables with 5 V wires in the same area without physical separation.
  • Use terminal blocks, heat-shrink tubing, and an enclosure or box to avoid accidental contact.

Safety

  • Always work with the mains disconnected while making or modifying 230 V AC connections.
  • Use a main switch or power strip with switch to be able to quickly cut off the supply.
  • Never touch mains cables or lamp terminals when the circuit is energized.
  • If you are not sure about the 230 V AC part, limit the experiment to the 5 V side and replace the lamp with an LED with resistor and a second relay or simply a light indicator.

Possible improvements

  • Replace the push button with a two-position switch so the lamp can stay on without holding the button down.
  • Add a transistor or microcontroller circuit to activate the relay from a logic signal (for example, Arduino).
  • Replace the electromechanical relay with a solid state relay (SSR) to avoid mechanical noise and increase lifetime.
  • Add a fuse in series with the lamp or the 230 V AC supply line for extra protection.
  • Implement a latching (self-maintaining) system using the relay itself so that one short press turns on and another short press turns off (switch-like function with push button).

More Practical Cases at Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon affiliate, I earn from qualifying purchases. If you buy through this link, you help support this project.

Quick Quiz

Question 1: What voltage does the push button operate at?




Question 2: What is the primary purpose of the circuit described?




Question 3: What type of relay is used in the circuit?




Question 4: What happens when the push button is released?




Question 5: What is the expected coil current range according to the relay datasheet?




Question 6: What voltage should be present at the lamp terminals when the relay is activated?




Question 7: What is the target audience for this project?




Question 8: What is the function of the relay in this circuit?




Question 9: What should happen when the push button is pressed?




Question 10: What is a key benefit of using this circuit?




More Practical Cases on Prometeo.blog

Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:
Scroll to Top