Using Arduino Modbus RTU libraries for ESP32

Hello everyone, I need your help, please.
I need to implement the circuit in the drawing below and intend to use the Arduino ModbusRTUMaster and ModbusRTUSlave libraries. I would like to know if these libraries can be used with the ESP32?

As your topic does not relate directly to the installation or operation of the IDE it has been moved to a more relevant category of the forum

I can recommend this for esp32:

Your slaves are not esp32, so find some library compatible with the MCU you use.

Thanks Kmin, I will study the suggestion for sure.

sorry, I'm a little lost here...

Gives compatibility with nano every, so it should fit here.

Hello everyone. Thanks for your help.
I'd like to know if you know any examples for this application. The Github examples aren't helping me much. I have a very tight three-day deadline to get this working for a demo at a trade show, and I'm getting worried. Any help would be appreciated.

What application? Only thing we know is that you are looking for compatible libraries for some devices based on Esp32 and ATMEGA4809.

Thank you Kmin,

I'm referring to this application.

I obviously have seen it. If that's all you can tell about your application, you support here will be very limited. Should we try to guess what you are willing to accomplish?

The purpose is to control and monitor MCC drawers.
Each drawer has a device that measures temperature and another that controls two motors. The electronic boards that control the motors have odd-numbered addresses, and the electronic boards that measure cable temperatures have even-numbered addresses.
A main board must control and monitor the remote boards via the Modbus network.

So are the slaves existing devices or you are asked to build them?

I must provide both Master and Slave boards.

They're already assembled and working. All I need to do is connect them together and create the communication codes for each Master/Slave model.

So you need to configure write single coils and read holding registers.
Slave library example has them both.

Master library half duplex example has single coil write and readInputRegisters, which you can modify to readHoldingRegisters.

You don't want to use Esp32 RXD0/TXD0 for rs485, use GPIO16/17 instead (Serial2).

I am using RXD0 and TXD0 of the ESP32 for RS-485 communication (and I'm a little scared about it), in addition to pin 21 to enable the RS-485 chip.

By the way thanks for your help.

Since it's the USB uart, how are you planning to interface with Esp32?

I’ll be using Bluetooth to control and monitor the system

Ahh.. And to upload code? OTA?

OTA No. I will be uploading via the USB port

Ok,you can disconnect rs485-serial line when uploading. But it would be much easier to use Serial2 for rs485