Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read local regs #376

Open
gerryvel opened this issue Dec 17, 2024 · 0 comments
Open

Read local regs #376

gerryvel opened this issue Dec 17, 2024 · 0 comments

Comments

@gerryvel
Copy link

gerryvel commented Dec 17, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant