easiest way is not to allow to handle DE/RE pins by esp32. Instead use mosfet or transistor, when there is tx or rx active then DE/RE are pulled low/high automatically. No library modifications necessary and this solution works for years in my setup.
@Antony Cartwright You video was very useful for me. there is a solution for the issue of modbus. In fact in the last esp-df version (3.2.2) we can use RTS pin in order to control DE/RE pin of the RS485 module. It works fine.
The A and B pins basically indicate a 0 or 1 by A being higher voltage than B, or the other way around. I would not connect a logic analyzer directly to them as they are not logic level. They can be negative and much higher than 5 V typical is +/- 7.
Just a note on Modbus. Modbus is not always used in the RS-485 mode, it can be use in RS-232, RS-422 or TCPIP. Modbus slave devices can only be multi dropped in RS-485, RS-422 and TCPIP.
Yes you can use TTL as well, it can't be multi dropped or be much farther than 6 meters away. I have work on systems where there could be 40 slave devices on an RS-485 multi drop and 600 meters away for the farthest one.
Oh cool! I've been working with Modbus for several hours today. I send a device a command, it sends on the A+ line, the device receives it and sends a reply... The reply is received (on both lines)... But the A+ lines receives the message with heavy distortion. The B- line is clean. The general result is garbage though. :-( Why would this happen?!?!
With RS-485 the data is sent on both A+ and B- at the same time with respect to ground. One is going from ground to a positive 5 volts and the other is going from ground to a negative 5 volts. I one get messed up and the other one does not the data should get through that is the design of RS-485 to be able to go long distances with out total communications fail. Is there a second command being sent before the full message is received that would mess up the data.
Hi, There's no second command. I've just switched over to a different RS485-TTL converter and the problem is slightly different now. Now it does transmit the message on both lines, but the received message is still corrupted on the A+ line. The message from ESP32 to the converter is perfect, so this puzzles me a bit. Why would the reply be noisy on one line from the device!?!? I'm thinking the actual wire might be damaged or dirty or something.
Antony Cartwright, I have query about integration of ESp32 and GOT HMI with FX5U through RS485. If i connect Individually, I am able to read the data from PLC but when I connect it together (PLC,HMI and ESP32) It shows error on PLC. I am using ESP32 for data logging . Can you suggest what could be reason for error?
Hi Antony, you provide interesting infos regarding modbus... is there any planing to provide a link to show wiring (schematic) and/or the code (sketch) for.. that someone else can rebuild your solution? I only found the info to patreon.... Or in an older modbus video to a not working link ;-(( regards
Dang, I need to order one of those analyzers. I am having a similar problem may be able to fix it without the tool but I really am curious to see it myself.
the problem is not the esp32 but the program.... it should switch only from tx mode to rx mode after the serial buffer sended the last byte at the low speed which takes a while.
easiest way is not to allow to handle DE/RE pins by esp32. Instead use mosfet or transistor, when there is tx or rx active then DE/RE are pulled low/high automatically. No library modifications necessary and this solution works for years in my setup.
How exactly does this work? I like the idea but wondering if the transmit works also with the lower voltages if the esp to rs485
Hi sir use transistor can show us how it work
@Antony Cartwright
You video was very useful for me.
there is a solution for the issue of modbus. In fact in the last esp-df version (3.2.2) we can use RTS pin in order to control DE/RE pin of the RS485 module.
It works fine.
Thanks for your comment! Where can I read more about this? Thanks!
The A and B pins basically indicate a 0 or 1 by A being higher voltage than B, or the other way around.
I would not connect a logic analyzer directly to them as they are not logic level. They can be negative and much higher than 5 V typical is +/- 7.
Logic analyzers normally accept +-30V.
I didnt see the solution? only the problem? Have the modbus libraries corrected this since your video?
Just a note on Modbus. Modbus is not always used in the RS-485 mode, it can be use in RS-232, RS-422 or TCPIP. Modbus slave devices can only be multi dropped in RS-485, RS-422 and TCPIP.
Ken Heinrich hi Ken, I think it can be used with TTL too! :)
Yes you can use TTL as well, it can't be multi dropped or be much farther than 6 meters away. I have work on systems where there could be 40 slave devices on an RS-485 multi drop and 600 meters away for the farthest one.
Oh cool! I've been working with Modbus for several hours today. I send a device a command, it sends on the A+ line, the device receives it and sends a reply... The reply is received (on both lines)... But the A+ lines receives the message with heavy distortion. The B- line is clean. The general result is garbage though. :-( Why would this happen?!?!
With RS-485 the data is sent on both A+ and B- at the same time with respect to ground. One is going from ground to a positive 5 volts and the other is going from ground to a negative 5 volts. I one get messed up and the other one does not the data should get through that is the design of RS-485 to be able to go long distances with out total communications fail. Is there a second command being sent before the full message is received that would mess up the data.
Hi, There's no second command. I've just switched over to a different RS485-TTL converter and the problem is slightly different now. Now it does transmit the message on both lines, but the received message is still corrupted on the A+ line. The message from ESP32 to the converter is perfect, so this puzzles me a bit. Why would the reply be noisy on one line from the device!?!? I'm thinking the actual wire might be damaged or dirty or something.
can you help me? i have a project, if i use esp32 sim800l how to setting slave address? and how to connect with SCADA?
why cant we connect esp32 with modbus what is the reason behind it
how if the esp32 work on 3.3v man?
Antony Cartwright, I have query about integration of ESp32 and GOT HMI with FX5U through RS485. If i connect Individually, I am able to read the data from PLC but when I connect it together (PLC,HMI and ESP32) It shows error on PLC. I am using ESP32 for data logging . Can you suggest what could be reason for error?
Modbus is now supported on ESP32 esp-idf.
Wish people would do idf tutorials to explain that code.
very clever and practical 🥳 thank you
One question, ESP32 works with 3V3 logic, can this Converter Board work with 3v3 logic level?
Paulo, procure pela interface com alimentação de 3V3 também. Assim, seu nível de tensão de equipara aos níveis do esp32.
@@joaoricardo_5236 Valeu pela resposta, testei com o ESP e um Arduino(lógica 5V) se comunicando, alimentei o barramento com 5V e funcionou legal.
Which code are you using? I'm trying to get started as well but have zero clue...
Hi Antony, you provide interesting infos regarding modbus... is there any planing to provide a link to show wiring (schematic) and/or the code (sketch) for.. that someone else can rebuild your solution? I only found the info to patreon.... Or in an older modbus video to a not working link ;-(( regards
Are you planning to do video with esp8266 and max485 and using a library to send a command to a slave?
Dang, I need to order one of those analyzers. I am having a similar problem may be able to fix it without the tool but I really am curious to see it myself.
Excellent
Part 2 pls
It's on my channel.
Hey! I bought one of those logic analyzers. Where did you find the software, mate?
the problem is not the esp32 but the program.... it should switch only from tx mode to rx mode after the serial buffer sended the last byte at the low speed which takes a while.
AAAHHHH Get's us reeled in, laid back in my chair, and left us with a cliffhanger! :P
Haha, sorry, but it was released today. :-)
.ino ?
Long winded. Too many adverts.