CE039 RS232 Relay Board: Complete Hex Command Guide with Python Examples and Response Frames

Control 4 independent relay channels from a PC, Python application or embedded system using real hexadecimal commands.

The Eletechsup CE039 is a 4-channel RS232 relay control board designed for computer-controlled switching, laboratory automation, electronics testing and remote equipment control.

For developers, the most important feature is its straightforward serial command protocol. Instead of manually switching relays, software can send an 8-byte hexadecimal command, receive a response frame and verify the reported relay state.

This tutorial covers the actual CE039 command examples published by Eletechsup, including relay ON/OFF commands, all four channels, response frames, status queries and a Python implementation.

Official product page:
https://eletechsup.com/products/ce039-dc-12v-4ch-rs232-relay-board-scm-pc-usb-uart-db9-remote-control-switch-plc-motor

Official technical FAQ:
https://eletechsup.com/blogs/news/ce039-faq

1. CE039 Hardware and Communication Specifications

Parameter Specification
Model Eletechsup CE039
Relay channels 4
Communication interface RS232 serial
Default baud rate 9600 bps
Data bits 8
Parity None
Stop bits 1
Data frame length 8 bytes
Board power supply DC 12V, specified range 8.5–13.5V
Relay contacts COM, NO and NC for each channel
Indication Power LED and relay status LEDs
Board dimensions 90 × 47 × 19 mm

Each relay provides a changeover contact. When activated, COM connects to NO; when deactivated, COM disconnects from NO and connects to NC.

The CE039 requires its own specified DC power supply. The voltage switched by its relay contacts is a separate circuit and must remain within the applicable contact ratings.

2. Connect the CE039 to Your PC

A typical setup is:

PC or laptop → USB-to-RS232 adapter → CE039 → external circuit

If your computer does not have a native RS232 port, use a compatible USB-to-RS232 adapter. Do not confuse an RS232 adapter with a TTL UART adapter: their electrical signal levels are different.

Configure the serial terminal as follows:

  • Baud rate: 9600

  • Data bits: 8

  • Parity: None

  • Stop bits: 1

  • Command format: Raw hexadecimal bytes

  • Command length: 8 bytes

Important: Enter the command as binary bytes, not as ASCII characters representing hexadecimal digits. For example, the hex string 55 56 must be transmitted as two bytes, 0x55 and 0x56, rather than four ASCII characters.

No additional carriage return or line feed is specified in the published 8-byte command examples.

3. Understanding the CE039 Command Frame

A typical relay-control command has this structure:

Byte position Example Meaning
1 55 Command-frame header
2 56 Command-frame header
3–5 00 00 00 Reserved fields in the published examples
6 01 Channel number
7 01 Operation code
8 AD Checksum byte in this example

For the published examples, the last byte is consistent with the low 8 bits of the sum of the preceding seven bytes.

For example:

55 + 56 + 01 + 01 = 0xAD

The reserved zero bytes do not change the sum.

Use the manufacturer's documented frame structure when constructing commands; do not assume this protocol is compatible with other serial relay boards merely because they also use eight-byte frames.

4. Actual Hexadecimal Commands for All Four Channels

The following command bytes are published in the official Eletechsup CE039 product documentation.

4.1 Turn a Relay ON

Operation code: 01

This activates the relay, connecting COM to NO.

Channel Command (HEX)
Relay 1 55 56 00 00 00 01 01 AD
Relay 2 55 56 00 00 00 02 01 AE
Relay 3 55 56 00 00 00 03 01 AF
Relay 4 55 56 00 00 00 04 01 B0

4.2 Turn a Relay OFF

Operation code: 02

This deactivates the relay, disconnecting COM from NO and connecting COM to NC.

Channel Command (HEX)
Relay 1 55 56 00 00 00 01 02 AE
Relay 2 55 56 00 00 00 02 02 AF
Relay 3 55 56 00 00 00 03 02 B0
Relay 4 55 56 00 00 00 04 02 B1

4.3 Toggle a Relay

Operation code: 03

Toggle reverses the relay's current state.

Channel Command (HEX)
Relay 1 55 56 00 00 00 01 03 AF
Relay 2 55 56 00 00 00 02 03 B0
Relay 3 55 56 00 00 00 03 03 B1
Relay 4 55 56 00 00 00 04 03 B2

Toggle is useful for a manual ON/OFF button, but an explicit ON or OFF command is generally preferable when a program needs a predictable target state.

4.4 Momentary Relay Operation

Operation code: 04

The published protocol describes this as connecting COM to NO and disconnecting it again after approximately 200 ms.

Channel Command (HEX)
Relay 1 55 56 00 00 00 01 04 B0
Relay 2 55 56 00 00 00 02 04 B1
Relay 3 55 56 00 00 00 03 04 B2
Relay 4 55 56 00 00 00 04 04 B3

This function can be useful for applications that require a short switching pulse, such as triggering a compatible test input or simulating a button press. Verify the target equipment's requirements before use.

4.5 Interlock Operation

Operation code: 05

The published command examples are:

Channel Command (HEX)
Relay 1 55 56 00 00 00 01 05 B1
Relay 2 55 56 00 00 00 02 05 B2
Relay 3 55 56 00 00 00 03 05 B3
Relay 4 55 56 00 00 00 04 05 B4

Interlock is intended for applications requiring mutually exclusive relay operation. Confirm the precise behavior and channel interaction with the product documentation before using it in an actual control circuit.

5. Actual Response Frames: How to Confirm Relay Status

The CE039 documentation publishes response frames beginning with 33 3C. The seventh byte identifies the reported relay state in the documented response examples.

5.1 Response When a Relay Is ON

The response operation/status byte is 01.

Channel Response (HEX)
Relay 1 33 3C 00 00 00 01 01 71
Relay 2 33 3C 00 00 00 02 01 72
Relay 3 33 3C 00 00 00 03 01 73
Relay 4 33 3C 00 00 00 04 01 74

5.2 Response When a Relay Is OFF

The response operation/status byte is 02.

Channel Response (HEX)
Relay 1 33 3C 00 00 00 01 02 72
Relay 2 33 3C 00 00 00 02 02 73
Relay 3 33 3C 00 00 00 03 02 74
Relay 4 33 3C 00 00 00 04 02 75

5.3 Example: Switch Relay 1 ON and Read the Response

Send:

55 56 00 00 00 01 01 AD

The documented ON response for Relay 1 is:

33 3C 00 00 00 01 01 71

A host application can check the response header, channel number, status byte and frame checksum before treating the response as valid.

A received response confirms the module's reported relay state. It does not independently prove that the external load is receiving power or operating correctly; that may require additional electrical feedback.

6. Read Relay Status

The official CE039 documentation lists this command for reading relay status:

55 56 00 00 00 00 00 AB

This is the published status-query command. The product documentation also describes the response format and relay-state byte.

Do not confuse this query with the individual channel ON/OFF commands. If you need to determine the state of each channel, parse the returned frame according to the manufacturer's protocol documentation rather than assuming a response layout that has not been verified.

7. Python Example: Control the CE039 Using Real Commands

Install the Python serial library:

pip install pyserial

The following example uses the actual published ON and OFF command bytes for all four channels.

import serial
import time

PORT = "COM3"  # Change to your actual port

relay_on = {
    1: bytes.fromhex("55 56 00 00 00 01 01 AD"),
    2: bytes.fromhex("55 56 00 00 00 02 01 AE"),
    3: bytes.fromhex("55 56 00 00 00 03 01 AF"),
    4: bytes.fromhex("55 56 00 00 00 04 01 B0"),
}

relay_off = {
    1: bytes.fromhex("55 56 00 00 00 01 02 AE"),
    2: bytes.fromhex("55 56 00 00 00 02 02 AF"),
    3: bytes.fromhex("55 56 00 00 00 03 02 B0"),
    4: bytes.fromhex("55 56 00 00 00 04 02 B1"),
}

def send_command(ser, command):
    ser.reset_input_buffer()
    ser.write(command)
    ser.flush()

    # The documented response is an 8-byte frame.
    response = ser.read(8)
    print("TX:", command.hex(" ").upper())
    print("RX:", response.hex(" ").upper())

    if len(response) != 8:
        print("Warning: incomplete response or serial timeout")
        return response

    # Validate the published response header and checksum.
    expected_checksum = sum(response[:7]) & 0xFF

    if response[:2] != bytes.fromhex("33 3C"):
        print("Warning: unexpected response header")
    elif response[7] != expected_checksum:
        print("Warning: response checksum mismatch")
    else:
        print("Response frame format and checksum: OK")

    return response

with serial.Serial(
    port=PORT,
    baudrate=9600,
    bytesize=serial.EIGHTBITS,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    timeout=1
) as ser:

    # Turn Relay 1 ON.
    send_command(ser, relay_on[1])
    time.sleep(0.2)

    # Turn Relay 1 OFF.
    send_command(ser, relay_off[1])

Before running: Set PORT to the correct serial port and connect the CE039 using a compatible RS232 interface. The program assumes an eight-byte response arrives within the configured timeout. If your application needs robust operation, add frame buffering, response validation, retries and handling for unexpected or delayed responses.

The example validates the documented response header and checksum. For an application that must verify a specific channel's state, also check that the returned channel number and state byte match the command you sent.

8. Practical Applications

PC-Based Automated Testing

A test program can switch a device's power or reset circuit, wait for a measurement, record the result and proceed to the next test stage.

Remote Equipment Switching

Use a serial command to operate a compatible electrical load from a computer. This can be useful for laboratory equipment and non-safety-critical equipment management.

Electronics Development

Switch selected circuits during prototype evaluation, production testing or repeated experiments without manually operating a switch.

Embedded Control

A controller with a suitable RS232 interface can send the same command frames from embedded software, making the CE039 a practical option for custom control projects.

Button and Trigger Simulation

The documented momentary function can provide a short relay pulse to a compatible external input. Confirm the input's electrical and timing requirements before implementation.

9. Common Troubleshooting Questions

Why does the relay not respond?

Check the DC 12V supply, serial port selection, RS232 electrical interface, wiring and 9600 8N1 settings. Make sure your program sends raw bytes rather than ASCII characters.

Why does the command appear correct but the response is missing?

Verify the command length, channel number, operation code and checksum. Also check that the adapter is compatible and that the application is reading the response correctly.

Can the CE039 be controlled by Python?

Yes. A Python program can send the documented eight-byte command frames through a serial port using pyserial.

Can the relay switch a different voltage from the board's supply voltage?

The relay contacts are electrically separate from the board's DC 12V supply, but the external circuit must remain within the relay contact ratings. Inductive loads may require additional suppression.

Does a response guarantee that the external equipment is working?

No. A valid response indicates the module's reported relay state. Additional feedback may be necessary to verify the condition of the external circuit or equipment.

10. Conclusion

The Eletechsup CE039 makes it possible to control four relay channels through a simple serial interface. Its documented eight-byte hexadecimal commands support ON, OFF, toggle, momentary and interlock operations, while the response frames allow software to inspect the reported relay state.

By combining the CE039 with a compatible RS232 interface and a small Python application, developers can build computer-controlled switching systems for test equipment, laboratory experiments and general-purpose automation.

Explore the Eletechsup CE039 4-Channel RS232 Relay Board:
https://eletechsup.com/products/ce039-dc-12v-4ch-rs232-relay-board-scm-pc-usb-uart-db9-remote-control-switch-plc-motor

#Eletechsup #CE039 #RS232 #RelayBoard #HexCommands #Python #PySerial #SerialCommunication #AutomatedTesting #PCControlledRelay #EmbeddedSystems #ElectronicsEngineering #RemoteSwitching #HardwareIntegration

Back to blog

Leave a comment