Skip to the content
2 layers45 × 72 mmRelay, the printed circuit board in 3D

A modbus RTU relay board with 3 relays for the CNC. This uses the ASX framework

Size
45 × 72 mm
Copper layers
2
Thickness
1.6 mm
Parts
43
Nets
37
Pads
135
Tracks, vias
176, 17
Pours
10
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
14 Dec 2024
Updated
10 Jan 2026

Overview

Relay is an open-source printed circuit board by adarwoo, from the adarwoo/modbus_relay repository on GitHub. It is a 2-layer board of 45 × 72 mm with 43 parts on 37 nets, routed with 176 tracks and 17 vias.

It is built around the ATTINY824-SSU, LM1117MP-5.0 and IRLML0030. Its parts include 10 capacitors, 9 resistors, 6 diodes, 4 connectors and 3 ICs. It belongs with the home automation and IoT boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

3

README

README.md

Modbus Relay

This project is a fully working MODBUS RTU Relay. The project comes with schematic and PCB, as well as the firmware of course!

The core of the relay is an AVR Tiny1624, an automotive grade MPU designed for harsh environment. Note: The code optimized with -Os is <16KB. The -Og used typically for debug is <32k. Therefore, for debugging, a 3224 device is required. Remembed to edit the makefile to specify your device.

This project can be reused for other Modbus devices. A modbus interface generator is provided that makes adding modbus commands simple. The generator reads from a Python configuration file.

Example of such configuration file:

python
"device@44": [
        (READ_COILS,            u16(0, 2, alias="addr"),
                                u16(1, 3, alias="qty"),
                                "on_read_coils"),

        (WRITE_SINGLE_COIL,     u16(0, 2, alias="addr"),
                                u16([0xFF00, 0, 0x5500], alias="op"),
                                "on_set_single"),

        (WRITE_MULTIPLE_COILS,  u16(0, alias="from"),
                                u16(3, alias="qty"),
                                u8(1, alias="count"),
                                u8(0, 7, alias="values"),
                                "on_set_multiple"),

        (READ_HOLDING_REGISTERS, u16(0, 2), u16(1, 3), "on_read_info"),
    ]

The handling code is just as simple:

c++
   void on_read_info(uint8_t index, uint8_t qty) {
      Datagram::pack<uint8_t>(qty*2);

      while ( qty-- ) {
         switch(index++) {
         case 0: Datagram::pack( DEVICE_ID ); break;
         case 1: Datagram::pack( HW_VERSION ); break;
         case 2: Datagram::pack( FW_VERSION ); break;
         default:
            Datagram::reply_error(modbus::error_t::illegal_data_value);
         }
      }
   }

front back

Solder side of the board

Out of the box, the relay supports the following modbus commands:

  • READ_COILS 1-3
  • WRITE_SINGLE_COIL Support for 0x5500 to toggle
  • WRITE_MULTIPLE_COILS 1-3
  • READ_HOLDING_REGISTERS
    1. Version
    2. FW version
    3. HW version

If compiling using the supplied Dockerfile, the elf is 7KB in size, so a ATTiny824 will work.

The device default address is 44 (Decimal). By default, it runs at 115200 8E1.

KiCAD schematic and PCB are available.

Tested with QModMaster.

I plan to add address and serial configuration modbus command (and eeprom persistence).

How to build

You will need a Linux shell, or WSL shell in Windows. The tool 'gitman' is required as well as Docker. (docker-ce or else).

Steps

bash
# Clone this repo
$ git clone https://https://github.com/adarwoo/modbus_relay.git
$ cd modbus_relay
# Optional - install gitman
$ pipx install gitman
$ gitman update
$ make NDEBUG=1 # Optional, add ARCH=attiny1624 to suit you device

The binary modbus_relay.elf can be found in the directory

Modbus Relay Device User Manual

Overview

The Modbus Relay Device is a configurable relay controller with Modbus RTU communication. This document describes how to configure and operate the device, including its default settings, configuration mode, and reset process.

Factory default settings

The relay comes pre-configured with the following value:

ConfigurationDefault valueExplanation
Slave ID0x44The device address is 44 (decimal) by default
Baud rate9600The device talks at 9600 by default
Serial setup8N18bits, no parity and 1 stop bit
Watchdog0 (off)The watchdog feature is off by default

Resetting the relay to factory default setttings

If the relay is un-responsive, it may have been mis-configured. The relay can be reset to it's factory default using the following procedure.

  1. Power off the relay
  2. Configure your Modbus master configuration tool (such as QModMaster) using a baud rate of 9600, 8 data bits, No parity, and 1 stop bit (9600 8N1).
  3. Ready the following message:
FieldValueExplanation
Slave ID0x00Broadcast address.
Function Code0x10Write multiple holding registers.
Start Address0x0063Address of the reset register (40100)
Quantity0x0002Writing 2 registers (32-bit number).
Byte Count0x044 bytes of data to follow.
Data0xDEAD 0x5AFEMSW = 0xDEAD, LSW = 0x5AFE.
CRC0xBAE7CRC
  1. Power on the relay. All LEDs turn RED for 5 seconds.
  2. During that time, send the 'Write multiple register' commmand
  3. If the relay receives the command, the LEDs will blink fast for 5 seconds, then turn all on indicating the device was successfully reset
  4. Now the device is factory reset and can be reached at its address 44 (0x2C).

Simple relay operation

In normal mode:

  • The device responds only to frames addressed to its Device ID.
  • The bus operates as configured
  • Relays operate based on the configured default positions and command inversion settings.
  • Regular coil commands do not respond in configuration mode to prevent mode mixing.

Supported Modbus Functions

  • Read Coils (Function Code 1):
    • Addresses 0x0000 to 0x0002 for Relay 0, Relay 1, and Relay 2.
  • Write Single Coil (Function Code 5):
    • Write 0xFF00 to turn on, 0x0000 to turn off, and 0x5500 to toggle a relay.
  • Write Multiple Coils (Function Code 15):
    • Write a bit array to set relay states (1 = closed, 0 = open).
  • Read Holding Registers (Function Code 3):
    • Register 0x0000 (40001): Product ID (0x3701).
    • Register 0x0001 (40002): Device Hardware Version (0xMMmm, where MM = major, mm = minor).
    • Register 0x0002 (40003): Software Version (0xMMmm, where MM = major, mm = minor).
    • Register 0x0008 (40009): Device address
    • Register 0x0009 (40010): Baud rate selection (1/100th of the actual baud rate)
    • Register 0x000A (40011): Parity. 0=None, 1=Odd, 2=Even
    • Register 0x000B (40012): Number of stop bits. 1=1 stop bit, 2=2 stop bits
    • Register 0x000C (40013): Watchdog window size in seconds
    • Register 0x0010 (40017 + 40019): Number of minutes in operation as a 32-bits
    • Register 0x0014 (40019 + 40020): Number of relay 0 movements as a 32-bits
    • Register 0x001A (40021 + 40022): Number of relay 1 movements as a 32-bits
    • Register 0x001C (40023 + 40024): Number of relay 2 movements as a 32-bits

Configuring the device

The factory default communication settings for the relay are:

  • Device address is 44
  • Baud rate is 9600
  • 8 data bits
  • No parity
  • 1 stop bit (9600 8N1).

Configuration registers available

These can be accessed with a write single register command or the serial settings can be set with 1 write multiple command.

Register AddressFunctionValues/DescriptionFactory Default
40009 (0x0008)Device ID1 to 24744
40010 (0x0009)1/100th of the baud Rate12, 24, 48, 96, 192, 384, 576, 115296
40011 (0x0010)Parity0 = None, 1 = Odd, 2 = Even0 (None)
40012 (0x0011)Stop Bits1 or 21
40013 (0x0012)Watchdog Timeout (seconds)0 = Disabled, 1->655350

Note: When writting the configuration with a multiple write, all 5 settings must be written in the same transaction.

Reset the device

The register at 0x63 (40100) can be written with 0xDEAD5AFE to reset the device remotely. This is usefull to apply any changes made to the settings. The command will reply, and the leds will flash fast for 2 seconds, then solid (the device is booting).

Using the watchdog

The relay has a command watchdog which will release the relays following a period of inactivity. Everytime a valid modbus command is received (including holding register read etc.), the watchdog is reset. This feature allow for the relays to be atomatically releases if the master was to fail. The period is given in seconds. A value of zero (default) turns off the feature.


Troubleshooting

Cannot Communicate with Device

  • Ensure the device is in configuration mode or responding to the correct Device ID.
  • Check baud rate, parity, and stop bit settings.

Lost Device ID

  1. Send a valid broadcast frame to enter configuration mode.
  2. Use the default Device ID (0) to reset the device via the reset register.

Relay Does Not Respond

  • Verify relay default positions and inversion settings in the holding registers.
  • Check the watchdog timeout setting to ensure it isn’t triggering prematurely.

Notes

  • Configuration mode is only accessible during the 2-second boot window.
  • For security and reliability, avoid using Device ID 0 for normal operations.
  • Always validate CRC and frame format for successful communication.

Parts

43
QtyValueFootprintReferences
4100nCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC4, C5, C6, C7
310kResistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolderR10, R11, R12
31JDiode_SMD:D_SMAD1, D2, D3
31uCapacitor_SMD:C_1206_3216Metric_Pad1.33x1.80mm_HandSolderC8, C9, C10
322Resistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolderR4, R5, R6
3471KVaristor:RV_Disc_D9mm_W3.3mm_P5mmRV1, RV2, RV3
3680Resistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolderR7, R8, R9
3GLED_THT:LED_D3.0mmD4, D5, D6
3IRLML0030Package_TO_SOT_SMD:SOT-23Q1, Q2, Q3
3Relay_SPDTRelay_THT:Relay_SPDT_Omron_G2RL-1-EK1, K2, K3
210uCapacitor_Tantalum_SMD:CP_EIA-6032-28_Kemet-CC1, C2
14u7Capacitor_SMD:C_1206_3216Metric_Pad1.33x1.80mm_HandSolderC3
162RAdarwoo:Murata_NFM61RFL1
1ATtiny824-SSPackage_SO:SOIC-14_3.9x8.7mm_P1.27mmU2
1AVR-UPDI-6Connector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_VerticalJ3
1LM1117MP-5.0Package_TO_SOT_SMD:SOT-223-3_TabPin2U1
1LOGOLOGOG***
1LT1785AxS8Package_SO:SOIC-8_3.9x4.9mm_P1.27mmU3
1Screw_Terminal_01x02Connector_Phoenix_MC:PhoenixContact_MCV_1,5_2-G-3.81_1x02_P3.81mm_VerticalJ5
1Screw_Terminal_01x03Connector_Phoenix_MC:PhoenixContact_MCV_1,5_3-G-3.81_1x03_P3.81mm_VerticalJ4
1~TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-4_1x04_P5.00mm_HorizontalJ2

Similar boards

  • 2 layers65 × 56 mmPiswitcher plus board, the printed circuit board in 3D

    Piswitcher plus board

    FibStack/pi-switcher-plus

    The FibStack PiSwitcher Plus board was designed to help you in your next automation project.

    48 parts
  • 2 layers60 × 99.6 mm9-firefly badge, the printed circuit board in 3D

    9-firefly badge

    lepi-labs/9-firefly-badge

    Firefly jar PCB badge

    22 parts
  • 4 layers126.6 × 37.7 mmGruzik2.0, the printed circuit board in 3D

    Gruzik2.0

    NYDEREK/LineFollower_GRUZIK2.0-light

    GRUZIK2.0 is simple light construction made for "line follower light" competition

    50 parts101MIT
  • 2 layers20 × 107 mmRawWavesV2, the printed circuit board in 3D

    RawWavesV2

    SherpaModular/RawWaves

    Raw Waves is a eurorack synthesizer module that plays RAW or WAV sample files from a micro SDcard. It is a derivate work of "Radio Music" from Tom Whitwell. Raw Waves is released under a CC-by-SA 3.0 license.

    55 parts26
  • 2 layers44.4 × 29.3 mmElectronicTriggerUnit, the printed circuit board in 3D

    ElectronicTriggerUnit

    aNThiCu/AirsoftETU

    The code for a airsoft MOSFET board that includes the trigger , active break mode and semi-auto,full-auto detection.

    36 parts8GPL-3.0
  • 2 layers55.2 × 43.8 mmEncabulator, the printed circuit board in 3D

    Encabulator

    imad-drs/mini_encabulator_PCB

    A complete PCB design exercise demonstrating schematic capture, component selection, and board layout using KiCAD. This project implements a simple LED blinker with user-controllable blink rate.

    17 parts3
  • 4 layers75.5 × 62 mmBspd, the printed circuit board in 3D

    Bspd

    chithigun23/ANUFS-BSPD-2026

    ANUFS's BSPD for 2026 Formula SAE ICE Car. The goal of this project is to be AEC-Q100/Q101/Q200 compliant.

    120 parts1
  • 2 layers51 × 51 mmSuperGauge, the printed circuit board in 3D

    SuperGauge

    KenwoodFox/SuperGauge

    This repo contains all the firmware and hardware for the SuperGauge.

    32 parts1

Questions

How big is the Relay PCB?

It measures 45 × 72 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Relay use?

43 parts, built around the ATTINY824-SSU, LM1117MP-5.0 and IRLML0030. 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 Relay KiCad files?

From the adarwoo/modbus_relay repository on GitHub, at the commit this page was made from: the board is hw/relay.kicad_pcb and its schematic hw/relay.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Relay design in my own project?

Its repository states no licence, so its author keeps all rights: ask adarwoo before reusing the design.