English
English
简体中文
日本語
pdf-icon

StamPLC Home Assistant Integration

This chapter describes how to integrate the IoT programmable logic controller StamPLC into Home Assistant.

Note
Special thanks to ESPHome community contributor @Beormund for providing the configuration file. For more references, visit https://github.com/Beormund/esphome-m5stamplc.

Preparation

Note

  • In this tutorial, the kit was compiled and uploaded under ESPHome 2025.10.3. If you encounter compilation/upload issues, consider switching ESPHome to this version.

Create Device

  1. Open ESPHome Builder in Home Assistant and create an empty configuration file.

    • Click the NEW DEVICE button in the bottom right corner.

    • Click CONTINUE in the pop-up box.

    • Select Empty Configuration.

    • Name the file (Optional).

    • Click EDIT on the newly generated configuration file.

  2. Copy the contents of configurations.yaml into the configuration file.

  3. Change network configuration or API information as needed, such as creating an API Encryption Key for authentication:

yaml
1 2 3
api:
  encryption:
    key: "Your_Encryption_Key"
Tip
If you need a Key, visit native api to generate one (under encryption).

Or change the timezone settings:

yaml
1
timezone: Europe/London

Change to the appropriate timezone:

yaml
1
timezone: Asia/Shanghai
  1. Click SAVE and INSTALL in the top right corner in sequence, then select Manual download.

The code will be generated and the project will be compiled.

Tip
If it's the first time compiling, it may take a long time; this depends on the performance of the Home Assistant host and network connection.
  1. When compilation is complete, select Factory format to download the firmware.

Download and Flash Firmware

  1. Download firmware: Download the Factory Format firmware via the Manual download method in ESPHome Builder.

  2. Flash firmware using web tools:

    • Open a browser and visit ESPHome Web to upload the firmware.

    • Connect StamPLC to the host using a USB-C cable, click CONNECT, and select the device connection.

    • Click INSTALL, select the previously downloaded firmware to upload, then click INSTALL again to flash the firmware to the device.

    • When flashing is complete, the device will automatically reset.

Getting Started

Add Device to Home Assistant Integration

  1. When the device restarts, it will automatically connect to the previously configured network. Under normal circumstances, the device can be discovered in Settings -> Devices & services.

  2. Click Add to integrate StamPLC into Home Assistant. If an API Encryption Key was previously set, you may need to enter it here for verification. StamPLC Dashboard Example:

  3. Physical Operation:

Expansion

StamPLC supports expansion, allowing other expansions to be connected via the 16-pin header on the right side.

StamPLC AC

  1. Product Introduction:

    StamPLC AC is an AC relay expansion module tailored for the StamPLC host. The module integrates AC load control and power supply for the entire machine, effectively simplifying the power wiring for applications. It uses contact relays (SPST - Normally Open), supporting line on/off up to AC 240V@10A. It has a built-in AC-DC isolated conversion circuit, supporting AC 100 ~ 240V input, which can power the relay load while outputting DC 12V to power the entire machine. Onboard programmable tri-color LED for status indication. The StamPLC main controller programs and controls the relays and RGB LED via an I2C IO expansion chip, effectively saving IO resources. Suitable for industrial application scenarios such as AC load equipment switches and solenoid valve control.

  2. Configure StamPLC AC: Based on the previous StamPLC configuration, some components need to be added to the YAML configuration:

    • Add new IO Expander:

      pi4ioe5v6408:
        - id: pi4ioe5v6408_1
          address: 0x43
        # Configuration of i2c GPIO Expander 2
        # on the StamPLC AC expansion
        - id: pi4ioe5v6408_2
          address: 0x44
    • Add new AC Relay switch:

      switch:
        ...
        - platform: gpio
          restore_mode: RESTORE_DEFAULT_OFF
          name: "StamPLC AC Relay"
          id: ac_r1
          pin:
            pi4ioe5v6408: pi4ioe5v6408_2
            number: 2
            mode:
              output: true
          on_state:
            - component.update: vdu
    • Add new LED color control on top of AC Relay:

      switch:
        ...
        # led indicator on StamPLC AC expansion
        - platform: gpio
          restore_mode: ALWAYS_OFF
          id: "ac_relay_led_red"
          pin:
            pi4ioe5v6408: pi4ioe5v6408_2
            number: 5
            inverted: true
            mode:
              output: true
      
        - platform: gpio
          restore_mode: ALWAYS_OFF
          id: "ac_relay_led_green"
          pin:
            pi4ioe5v6408: pi4ioe5v6408_2
            number: 6
            inverted: true
            mode:
              output: true
      
        - platform: gpio
          restore_mode: ALWAYS_OFF
          id: "ac_relay_led_blue"
          pin:
            pi4ioe5v6408: pi4ioe5v6408_2
            number: 7
            inverted: true
            mode:
              output: true
    • Add new AC Relay UI for the Display component:

      display:
        ...
        lambda: |-
          ...
          it.print(5, 80, id(font1), Color(orange), "Relays 1-4");
          it.filled_rectangle(5, 99, 25, 25, id(r1).state ? id(red) : id(grey));
          it.filled_rectangle(34, 99, 25, 25, id(r2).state ? id(red) : id(grey));
          it.filled_rectangle(63, 99, 25, 25, id(r3).state ? id(red) : id(grey));
          it.filled_rectangle(92, 99, 25, 25, id(r4).state ? id(red) : id(grey));
          it.print(141, 80, id(font1), Color(orange), "AC Expansion");    // The AC Relay Expansion
          it.filled_rectangle(141, 99, 25, 25, id(ac_r1).state ? id(red) : id(grey));
        ...
  3. After completing the configuration, recompile and upload the firmware. Add the device to Home Assistant to control the AC Relay via the additional switch.

  4. Turning the switch on and off will change the LCD status synchronously.

StamPLC PoE

  1. Product Introduction:

    StamPLC PoE is an Ethernet control module for the StamPLC host, supporting PoE (Power over Ethernet) technology, which allows simultaneous data transmission and power supply through a single network cable. The module has a built-in W5500 embedded Ethernet controller, integrating the TCP/IP protocol stack, with 8 independent hardware sockets, 10/100M Ethernet Data Link Layer (MAC), and Physical Layer (PHY), supporting mainstream network communication methods such as UDP and TCP.

  2. Configure StamPLC PoE:

Compatibility Warning
Since the PoE (W5500 Ethernet) component occupies SPI hardware resources separately, the LCD Display and PoE will use the same set of SPI pins, and defining both will cause a conflict. Therefore, physically, you must choose between PoE and Display functionality.
In network components, the 'wifi' component and 'ethernet' component are mutually exclusive options; you can only choose one.

To use the PoE function, you need to disable the wifi, display, and spi components (delete related declarations/definitions in the configuration file), then add to the original configuration file:

ethernet:
  id: ethernet_1
  type: W5500
  clk_pin: GPIO7
  mosi_pin: GPIO8
  miso_pin: GPIO9
  cs_pin: GPIO11
  clock_speed: 20MHz
  1. Save and recompile, upload the project. Use a PoE switch or router to provide power and network to the device.

Video

On This Page