Skip to content

Read local regs #376

Open
Open
@gerryvel

Description

@gerryvel

Hi Alexander,

sorry, i'm a beginner, i have a ESP32C3 and use the server (Modbus_TCP):

const int Sensor_HREG = 100

void setup()
mb.server();
mb.addHreg(Sensor_HREG, 0, 20);

void loop()
mb.task();
   delay(10);

  RegVal0 = fbmx_temperature*10;
  RegVal1 = fbmx_pressure/100;
  RegVal2 = fbmx_humidity*10;
  RegVal3 = fbmx_altitude;
  RegVal4 = BoardSpannung*100;

  mb.Hreg(100, RegVal0);   // Value in xx,x °C 
  mb.Hreg(101, RegVal1);   // Value in xxxx mbar
  mb.Hreg(102, RegVal2);   // Value in xx.x %
  mb.Hreg(103, RegVal3);   // Value in xxxx m
  mb.Hreg(104, RegVal4);   // Value in xx.xx V

My client read and write in Reg 105 and 106.
Read from S7-1200 Client is okay, and the S7 write command is also okay.

But with read local Register

Serial.println("\nRead Register 105 : " + String(mb.Hreg(105)));
Serial.println("Read Register 106 : " + String(mb.Hreg(106)));

and printout:
Read BME 280
Temperatur : 18.0 °C
Luftdruck : 961.6 mbar
Luftfeuchte : 43.9 %
Höhe : 439.4 m
Spannung : 1.60 V

Read Register 105 : 0
Read Register 106 : 180
Register 106 has the same value how Register 100 (the temperatur)!

Where is my mistake?

Thanks, Gerry

https://github.com/gerryvel/RoomSensor/blob/main/src/Sensor_TPH.ino

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions