Craftiarenko
Published © GPL3+

Building a Wired Smart Workshop with ESPHome and Ethernet

A wired automation system using ESPHome, Home Assistant and DFRobot sensors for reliable lighting and CO2-based ventilation.

IntermediateFull instructions provided3 hours74
Building a Wired Smart Workshop with ESPHome and Ethernet

Things used in this project

Hardware components

Fermion: C4002 mmWave Human Presence Sensor - Static & Motion Detection for Home Assistant (10m)
DFRobot Fermion: C4002 mmWave Human Presence Sensor - Static & Motion Detection for Home Assistant (10m)
×1
DFRobot Gravity STCC4 CO2 sensor
×1
WT32-ETH01
×1
AC-DC 5W 5V 1A
×1
DT-R008
×1
HDR-30-12
×1

Software apps and online services

Home Assistant
Home Assistant

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Custom parts and enclosures

Sensor Cover

Cover for STCC4 sensor

Sensor Panel

Panel for placing the STCC4 sensor and the C4002 sensor

Schematics

Relay schematic

General diagram of the electrical panel

Sensor schematic

Wiring diagram for C4002, STCC4, WT32-ETH01

Code

ESPHome Sensors Configuration

YAML
Configuration file for ESPHome using C4002 and STCC4 sensors with WT32-ETH01 board
esphome:
  name: workshop-eth-sensors
  friendly_name: workshop-eth-sensors

esp32:
  board: wt32-eth01
  framework:
    type: esp-idf

external_components:
  - source: github://pr#14037
  # - source:
  #     type: git
  #     url: https://github.com/uncle-yura/esphome-stcc4
  #     ref: main
    components: [stcc4]
    
  - source:
      type: git
      url: https://github.com/uncle-yura/esphome-c4002
      ref: main
    components: [ c4002 ]
    
# Enable logging
logger:
  level: INFO

# Enable Home Assistant API
api:
  encryption:
    key: "your-encryption-key"

ota:
  - platform: esphome
    password: "your ota password"

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk:
    pin: GPIO0
    mode: CLK_EXT_IN
  phy_addr: 1
  power_pin: GPIO16

i2c:
  sda: GPIO15
  scl: GPIO14
  scan: true
  id: bus_a
  frequency: 10kHz

uart:
  id: uart_bus
  tx_pin: GPIO17
  rx_pin: GPIO05
  baud_rate: 115200
  
c4002:
  id: my_c4002
  
binary_sensor:
  - platform: c4002
    c4002_id: my_c4002
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target
  
sensor:
  - platform: stcc4
    co2:
      name: "CO2 Concentration"
    temperature:
      name: "Temperature"
      filters:
        - calibrate_linear:
            method: least_squares
            datapoints:
              - 14.7 -> 11
              - 16.5 -> 12
              - 17.5 -> 13
              - 18.1 -> 14
              - 27.4 -> 23
              - 28.07 -> 26.5
    humidity:
      name: "Humidity"
    ambient_pressure_compensation: 990
    update_interval: 60s
  
  - platform: c4002
    c4002_id: my_c4002
    light:
      name: Light
    still_energy:
      name: Still Energy
    still_distance:
      name: Still Distance
    still_gate_index:
      name: Gate Index
    moving_distance:
      name: Moving Distance
    moving_energy:
      name: Moving Energy
    moving_speed:
      name: Moving Speed
      
text_sensor:
  - platform: c4002
    c4002_id: my_c4002
    message:
      name: "C4002 log"
    version:
      name: Version
    direction:
      name: Direction

button:
  - platform: restart
    name: "Restart"
  
  - platform: c4002
    restart:
      name: "Restart C4002"
    factory_reset:
      name: "Factory Reset"
    calibrate:
      name: "Calibrate"
      
switch:
  - platform: c4002
    output_led:
      name: "Output LED Switch"
    run_led:
      name: "Run LED Switch"

select:
  - platform: c4002
    c4002_id: my_c4002
    output_mode:
      name: "OUT Mode"
    distance_resolution:
      name: Distance resolution
    baud_rate:
      name: Baud Rate
      initial_value: "115200"
      restore_value: true
      
number:
  - platform: c4002
    max_distance:
      name: "Max detection distance"
    min_distance:
      name: "Min detection distance"
    light_threshold:
      name: "Light Threshold"
    timeout:
      name: "Target Disappear Delay Time"
    lock_timeout:
      name: "Lock detection timeout"

    g0:
      move_threshold:
        name: G0 move threshold
      still_threshold:
        name: G0 still threshold
    g1:
      move_threshold:
        name: G1 move threshold
      still_threshold:
        name: G1 still threshold
    g2:
      move_threshold:
        name: G2 move threshold
      still_threshold:
        name: G2 still threshold
    g3:
      move_threshold:
        name: G3 move threshold
      still_threshold:
        name: G3 still threshold
    g4:
      move_threshold:
        name: G4 move threshold
      still_threshold:
        name: G4 still threshold
    g5:
      move_threshold:
        name: G5 move threshold
      still_threshold:
        name: G5 still threshold
    g6:
      move_threshold:
        name: G6 move threshold
      still_threshold:
        name: G6 still threshold
    g7:
      move_threshold:
        name: G7 move threshold
      still_threshold:
        name: G7 still threshold
    g8:
      move_threshold:
        name: G8 move threshold
      still_threshold:
        name: G8 still threshold
    g9:
      move_threshold:
        name: G9 move threshold
      still_threshold:
        name: G9 still threshold
    g10:
      move_threshold:
        name: G10 move threshold
      still_threshold:
        name: G10 still threshold
    g11:
      move_threshold:
        name: G11 move threshold
      still_threshold:
        name: G11 still threshold
    g12:
      move_threshold:
        name: G12 move threshold
      still_threshold:
        name: G12 still threshold
    g13:
      move_threshold:
        name: G13 move threshold
      still_threshold:
        name: G13 still threshold
    g14:
      move_threshold:
        name: G14 move threshold
      still_threshold:
        name: G14 still threshold
    g15:
      move_threshold:
        name: G15 move threshold
      still_threshold:
        name: G15 still threshold
    g16:
      move_threshold:
        name: G16 move threshold
      still_threshold:
        name: G16 still threshold
    g17:
      move_threshold:
        name: G17 move threshold
      still_threshold:
        name: G17 still threshold
    g18:
      move_threshold:
        name: G18 move threshold
      still_threshold:
        name: G18 still threshold
    g19:
      move_threshold:
        name: G19 move threshold
      still_threshold:
        name: G19 still threshold
    g20:
      move_threshold:
        name: G20 move threshold
      still_threshold:
        name: G20 still threshold
    g21:
      move_threshold:
        name: G21 move threshold
      still_threshold:
        name: G21 still threshold
    g22:
      move_threshold:
        name: G22 move threshold
      still_threshold:
        name: G22 still threshold
    g23:
      move_threshold:
        name: G23 move threshold
      still_threshold:
        name: G23 still threshold
    g24:
      move_threshold:
        name: G24 move threshold
      still_threshold:
        name: G24 still threshold

esphome-plc.yaml

YAML
Configuration file for ESPHome using DT-R008 board
substitutions:
  friendly_name: workshop-plc
  
esphome:
  name: workshop-plc
  friendly_name: ${friendly_name}

esp32:
  variant: esp32
  framework:
    type: esp-idf
    advanced:
      minimum_chip_revision: "3.1"

logger:
  baud_rate: 0

api:
  encryption:
    key: "your-encryption-key"

ota:
  - platform: esphome

external_components:
  - source: github://kecajtop/dtr0xx_io@master
    refresh: 60s
    components:
      - dtr008v2io
    
ethernet:
 type: JL1101
 mdc_pin: 23
 mdio_pin: 18
 clk_mode: GPIO17_OUT
 power_pin: 0
 phy_addr: 1

uart:
  id: mod_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600
  stop_bits: 1

spi:
  - id: dtr008v2io_hub_spi
    interface: hardware
    clk_pin: GPIO14
    mosi_pin: GPIO13
    miso_pin: GPIO16
  
dtr008v2io:
  - id: dtr008v2io_hub
    oe_pin: GPIO32
    spi_id: dtr008v2io_hub_spi
    cs_pin: GPIO15

binary_sensor:
  - platform: gpio
    id: input_1
    name: ${friendly_name} Input 1
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 0
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 2
    id: input_2
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 1
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 3
    id: input_3
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 2
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 4
    id: input_4
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 3
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 5
    id: input_5
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 4
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 6
    id: input_6
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 5
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 7
    id: input_7
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 6
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

  - platform: gpio
    name: ${friendly_name} Input 8
    id: input_8
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 7
      inverted: true
      allow_other_uses: true
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

switch:
  - platform: gpio
    name: ${friendly_name} Relay 1
    id: relay_1
    restore_mode: ALWAYS_OFF
    interlock: [relay_2, relay_3]
    interlock_wait_time: 250ms
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 0
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 2
    id: relay_2
    restore_mode: ALWAYS_OFF
    interlock: [relay_1, relay_3]
    interlock_wait_time: 250ms
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 1
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 3
    id: relay_3
    restore_mode: ALWAYS_OFF
    interlock: [relay_1, relay_2]
    interlock_wait_time: 250ms
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 2
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 4
    id: relay_4
    restore_mode: ALWAYS_OFF
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 3
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 5
    id: relay_5
    restore_mode: ALWAYS_OFF
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 4
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 6
    id: relay_6
    restore_mode: ALWAYS_OFF
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 5
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 7
    id: relay_7
    restore_mode: ALWAYS_OFF
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 6
      inverted: false
      allow_other_uses: true
      
  - platform: gpio
    name: ${friendly_name} Relay 8
    id: relay_8
    restore_mode: ALWAYS_OFF
    pin:
      dtr008v2io: dtr008v2io_hub
      number: 7
      inverted: false
      allow_other_uses: true

Credits

Craftiarenko
7 projects • 13 followers
Making simple things difficult :)
Thanks to kecajtop and will-tm.

Comments