110V / 230V Switch Circuit for Arduino / Raspberry Pi - Home Automation




First of all, 110V / 230V is lethal. Do this project at your own risk! If you don't know what are you doing, ask help!

With this switch you can control your lamps and electric devices like TVs, coffee machines, stereos etc.

Normal electromechanical relays are very unreliable. This is a better solution that can switch up to 600V / 8A, and totally isolated from the microcontroller thanksto the optocoupler.

Components you need:

- Arduino (arduino on Ebay)

- perfboard

- BTA08-600C triac (BTA08 on Ebay)

- MOC3021 optocoupler (MOC3021 on Ebay)

- 300 Ohm resistor

- 100 Ohm resistor

Tools you need:

- soldering iron (soldering iron on Ebay)


Step 1: The Hardware

The circuit is pretty simple. The microcontroller you use drive the triac through the optocoupler. The optocoupler is for safety reasons, but I recommend to use it.

Step 2: The Software

Here is an Arduino example code to show you how simple it is to use this circuit. When the digital pin is HIGH the triac switch on, when the pin is LOW the triac switch off.

void setup() {

pinMode(3, OUTPUT);


void loop() {

digitalWrite(3, HIGH);


digitalWrite(3, LOW);



IoT Challenge

This is an entry in the
IoT Challenge



    • Party Challenge

      Party Challenge
    • Arduino Contest 2019

      Arduino Contest 2019
    • Fandom Contest

      Fandom Contest

    4 Discussions


    11 days ago

    Good job!
    We have seen ARDUINO switching up to 4 or more relays.
    How could this be extended to do the same.

    1 reply

    Reply 11 days ago

    It is pretty simple, you can build as many of this as many you need, and you can connect them to the microcontrollers GPIO pins. So if your microcontroller has 12 digital pin, you can connect 12 of this circuit to it. If you need more than that, you can use shift registers or chips called port expanders.


    12 days ago

    I'd love to learn more about the components you're choosing. Is there anything special about this octocoupler?

    1 reply

    Reply 11 days ago

    There is nothing really special about this optocoupler, its reverse voltage is 3V so can switch by a microcontroller, and output terminal voltage is 400V so it is safe if something wrong kicks in on the triac side.
    There is nothing special about the triac either, the main reason I choose this, it can handle 600 volts and 8 amps, so it is more than enough in an average home.