Skip to the content
2 layers85 × 106.5 mm230V controller, the printed circuit board in 3D

This project was under development during the first semester of Master's Studies at Warsaw University of Technology (Poland) as a final project for Industrial Communication Protocols.

Size
85 × 106.5 mm
Copper layers
2
Thickness
1.6 mm
Parts
38
Nets
54
Pads
120
Tracks, vias
264, 0
Pours
3
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
4 Jul 2024
Updated
4 Feb 2025

Overview

230V controller is an open-source printed circuit board by kkorzen, from the kkorzen/Mains-Voltage-Device-Controller repository on GitHub, published under the MIT licence. It is a 2-layer board of 85 × 106.5 mm with 38 parts on 54 nets, routed with 264 tracks and 0 vias.

It is built around the BT136-600E, MOC3021M and BC546. Its parts include 11 resistors, 9 diodes, 4 transistors, 4 connectors and 3 switches. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

3

README

README.md

Contents

Introduction

This project was under development during the first semester of Master's Studies at Warsaw University of Technology (Poland) as a final project for Industrial Communication Protocols. Using the UART adaptation of RS-232, a simple controller was created. Its main goal was to make it possible to control a flow of mains current to the load devices. The device contains of two relays for bi-stable control and one triac for more "analogue" control (e.g., a lightbulb dimmer). The heart is an Arduino Nano board.

To make it a complete device with an "easy-to-use" logic, a simple desktop application was created that allows the user to change the states of two included relays and adjust the output voltage of a triac via a slider.

Electronics schematics + PCB Layout

Electronics schematic was made with KiCad. The whole schematic was divided into six sections to clarify different modules of the device.

Power section

This section contains only a single screw terminal for mains voltage connection. Through this terminal, the mains voltage/current are later delivered to the load devices.

Disclaimer:
"Zasilanie 230 VAC" means "230 VAC power supply".

Zero-cross detection

This section, one of the most important, is responsible for detecting the moment when a mains voltage's sine wave is crossing its zero point. As shown in the image given below, as the sine wave has a non-zero value, the optocouple is pulling the ZCD voltage to ground, but at the time the sine has a value of zero the ZCD voltage is pulled high through the 10k resistor $R_3$.

Bistable relay

Both of these relays are used to control the power delivery for any load that works with mains voltage. Moreover, it is possible to control any device that takes the mains voltage as the binary control input.

For additional protection, a BJT transistor was used as an element responsible for activating the relay's coil.

Triac dimmer

When the dimmer module is enabled by setting the DIMMER_EN voltage to HIGH, the optotriac diode is connected to ground, completing the circuit. Then, for a specific period of time, the DIMM_TRIAC voltage is set to HIGH, activating the optotriac. This behavior results in the main triac activating for a specified time, resulting in delivering a specified amount of power to the connected load.

IMPORTANT

Because the project utilizes a triac, only a resistive load is recommended to avoid the appearance of so-called tail current.

Control logic

A simple schematic for an Arduino with a drawn pinout. Nothing special, to be honest :sweat_smile:. A button was added to enable and disable dimmer, although the MCU can be reprogrammed to utilize this switch differently.

PCB Layout

Both sides of board were utilized, but most of the traces are located on the front. The were two main goals while designed such layout:

  1. Relatively compact size
  2. Visible separation of mains AC volatage from the control +5 volts. There is no physical gap between them, but the PCB was designed in such way that control voltage occupies one side of the PCB and the main voltage - the other side.

The layout can be viewed using one of the free PCB design software, for example KiCad.

Arduino code

Code written for an ATmega328P microcontroller (on an Arduino board) is not anything sophisticated, although it utilizes an ISR for accurate zero-cross detection of mains voltage sine wave.

For communication, it uses a USB protocol (and a USB <> UART transcoder) which, by transmitting and receiving characters, can be controlled by an external desktop app.

In the source code, there is also a potentiometer pinout definition #define POT A0, which was used for manual testing of the dimmer code + circuit combination before the development of the app. It was mounted only on the prototype board (manually soldered on the perfboard) and is not included in the final project.

The range of a triac activation delay (triac_delay) was selected with a so-called trial-and-error method. Values exceeding the range of 300–9000 have been marked as causing the dimmer to be unstable. Feel free to experiment with this range, however please be careful.

Application

It's a simple application - nothing revolutionary, although it was a pretty good micro challenge, which surely gave me an insight into making an app communicating with an external device.

When the app is opened, firstly, an appropriate COM port has to be selected using the combo box and then, by clicking the "Connect" button, the app will (or not if an invalid COM was selected) connect itself with a device, thus enabling the control section (right-hand side of the app's screen).

By clicking the "ON" and "OFF" buttons, you can change the state of both relays, respectively. The section below, called "Sine Wave Control", is responsible, as the name suggests, for adjusting the power delivered to the dimmer and its load (read the important warning in the Triac dimmer section).

If the connection is lost or the app is closed without disconnecting, all the relays are turned off and the dimmer power is set to 0%.

Parts

38
QtyValueFootprintReferences
41N4007Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD1, D2, D3, D4
4Screw_Terminal_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2_1x02_P5.00mm_HorizontalJ1, J2, J3, J4
32.2kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR7, R8, R10
3330Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR4, R6, R11
3BC546Package_TO_SOT_THT:TO-92_Inline_WideQ1, Q2, Q4
3LEDLED_THT:LED_D3.0mmD5, D6, D9
21N4148Diode_THT:D_DO-35_SOD27_P7.62mm_HorizontalD7, D8
2220Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR5, R9
247kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR1, R2
2HF32FAMy_Footprints:HF32FA_Type1_FormCK1, K2
110kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR3
1Arduino_Nano_v3.xModule:Arduino_NanoA1
1BT136-600Package_TO_SOT_THT:TO-220-3_VerticalQ3
1MOC3021MPackage_DIP:DIP-6_W7.62mmU3
1PC817Package_DIP:DIP-4_W7.62mmU1
1SW_Push_DPDTButton_Switch_THT:SW_Push_2P2T_Toggle_CK_PVA2xxH1xxxxxxV2SW2

The 34 most common of 38 parts.

Similar boards

  • 2 layers78.7 × 58.4 mmDimmerESP32, the printed circuit board in 3D

    DimmerESP32

    martinhofigueiredo/SE

    Sistemas Embarcados

    12 parts3
  • 2 layers260 × 140 mmSmartEnergyMag System, the printed circuit board in 3D

    SmartEnergyMag System

    MunyratanakBrorn/Smart-Electrical-Energy-Management-System

    Bachelor of Technology Thesis Project 2024.

    403 parts
  • 2 layers90 × 64.5 mmESLS, the printed circuit board in 3D

    ESLS

    Rajcr2/ESLS

    This was my academic project focused on creating a efficient LED based Street Lighting System which will avoid Power Wastage due to manual mismanagement.

    11 partsMIT
  • 2 layers100 × 100 mmAaram, the printed circuit board in 3D

    Aaram

    xicor22/Aaram

    PCB design for retro fitting old switch boards with new tech to control it remotely.

    77 partsGPL-3.0
  • 2 layers100 × 120.5 mmStopLight4, the printed circuit board in 3D

    StopLight4

    kitspace-test-repos/kicad6-file-collection

    59 partsMIT
  • 2 layers122.6 × 80.6 mmBed smart plug, the printed circuit board in 3D

    Bed smart plug

    mylife-home/mylife-home-devices

    MyLife Home devices

    26 partsGPL-3.0
  • 2 layers41 × 38 mmRS Board, the printed circuit board in 3D

    RS Board

    VGCH/radar_switch

    DIY module for lighting control with radar sensor

    35 parts5

Questions

How big is the 230V controller PCB?

It measures 85 × 106.5 mm and has 2 copper layers, 1.6 mm thick.

What parts does the 230V controller use?

38 parts, built around the BT136-600E, MOC3021M and BC546. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the 230V controller KiCad files?

From the kkorzen/Mains-Voltage-Device-Controller repository on GitHub, at the commit this page was made from: the board is Controller_PCB/230V_controller.kicad_pcb and its schematic Controller_PCB/230V_controller.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the 230V controller design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).