The example is for the Lilygo unit to be a MODBUS master. I need an example where the LIlygo unit is a Modbus Slave where I can set its address and have 30 or more on one RS485 comms cable. Does anyone have an example of this? Regards .. Ian
@mimorris, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem
as the modbus client (master) implementation doesn't look very special I guess you can just use "any" working Modbus Server (slave) Library which allows you to hand over a stream to the hw serial.
I am a beginner with the Arduino IDE Your comment "any" working Modbus Server (slave) Library doesn't mean much to me. I am looking/hoping for a direct link to an example for the Lilygo board. It may be that the board is already loaded with and example but I can't find what is loaded by default.
when you follow the Link from post #2 you will see there is only a Modbus Master Example.
Ask the vendor if they have a Modbus Slave example for you.
If you have searched for a Modbus Slave example and you haven't found anything it is very likely that there is no. Therefore I advised you to make your own example with any library.
I could guide you through the process, but I don't have your board, just a ESP32 testboard and a separate RS485 module. If you want me (or any other person here to help you), you should describe
a) what your slave should be able to do via Modbus
b) what possibilities you have to TEST your device. So how you will control your slave. For example how the code of your Modbus Master looks like.
btw: In 2022 we call Modbus Master --> Modbus CLIENT and the Modbus Slave --> Modbus SERVER.
Modbus is a Single Client - Multi Server topology.
Modbus is restriced to 247 devices,
but the limit could be lower if you use a common MAX485 for the communication ... I'm to lazy to google, approx 30 ~ 32.
imho the usage of "client" and "server" is clear:
the client requests something from a server,
the server provides a resource (the information, a sensor value, a relay to switch...).
So in this sense it's the same like a browser and the webserver...
and at least ... the fomer Slave is now the Server ... easy to remember
(and so much better than Arduinos renaming of MOSI and MISO in SPI).
I have used Siemens S7-1200PLC in the past that acts as the Modbus Master(Client). I have used the RS485 from the Siemens to link to 32 pieces of voltmeters. These units are expensive as they are to measure DC and need to have isolation. I am looking to build an alternative using an ESP32 and hall effect voltage sensor( 0 to 100V DC)
Before looking to have a full PCB built I need to link my PC running a Modbus master protocol software and a USB to RS485 converter to the ESP32 on RS485. I need to be able to read/request from the slave( server) only 6 registers ( 16bit ) using the correct modbus code for multiple read . Once I have that working I need to look at an isolated RS485 chip. I will be working on a different project for a few days so will come back to this topic later.