Skip to content

ESPHome components to send/receive sensor values between two ESPHome devices over UART without WIFI.

License

Notifications You must be signed in to change notification settings

KG3RK3N/esphome-uart-p2p

Repository files navigation

esphome-uart-p2p

GitHub stars GitHub forks GitHub watchers

ESPHome components to send/receive sensor values between two ESPHome devices over UART without WIFI.

Features

  • Sensor support
  • Binary sensor support
  • Text sensor support
  • CRC check
  • Value type check
  • Multi Transmitter/Receiver support for multiple UARTs (like ESP32)

Requirements

Schematics


┌──────────┐                ┌─────────┐
│          │<----- RX ----->│         │
│  ESP32   │<----- TX ----->│  ESP32  │
│          │<----- GND ---->│         │<-- 3.3V
│          │                │         │<-- GND
└──────────┘                └─────────┘

│            o GND ── GND                │
│            o TXD ── RXD (`rx_pin`)     │
│            o RXD ── TXD (`tx_pin`)     │
└─[oooooooo]─────────────────[oooooooo]──┘

For test purposes you can connect the RXD & TXD pins together of one esp and than use both components on one device.

Installation

You can install this component with ESPHome external components feature like the following examples:

Transmitter

This component send the data to another devices.

external_components:
  - source:
      url: https://github.com/KG3RK3N/esphome-uart-p2p
      type: git
    components: [uart_p2p_transmitter]

Receiver

This component receive data from a device with a transmitter.

external_components:
  - source:
      url: https://github.com/KG3RK3N/esphome-uart-p2p
      type: git
    components: [uart_p2p_receiver]

Configuration

In the following samples you can see, that each sensor has a address to assign the values to each sensor. Its necessary to have unique addresses and the sensor type needs to be the same on both sides.

    Transmitter                 Receiver

Valid:
   0x01 (number)    ------>   0x01 (number)
   0x02 (binary)    ------>   0x02 (binary)

Invalid:
   0x02 (number)    ------>   0x02 (binary)
   0x02 (binary)    ------>   0x02 (number)
   0x02 (number)    ------>   0x03 (number)

Transmitter

uart_p2p_transmitter:
  uart: uart_1
  sensors:
    - sensor_id: random_sensor_1
      address: 0x01
  binary_sensors:
    - sensor_id: binary_sensor_1
      address: 0x02
  text_sensors:
    - sensor_id: text_sensor_1
      address: 0x03

Here you can find a full sample for the transmitter.

Receiver

uart_p2p_receiver:
  uart_id: uart_1
  sensors:
    - id: random_sensor_1
      name: "Sensor address 0x01"
      unit_of_measurement: "%"
      address: 0x01
  binary_sensors:
    - id: binary_sensor_1
      name: "Binary sensor address 0x02"
      address: 0x02
  text_sensors:
    - id: text_sensor_1
      name: "Text sensor address 0x03"
      address: 0x03

Here you can find a full sample for the receiver.

More samples

Known issues

None.

Debugging

If this component doesn't work out of the box for your device please update your configuration to enable the debug output of the UART component and increase the log level to the see outgoing and incoming serial traffic:

logger:
  level: DEBUG

uart:
  id: uart_0
  baud_rate: 115200
  tx_pin: GPIO17
  rx_pin: GPIO16
  debug:
    direction: BOTH

About

ESPHome components to send/receive sensor values between two ESPHome devices over UART without WIFI.

Resources

License

Stars

Watchers

Forks