LILyGO esp32 can rs485 board

I am new to Arduino and the ESp32 boards.
I have set up the TTGO T display and played with various examples.

I have a LILYGO ESP32 CAN RS485board and want to set the board and later many boards up as a modbus slave on rs485.

I need an example of a sketch for this board with modbus slave setup.
Any ideas please? DO Llilygo have an example? I cant find one.

Regards

Ian

First Goggle Hit: GitHub - Xinyuan-LilyGO/T-CAN485

If that is the board.txt you are using, then there is a CAN example.

Thank You for the link.

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 :wink:

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.

#define RS485_EN_PIN 17 // 17 /RE
#define RS485_TX_PIN 22 // 21
#define RS485_RX_PIN 21 // 22
#define RS485_SE_PIN 19 // 22 /SHDN

Thanks for your reply.

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.

Again, thanks for your help. Regards Ian

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.

So you can have 1 client talking to 100 servers? I would have expected it to be the other way around.

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.

Server/Client Anouncement: https://modbus.org/docs/Client-ServerPR-07-2020-final.docx.pdf

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 :wink:
(and so much better than Arduinos renaming of MOSI and MISO in SPI).

1 Like

Thanks for the reply.

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.

Again thanks for your reply.

ok so basically a FC3 Read Multiple Holding register. What are the 6 addresses (or the start address with the consecutive 6 values)?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.