j0ta29 / esphome

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
https://esphome.io/
Other
6 stars 2 forks source link

8266 uart_swap #11

Open rorso opened 4 months ago

rorso commented 4 months ago

Thank you for your code adaption. I tried as you suggested with the following configuration.

esphome:
  name: esphome-web-fcaf73
  friendly_name: esphome-web-fcaf73

esp8266:
  board: esp_wroom_02

# Enable logging
logger:
  hardware_uart: UART1
  baud_rate: 0
  level: DEBUG

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

ota:
  password: "fe027c2092664e42861b2890f8788a2f"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-Fcaf73"
    password: "--------------------"

captive_portal:

external_components:
  - source:
      type: git
      url: https://github.com/j0ta29/esphome
      ref: uart_swap
    components: [ optolink ]

optolink:
  protocol: P300
  tx_pin: GPIO15
  rx_pin: GPIO13
  logger: enable             # wenn später alles rund läuft, wieder entfernen 

text_sensor:
  - platform: optolink
    name: device_info
    mode: DEVICE_INFO

  - platform: optolink
    name: state
    mode: STATE_INFO

I was allowed to configure the alternate GPIO pins - and just these. Others are rejected.

But the running code still sends on the tx and not on the GPIO15 pin.

j0ta29 commented 4 months ago

But the running code still sends on the tx and not on the GPIO15 pin

Did you mean "...sends on the GPIO1 and not..."?

rorso commented 4 months ago

Did you mean "...sends on the GPIO1 and not..."?

Yes, it still communicates on the original pins, as if I had not tried to swap them. The parameters are accepted, but do not show any effect.

j0ta29 commented 4 months ago

Strange! I'm using the library VitoWifi for communication with the Optolink interface. For ESP8266 VitoWifi only accepts the Serial object of the Arduino platform. I have not yet investigated if the library initializes pin configuration (beside baud rate etc.) As it's not easy for me to test whether swapping pins works (everything is soldered), you can play around modifying the Serial object by using on_boot (https://esphome.io/components/esphome#on-boot).

Example:

esphome:
  ...
  on_boot:
    - lambda: Serial.swap();  

For more information about the Serial object see https://arduino-esp8266.readthedocs.io/en/latest/reference.html#serial