2-CH RS485 HAT and PI4J #133
Replies: 4 comments
-
Hello! |
Beta Was this translation helpful? Give feedback.
-
Sorry, from your question it is not really clear what you already tried in code and what the actual problem is... Which version of Java or you using? If Java 8, maybe you can use V1.3 and take a look at this example for serial communication: |
Beta Was this translation helpful? Give feedback.
-
Initially, I needed to exchange information between the raspberry pi and the thermostat via the Modbus-RTU (RS485) protocol. To solve this problem, I bought a 2-CH RS485 HART (two rs485 interfaces on board). com ports of the device are defined on raspberry pi as ttySC0 and ttySC1. I used the jssc library to exchange on the com port, since I already had experience working with this library. Using the library, I open the ttySC0 port and read and write data. I use Java 11. |
Beta Was this translation helpful? Give feedback.
-
This does not look like Pi4J v2 code, but rather Pi4J v.1x. Pi4J v1.x uses the WiringPi numbering scheme. So GPIO_0 is physical/board PIN number 11 on the 40 pin header. As you can see below, this pin also potentially serves as RTS for serial communication for UART0 and UART1 see: https://pinout.xyz/pinout/pin11_gpio17 So I think there could be a potential conflict when Pi4J is creating the pin and potentially trying to steal the pin from the serial driver. I would suggest moving off of GPIO_0 if possible and trying another pin. Maybe GPIO_3. Thanks, Robert |
Beta Was this translation helpful? Give feedback.
-
Hello!
I use 2-CH RS485 HAT (https://www.waveshare.com/wiki/2-CH_RS485_HAT) to connect raspberry pi to indusctrial device via rs485 and Modbus-RTU. The app was writen by Java and work very good. Now I want to read two discrete signals. I try to use PI4J 1.4, but I have a problem. When I write "GpioController gpio = GpioFactory.getInstance();" in my program the serial port which provide by 2-CH_RS485_HAT doesn't work.
Can I use Pi4J and 2-CH_RS485_HAT driver together? And if it can what will i do for it?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions