En el momento me encuentro realizando una comunicación RS485, usando el protocolo modbus, en un ESP32 para leer los datos de un sensor. Actualmente, ya valide el funcionamiento del sensor, recibiendo datos a traves de un conversor RS485-USB, usando el software ModbusPoll. Tambien valide que la comunicación del ESP32 se este realizando de forma correcta, usando el mismo conversor RS485-USB y el software ModbusSlave, validando la dirección, el slaveID, y demas. Mi problema reside cuando intento leer los datos del sensor con el ESP32, ya que, usando la libreria ModbusMaster, solo recibo el mensaje E2, es decir, Timeout. Si conecto el sensor, el ESP32 y el PC, usando el modulo RS485, el PC recibe los datos, pero el ESP32 no. Alguien sabe que puede estar provocando esto o que configuración adicional se debe realizar?
If Google translate is any good, then @aditivator asked:
At the moment I am making an RS485 communication, using the modbus protocol, in an ESP32 to read the data from a sensor. Currently, I have already validated the operation of the sensor, receiving data through an RS485-USB converter, using the ModbusPoll software. Also validate that the ESP32 communication is being carried out correctly, using the same RS485-USB converter and the ModbusSlave software, validating the address, the slaveID, and so on. My problem is when I try to read the sensor data with the ESP32, since, using the ModbusMaster library, I only receive the E2 message, that is, Timeout. If I connect the sensor, the ESP32 and the PC, using the RS485 module, the PC receives the data, but the ESP32 does not. Does anyone know what might be causing this or what additional configuration needs to be done?
Thank you.
What is the purpose of the delay(100) in these 2 functions?
In your modbusPostTransmission() function, you must not have any delay otherwise you are almost certainly going to get error code E2 (i.e. timeout).
He trasladado su tema de una categoría de idioma inglés del foro a la categoría International > Español@aditivator.
En adelante por favor usar la categoría apropiada a la lengua en que queráis publicar. Esto es importante para el uso responsable del foro, y esta explicado aquí la guía "How to get the best out of this forum".
Este guía contiene mucha información útil. Por favor leer.
I've got the very same problem. Doing some internet research it seems the problem is that ESP32 is so fast, the enable signal turns to LOW before the telegram is fully transmitted. Successful examples with ESP32 boards either use other library or use the second UART. In my case I can't afford any of solutions above because I've already made a custom board (many of them) and I feel comfortable using modbusmater library so I don't want to start the learning curve using another library. I tried reducing clock speed to 80Mhz (didn't work) and adding a time delay to the post transmission function (didn't work either)
Moderador:
Por favor @miltonch y @aditivator estamos en el foro Arduino en español, de modo que deben usar este idioma.
Pueden usar google translante si desean continuar en el hilo.
La sugerencia de @aditivator es que no uses delay() en la rutina de transmisión.
Es cierto porque la secuencia modbus es precisa y si la alteras simplemente te da timeout.
retira el delay(100)
Despues de mucho revisar, encontre que era un error en la configuración del puerto serial. En mi caso, mi dispositivo en su configuración establecía los parametros de baud en 9600, bits 8, stop bit 1, y paridad N. Por alguna razón habia colocado la paridad en E, y simplemente al cambiarlo, funciono, empezo a responder de manera correcta. Los delay los segui usando, ya que sin ellos, la comunicación podia tener fallas, aunque los reduje a 10ms. Puedes intentar revisar y validar.