Hello! Please, I need help . I only have an Arduino Uno and a MAX 485 converter. I need to communicate via modbus protocol. And to be more specific, so that the message from the Arduino Uno is sent to RS 485 and the sent data is shown in the code terminal (which is written in Visual Studio Code and written in Javascript). I connect the installation itself to my PC via a USB to RS485 converter. here are photos of how it's all connected
thank you so much for being interested in my problem!:"D
the problem is that in the Node program.js does not send the data that I sent in the Arduino Uno code to RS-485. More precisely, it shows via USB that it receives something, but for some reason it does not want to reproduce it into the terminal itself and duplicate this information. It only stops at the message "Modbus connection open" and stands without sending any more information (although it should show the data sent to it from the Arduino Uno on the code)
i've written code to send/receive data over RS-485 but am not familiar with the library you're using.
such code, with 2 serial interfaces, would typically check for input on one interface and re-transmit what it receives on the other interface. i don't see that in your Arduino code
looks like you're repeatedly
setting the values of Data1 and 2
printing them on the serial monitor
setting posPtr and distPtr to the locations of Data 1 and 2
setting values in ModbusData [] to the values of the ptrs
all of the above could have been done once in setup()
i'll guess that modbus.poll() must be checking the input pin for data and to do so, it needs to repeatedly check that pin ...
but there's a 500 msec delay between each time poll() is invoked, so i doubt it will see changed on the pin quickly enough
OH, that is, in order for it to send data normally, should all the code from the loop be transferred to setup? thus finally having time to send the necessary data once?
Hello again, I apologize, but my plans have changed. Now, I need to send a message from the computer to the USB-to-RS485 converter, but I still can't get it to work no matter how hard I try. To be more specific, the Node.js code gets stuck at "Preparing to send data..." and doesn't proceed any further, and there are no messages about this data in the Arduino Uno.