-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand uart invert feature to ESP8266 #1727
Conversation
Hey there @esphome/core, mind taking a look at this pull request as its been labeled with an integration ( |
746cc00
to
4b8553a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM docs too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait... why is there even an invert
option?
Invert should already be possible just by using the invert:
property of the tx_pin
/rx_pin
(or if not, then that mechanism should be used for inverting line levels).
4b8553a
to
1112ac8
Compare
we should then rollback |
First of all, thanks for your great work Otto (& others)! |
Adding the invert option to pin might take the feature just working (at least on the software serial tx) so I believe Otto's idea is the way to go. May be we can fix this pr to do that and then the esp32 fix in another pr. Sounds good? |
c9741fa
to
f3904cc
Compare
Updated to use the pin scheme as requested by Otto. This indeed seems a more natural way of handeling things. Right now it is not yet supported to only invert RX or TX on the ESP32, but this should be an edge case anyway. Let me know what you think. |
10f6e31
to
e513c55
Compare
Updated for backward compatibility, I'm not sure if this is the correct way of handling it, I'm open to suggestions. |
No, just do the cv.Invalid and deprecate the option right away. It's just a configuration change. |
e513c55
to
9747ee5
Compare
Updated |
9747ee5
to
c4a0c81
Compare
c4a0c81
to
a94ad2a
Compare
a94ad2a
to
6c166d0
Compare
Any progress because with the current uart component only esp32 has invert. Would be nice if esp8266 has also the possibility for hardware invert when using DSMR ( which needs inverted RX) |
One problem with that is that we are seeing that DSMR with software UART can be very unstable, up to the level that not a single telegram can be read successfully because of missing or garbled bytes. |
I also needed this for DSMR, and it has been running since the opening of this PR without issues, so the HW invert definitly works. |
@Lewn think you can update the branch/PR to be ready for beta release tomorrow? |
60f43f5
to
ae105db
Compare
Updated the code, it should work now, but I cannot test it on my physical setup right now. Please review with care before merging. For reference, the branch that ran successfully for months on my DSMR node: https://github.com/Lewn/esphome/tree/UART-invert-refactor |
Using your UART-invert-for-esp8266 branch as an external component I can confirm a succesful compile. |
This PR looks like it would solve feature request: #1727 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that this has been such a bumpy ride and that I'm having even more comments now, but given the importance of the UART component, I'd like to get this right.
Is there anyone that can test the software serial?
ae105db
to
e4fff2e
Compare
Reverted the softwareserial changes, as they are already working today, rebased to dev. |
What does this implement/fix?
Expands theinvert
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 ofinvert
andtx_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
Related issue or feature (if applicable): N/A
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#1117
Test Environment
Example entry for
config.yaml
: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:
tests/
folder).If user exposed functionality or configuration variables are added/changed: