Okay there is a temperature and humidity correction:
Also after let it run for about 1h the data isnt that accurate (about 4degree C too high and the humidity is a little bit to low)
Trust me, it's easier to adjust in your code, than writing some modbus registers without proper documentation.
So you mean just a correction factor in my code.
Timestamp originates in Serial Monitor, not in the Arduino, so it's not an indication that the baud is correct.
What I'm seeing, I'd say incorrect baud, but I haven't dug into the thread yet.
edit
Never mind. I hate how chrome doesn't load all the messages at first. Thought I was at the bottom of the thread, but apparently not. Ugh.
Yes, leave it running for a day to stabilize and then check if error is linear and adjust if needed.
Also, for calibration you need calibrated meter.
Yes.
I just tested if I am able to extend the code for the second sensor and it looks promising.
#include <ModbusMaster.h>
ModbusMaster sens1;
ModbusMaster sens2;
void setup()
{
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, 18, 17);
sens1.begin(1, Serial1);
sens2.begin(2, Serial1);
}
//Setup ends here
void loop()
{
uint8_t result1 = sens1.readHoldingRegisters(0, 2);
delay (250);
if (result1 == sens1.ku8MBSuccess)
{
Serial.println("- Sense1 -");
Serial.print("1. register: ");
Serial.println(sens1.getResponseBuffer(0));
Serial.print("2. register: ");
Serial.println(sens1.getResponseBuffer(1));
}
Serial.print("\n");
delay(250);
uint8_t result2 = sens2.readHoldingRegisters(0, 1);
delay (250);
if (result2 == sens2.ku8MBSuccess)
{
Serial.println("- Sense2 -");
Serial.print("1. register: ");
Serial.println(sens2.getResponseBuffer(0));
}
Serial.print("\n");
delay(250);
}
I'm not quite sure about it, I have never had opportunity to try with multiple slaves.
Try if it works.
But I would expect that you don't need to make two modbus objects since all parameters are same, it's just changing the first byte sent .
You could probably change the slave on the fly, I just don't know how.