The Dual-Sensor Consensus Arbiter

SS 2 Arduino Uno Simulation first Redundancy and Fault Tolerance
Simulation lab
Board: ♾️ Arduino Uno
Open in Wokwi ↗
Simulator preview
ARDUINO UNO

Press the pushbutton to test the interactive circuit in real time.

>_ Serial monitor
Ready — press the button.
📦 Components ▴
  • Arduino Uno microcontroller board
  • LED indicator (green)
  • 220 ohm current-limiting resistor
  • Tactile pushbutton switch
  • Jumper wires (male-male)

🔧 Build Your Consensus Arbiter

1 Wire two independent analog temperature sensors (Sensor A on A0, Sensor B on A1).
2 Apply offset calibration compensation to balance sensor tolerances: 'A_cal = readA - offsetA'.
3 Calculate inter-sensor disagreement: 'delta = abs(A_cal - B_cal)'.
4 If delta <= 15, confirm consensus and output the average; if delta > 15, assert CRITICAL FAULT!
🧩 Block plan / Starter code ▴
const int SENSOR_A_PIN = A0;
const int SENSOR_B_PIN = A1;
const int STATUS_LED = 13;
const int FAULT_LED = 12;
const int DISAGREEMENT_THRESHOLD = 15; // Max allowable deviation

void setup() {
  pinMode(STATUS_LED, OUTPUT);
  pinMode(FAULT_LED, OUTPUT);
  Serial.begin(115200);
  Serial.println("Dual-Sensor Consensus Arbiter Initialized.");
}

void loop() {
  int readA = analogRead(SENSOR_A_PIN);
  int readB = analogRead(SENSOR_B_PIN);
  int delta = abs(readA - readB);

  if (delta <= DISAGREEMENT_THRESHOLD) {
    digitalWrite(STATUS_LED, HIGH);
    digitalWrite(FAULT_LED, LOW);
    int consensus = (readA + readB) / 2;
    Serial.print("Consensus OK: Value = ");
    Serial.println(consensus);
  } else {
    digitalWrite(STATUS_LED, LOW);
    digitalWrite(FAULT_LED, HIGH);
    Serial.print("CRITICAL FAULT: Sensor Disagreement! Delta = ");
    Serial.println(delta);
  }
  delay(500);
}

Dual modular redundancy detects sensor drift, broken wiring, and hardware divergence instantly.

⚗️ Test your model

Test Condition / ActionExpected Result
Sensors Matched (A=500, B=505, delta=5)Consensus confirmed; Green LED ON; outputs 502 average
Sensor Drift Induced (A=500, B=540, delta=40)Disagreement asserted; Red Fault LED ON; logs error
Unplug Sensor A (A=0, B=500)Immediate fail-safe shutdown; prevents blind operation
⚑ Try a challenge

Implement a Triple Modular Redundant (TMR) system with 3 sensors that isolates the faulty sensor and continues running on the majority 2!

❓ Quick check
Why do mission-critical systems like vaccine refrigerators and airplane controls install two independent sensors instead of just one?

📖 Our Story & Concepts

In aerospace avionics, medical ventilators, and nuclear reactors, a single sensor failing silently can cause loss of life. If a boiler thermostat fails by freezing at 20°C, the controller keeps running heaters until the tank explodes.

To eliminate single points of failure, safety-critical systems implement Dual Modular Redundancy (DMR). Two independent physical channels sample the exact same process. When their readings diverge beyond calibrated tolerance, the arbiter flags a safety violation and commands actuators into a safe fail-soft state.

</> Full Annotated Code Walkthrough

// Complete Dual Modular Redundancy Arbiter with Self-Test
const int SENSOR_A_PIN = A0;
const int SENSOR_B_PIN = A1;
const int OK_PIN = 13;
const int FAULT_PIN = 12;

const int MAX_TOLERANCE = 18;

void setup() {
  pinMode(OK_PIN, OUTPUT);
  pinMode(FAULT_PIN, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  int a = analogRead(SENSOR_A_PIN);
  int b = analogRead(SENSOR_B_PIN);
  int diff = abs(a - b);

  if (diff <= MAX_TOLERANCE) {
    digitalWrite(OK_PIN, HIGH);
    digitalWrite(FAULT_PIN, LOW);
    int avg = (a + b) / 2;
    Serial.print("CONFIRMED_DATA:"); Serial.println(avg);
  } else {
    digitalWrite(OK_PIN, LOW);
    digitalWrite(FAULT_PIN, HIGH);
    Serial.print("INTEGRITY_VIOLATION_DELTA:"); Serial.println(diff);
  }
  delay(300);
}

Dual modular redundancy detects sensor drift, broken wiring, and hardware divergence instantly.

▷ Expected Results & Troubleshooting

Test Condition / ActionExpected Result
Sensors Matched (A=500, B=505, delta=5)Consensus confirmed; Green LED ON; outputs 502 average
Sensor Drift Induced (A=500, B=540, delta=40)Disagreement asserted; Red Fault LED ON; logs error
Unplug Sensor A (A=0, B=500)Immediate fail-safe shutdown; prevents blind operation

⚑ Extension Challenges & Blueprints

⚑ Extension Challenges
  • Level 1: Add individual gain/offset compensation curves for both sensors before delta comparison.
  • Level 2: Implement Triple Modular Redundancy (TMR) with majority voting logic.
  • Level 3: Transmit failure diagnostic reports over an encrypted serial or CAN bus network.

❓ Check Your Understanding

Question 1: Why do mission-critical systems like vaccine refrigerators and airplane controls install two independent sensors instead of just one?

Question 2: What is an 'Uncertainty / Disagreement Tolerance Window' (Delta limit)?

Question 3: If Sensor A reads 4.0°C and Sensor B reads 8.5°C (difference = 4.5°C), what should our Consensus Arbiter do?

Question 4: What mathematical function in C++ computes the absolute positive difference between two numbers regardless of which is larger?

Feedback appears after you check your answer.