Keep a local guard working when the uplink fails
Prove that a threshold alarm still acts locally while an unavailable uplink buffers evidence for ordered reconciliation.

Edge Eddie: I want you to cut the upstream path, prove the local action, and preserve the evidence needed after recovery.
Predict the reading, then compare it with the measurement.
Wokwi ESP32
Third party ToolProve that a threshold alarm still acts locally while an unavailable uplink buffers evidence for ordered reconciliation.
Open the ESP32 editor, paste diagram.json, then paste sketch.ino.
Open Wokwi to paste in the files (new tab)Get the files
Use both prepared files. This is a paste-in setup; saving a project requires a Wokwi account.
sketch.ino
- Use the launch button above to open the ESP32 editor in Wokwi.
- Select the editor’s diagram.json tab and replace all its text with the supplied diagram.json.
- Select the sketch.ino tab, replace all its text with the supplied sketch.ino, then click Start Simulation.
Steps
Step 1
- Do
- Open a new Wokwi ESP32 project, paste diagram.json and sketch.ino, and inspect the sensor, GPIO13 uplink button, and three LED paths.
- You will see
- The potentiometer feeds GPIO34; GPIO13 toggles the modeled uplink; red, green, and yellow LEDs show alarm, link, and buffer state.
- Why it matters
- The host chapter asks which path owns a safety decision when the fog tier fails.

Step 1 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- Inspect the LIMIT comparison and confirm that digitalWrite(ALARM_LED, alarm) is outside the uplink condition.
- You will see
- LIMIT is 2500 and the local alarm output depends only on the current sensor reading.
- Why it matters
- A local guard must not block on an upstream service or acknowledgement.

Step 2 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- Start the simulation and open Serial Monitor at 115200 baud.
- You will see
- EDGE-FOG LOCAL GUARD READY appears, followed by samples that name the limit, local action, uplink state, and buffered count.
- Why it matters
- A declared startup state and compact record make the outage run repeatable.

Step 3 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- Press the blue Toggle uplink button once.
- You will see
- UPLINK=OFF appears and the green link LED turns off.
- Why it matters
- GPIO13 models the failed upstream path without changing the local sensor or controller.

Step 4 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- Leave the sensor above LIMIT while the uplink remains off and watch the next decision row.
- You will see
- local_action=ALARM remains visible with uplink=OFF.
- Why it matters
- This is the Local Guard acceptance result: urgent behavior survives loss of the fog or cloud path.

Step 5 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- Wait for at least three offline samples.
- You will see
- The yellow buffer LED stays on and buffered reaches at least 3.
- Why it matters
- The failure drill must distinguish continuing control from delayed evidence.

Step 6 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- Press Toggle uplink again and inspect the next serial rows.
- You will see
- UPLINK=ON is followed by RECONCILE sent= with original_event_order=preserved, then buffered=0.
- Why it matters
- Recovery is incomplete until delayed records are marked and reconciled without being mistaken for fresh alarms.

Step 7 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab)
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
A cold-chain gateway normally approves compressor commands, but truck sensors must protect cargo while the gateway is rebooting. What is the safest ownership pattern?
Return to the chapter’s knowledge checkA site buffer holds one hour of raw vibration samples. A two-hour network outage happens, and the same buffer is also used for fault alarms. What is the main design risk?
Return to the chapter’s knowledge checkA production cell requires a local reject decision before a part leaves the inspection station. The fog node can fail over to a standby node in 20 seconds. What should the review flag?
Return to the chapter’s knowledge check
Return to Edge-Fog Computing: Common Pitfalls and Solutions · Browse Labs