Hi, I have a question, so I have two identical devices that I would like to communicate via RX / TX (RS485). Both devices are exactly the same component, but as far as I know this is half-duplex mode, which means the first device sends, the second device receives and then again the second device receives and the first device sends. I have no idea how to write code for this communication. I found here as far as this chip is concerned https://github.com/nopnop2002/SC16IS752 also tried to load on both devices example code https://github.com/nopnop2002/SC16IS752 ... 2C_RECEIVE but nothing works. Some ideas?
RS485 ESP32 half-duplex communication
-
- Posts: 9770
- Joined: Thu Nov 26, 2015 4:08 am
Re: RS485 ESP32 half-duplex communication
Did you look at the examples included in esp-idf already?
Re: RS485 ESP32 half-duplex communication
What about components which I use, should I also define them somehow? Uart expander (SC16IS752IPW) and RS485 (SN65HVD72D)?ESP_Sprite wrote: ↑Tue Dec 21, 2021 1:41 amDid you look at the examples included in esp-idf already?
-
- Posts: 9770
- Joined: Thu Nov 26, 2015 4:08 am
Re: RS485 ESP32 half-duplex communication
The RS485 chip is transparent; it should just work with the example to my knowledge. I don't think we have specific code for the UART expander chip you're using.
EDIT: Ah, the ESP32 is connected via SPI to the SC16IS752IPW, which is then connected to the RS485 chip? Sorry, then the example is useless (as it assumes you use the ESP32s internal UARTS) and we don't have a driver for the SC16IS752IPW (it seems like a fairly obscure chip)
Why don't you nix the SC16IS752IPW and simply connect the SN65HVD72D chip directly to the ESP32? The ESP32 has 3 UARTs, it's not like you're lacking that.
EDIT: Ah, the ESP32 is connected via SPI to the SC16IS752IPW, which is then connected to the RS485 chip? Sorry, then the example is useless (as it assumes you use the ESP32s internal UARTS) and we don't have a driver for the SC16IS752IPW (it seems like a fairly obscure chip)
Why don't you nix the SC16IS752IPW and simply connect the SN65HVD72D chip directly to the ESP32? The ESP32 has 3 UARTs, it's not like you're lacking that.
Re: RS485 ESP32 half-duplex communication
After hours of reading I understand I need to set pin to low/high when receiving or transmiting. So I need to set pins (basically one pin for both on RS485 component DE & !RE) to high/low. Those pin is in my case connected to RTSA pin of UART which should do this job automatically based on datasheet, do I need to enable somehow auto RTS? In datasheet it says:
This pin only affects the transmit and receive operations when Auto-RTS function is enabled via the Enhanced Features Register (EFR[6]) for hardware flow control operation.
Would be better in my case if I use some of free GPIO pins from UART and manually changing pin to low/high?
This pin only affects the transmit and receive operations when Auto-RTS function is enabled via the Enhanced Features Register (EFR[6]) for hardware flow control operation.
Would be better in my case if I use some of free GPIO pins from UART and manually changing pin to low/high?
Who is online
Users browsing this forum: No registered users and 46 guests