Hi, I’m trying to read data from a sensecap grove sen54 module in a sensecap 4G Hub through a sensecap s2110 converter module from grove to modbus.
I can see that I get data through the Modbus Poll software, but I don’t know how to configure the parameters (modbus address, type of register, type of data, etc…) so that the Sensecap 4G Hub can read them correctly.
Hi. It sounds like you have successfully connected the Grove sensor to the S2110 and got a reading. You will then need to do some configuration to connect the S2110 to the Sensecap 4G Hub.
The Sensecap 4G Hub supports custom sensors, but the sensor’s Modbus slave address suppose to be in the range 128 to 254. So you need to change the Modbus slave address of the S2110, which by default is 1. After that you can configure the type of register and type of data for the 4G Hub. They should be the same configuration as you have in the S2110 for Grove sensors.
Cita 1. Build new libraries using GitHub source code
The contents here are on the GitHub where we maintain the code.
Step 1: Add a sensorNew.hpp file to the src\sensor folder for the new sensor.
Step 2: Define the sensor class and implement the init() and sample() functions.The sensor class should inherits from the sensorClass class, and implement the init() and sample() functions. The init() function is used to initialize the sensor, and than returns a register offset value for Modbus communication. The sample() function is used to read the sensor data, returns true when the data is valid, and returns false when the data is invalid.
Step 3: Include the sensorNEW.hpp file and call it.Add line #include "sensorNew.hpp" to the src\sensor\sensorBuilder.hpp file. In the setup() function of the sensorBuilder.ino file, create the new sensor class object and call the SensorBuilder.addSensor() function with it as an argument.
I’m having trouble here on this part. I know how to configure the Sensecap 4G but I need to change how the modbus address says.
Thank you very much for your help
You can find #define SENSOR_BUILDER_DEF_SLAVE 1 at line 23 of src/sensorBuilder.hpp on the source code. I think changing the value of this definition will change the Modbus address.