DaveTiff
(Dave T)
March 25, 2021, 9:13pm
1
Hi
The UART Pin normally sits Hi, and goes low when data is sent. Can this be inverted.
If so, what is the syntax?
Regards, Dave
sender
March 26, 2021, 6:37am
2
I think not atm in software. But there seems to be an update coming…
esphome:dev
← needspeed:feature/uart_invert_option
opened 10:46AM - 05 Mar 21 UTC
DaveTiff
(Dave T)
March 26, 2021, 9:20am
3
Thanks, I am using a ESP8266 so might have to do it in hardware this time.
But will keep an eye on this topic.
Thanks for the reply, Regards, Dave
jo-bru
August 30, 2022, 10:25am
4
Quick update:
This seems to be implemented now also for ESP8266:
esphome:dev
← Lewn:UART-invert-for-esp8266
opened 06:59PM - 26 Apr 21 UTC
# What does this implement/fix?
~Expands the ``invert`` option added for the… ESP32 in #1586 to the ESP8266.~
Changes the ``invert`` option from #1586 to use the more idiomatic configuration using the full pin scheme. It also implements this feature for the ESP8266.
~As the esp8266 arduino library only implements this for UART0, a combination of ``invert`` and ``tx_pin: GPIO2`` will fall back to using software UART.~
To also support different pin combinations, a the inverting behaviour is also implemented for ``ESP8266SoftwareSerial``.
## Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [X] Configuration change (this will require users to update their yaml configuration files to keep working) (on request of Otto, see below)
**Related issue or feature (if applicable):** N/A
**Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#1117
# Test Environment
- [ ] ESP32
- [X] ESP8266
- [ ] Windows
- [ ] Mac OS
- [X] Linux (Home Assistant on Home Assistant OS)
- [X] ADALM2000 logic analyzer/signal generator to verify incoming and outgoing signals
## Example entry for `config.yaml`:
<!--
Supplying a configuration snippet, makes it easier for a maintainer to test
your PR. Furthermore, for new integrations, it gives an impression of how
the configuration would look like.
Note: Remove this section if this PR does not have an example entry.
-->
```yaml
# Example config.yaml
uart:
# UART0
- id: uart0
tx_pin:
number: GPIO1
inverted: yes
rx_pin: GPIO3
baud_rate: 115200
- id: not_uart1
tx_pin:
# SoftwareSerial
- id: sw
tx_pin: GPIO5
rx_pin:
number: GPIO4
inverted: yes
baud_rate: 115200
```
# Explain your changes
I needed to communicate over inverted lines, and this was only supported for the ESP32, I decided to implement it for the ESP8266 for my own needs. I think it might benefit others as well.
## Checklist:
- [X] The code change is tested and works locally.
- [X] Tests have been added to verify that the new code works (under `tests/` folder).
If user exposed functionality or configuration variables are added/changed:
- [X] Documentation added/updated in [esphome-docs](https://github.com/esphome/esphome-docs).
A short check showed that it works, but I can’t get the UART RX pin to be inverted properly.
The RX idle voltage level is still on 3.3V…
Connecting TX directly to RX works, but when I use an external source I get the following voltage levels: logic 0: ~3V, logic 1: ~6V.
I’m doing these tests with a Wemos D1 mini (ESP8266).
Has anyone had the same issue?