Hi everyone,
I'm currently working on developing a protocol converter that reads data from Modbus RTU slave devices (via RS485) and sends the collected data to a cloud server using HTTP POST over GPRS or Ethernet.
I have successfully implemented Modbus RTU communication and can read holding/input registers using Function Code 0x03/0x04. I also have the HTTP client code working (sending JSON/XML payloads). However, I'm facing challenges in mapping the Modbus RTU data to the HTTP payload structure.
My Questions:
I'm currently working on developing a protocol converter that reads data from Modbus RTU slave devices (via RS485) and sends the collected data to a cloud server using HTTP POST over GPRS or Ethernet.
I have successfully implemented Modbus RTU communication and can read holding/input registers using Function Code 0x03/0x04. I also have the HTTP client code working (sending JSON/XML payloads). However, I'm facing challenges in mapping the Modbus RTU data to the HTTP payload structure.
My Questions:
- What is the standard approach or best practice to map Modbus RTU registers (e.g., 40001, 40002) to HTTP parameters or JSON fields?
- For example, if I read two registers representing temperature and humidity, how should I define them in the outgoing HTTP request?
- Which HTTP parameters are typically required from the server side to do this mapping effectively?
- Do I need:
- Base URL (e.g., http://server.com/api/data)
- HTTP method (GET/POST)
- Expected fields or keys (e.g., temperature, humidity)
- Content-Type (e.g., JSON or XML)
- Headers?
- Do I need:
- How should I handle scaling, byte-order (endianness), and data type conversions (e.g., Modbus floats or 16-bit integers → JSON numbers)?
- Is there any standard format or user manual I should follow for mapping Modbus registers to HTTP fields for such converters?
