Electronic – Implementing Modbus RTU on a UART device

modbusrs485uart

I have a particle counter HPMA115S0 which has a UART communication interface. I bought a TTL UART to RS485 Converter Module to make it work with a PLC over Modbus RTU protocol.

I usually work with devices that have RS485 serial communication standard but those devices have all the information I need to make them work over a Modbus serial communication protocol (PLC as a master) such as the ID and the baud rate and the registers' addresses which contain the data to request.

However, with HPMA115S0 I don't know what the ID would be, what is the register address of the measurement value and so on. So can I make this device with UART communication to work over Modbus serial protocol by using the UART to RS485 converter?

Best Answer

Your sensor does not need Modbus at all, from the datasheet you can see it uses a simple protocol that sends 32 bytes per frame.

If you have a PLC you should be able to receive these frames quite easily. Most (at least those I've seen) PLCs with an RS485 port can work with either Modbus or what it's called "character mode", which means that the port on the PLC works like a raw UART so to speak, and you have to define your own protocol in your software. When you use this raw protocol you won't need any device address or register number or anything like that you just open your port with the right settings and start listening and processing frames and recording values.

If you don't need a PLC you could always use any kind of computer with a serial port or a USB serial adaptor (RS232 or RS485 if the sensor is far away in the field). The easiest and cheapest I can think of is a Raspberry Pi Zero next to the sensor with a Python script to record values every 10 seconds or more and write them to a database. This way you won't need the RS485 link and you can connect to the Pi to read or download values in many different ways. You can even install something like Domoticz (http://www.domoticz.com/) to have plots with trends or trigger alarms via e-mail or sms (note that I don't think your sensor is supported by Domoticz out of the box, but with such a simple protocol the interface should be a piece of cake).

Many possibilities indeed!