Skip to content

Modbus Write Single Register Value Not Updated

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about Modbus Write Single Register Value Not Updated. We cover key concepts, practical examples, and best practices.

The Problem

Modbus Function Code 06 (Write Single Register) returns success but value does not change.

Quick Fix

Wrong

// Writing a read-only register
mb.writeSingleRegister(1, 100, 5000);  // Register 100 may be read-only```

Response shows success (echo of request) but value remains unchanged.


### Right

```cpp
#include <ModbusRtu.h>

Modbus master(1, Serial, 2);

void setup() {
  master.begin(9600, SERIAL_8N1);
  Serial.begin(9600);
}

void loop() {
  // Write Single Register (FC 06)
  // Only writable registers accept the new value
  // Check device manual for writable register ranges (typically 0-99 for config)

  int result = master.writeRegister(1, 10, 1500);  // Register 10 = 1500

  if (result == 0) {
    Serial.println("Write acknowledged");

    // Verify by reading back (echo != actually stored!)
    uint16_t verify;
    master.readHoldingRegisters(1, 10, 1, &verify);
    Serial.print("Verified value: ");
    Serial.println(verify);
  } else {
    Serial.print("Write register error: ");
    Serial.println(result);
  }
  delay(2000);
}```

Write acknowledged Verified value: 1500 (Value persisted in slave)


## Prevention

Modbus FC 06 writes a single 16-bit holding register. The slave echoes the request on success — but the echo does NOT confirm the value was applied! Some slaves buffer writes or have validation rules. Always verify by reading back with FC 03. Read-only registers silently echo the write request without updating. Check device documentation for writable register ranges.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

## FAQ

<details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">### Does echo mean the write succeeded?</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>No. The echo only confirms the request was received. The slave may have rejected the new value silently. Always verify with FC 03.</p>
<h3 id="fc-06-vs-fc-16">FC 06 vs FC 16?</h3><p>FC 06 = Write Single Register (1 register). FC 16 = Write Multiple Registers (up to 123 registers). FC 16 is more efficient for bulk writes.</p>
<h3 id="what-register-values-are-valid">What register values are valid?</h3><p>0-65535 (uint16_t). Some registers accept signed values. Check the device manual for range limits and scaling factors.</p>
</div></details>

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro