ESP32 & IEC 61508: Functional Safety in Industrial IoT Designs
The ESP32 is an undeniable force in the Industrial IoT (IIoT) landscape. Its combination of a dual-core processor, extensive peripherals, and integrated Wi-Fi and Bluetooth connectivity, all at a very low cost, has made it the default choice for countless monitoring, data logging, and protocol bridging applications. But what happens when the system it controls isn't just collecting data, but is responsible for preventing a hazardous event? This is the domain of functional safety and the world of standards like IEC 61508.
This post is for the engineers and product managers looking at the ESP32 and asking a hard question: can this non-certified, commercial-off-the-shelf (COTS) microcontroller be a component in a system that requires functional safety compliance? The answer is complex, and it involves a significant shift in responsibility from the component manufacturer to you, the system designer.
The Core Challenge: Why the ESP32 Isn't Safety-Rated
First, let's be direct. The ESP32 was not designed for functional safety. It is not certified against IEC 61508, and Espressif provides no safety manual or Failure Modes, Effects, and Diagnostics Analysis (FMEDA) data. These documents are the bedrock of a functional safety case, and their absence is the single biggest hurdle.
Safety-certified microcontrollers are fundamentally different. They often include:
- Hardware Redundancy: Lock-step cores, redundant memory with ECC, and cross-monitoring peripherals built into the silicon.
- Certified Toolchains: Compilers and linkers that have been rigorously tested and validated not to introduce systematic faults.
- Safety-Rated Peripherals: Specialized watchdog timers and clock monitors designed to detect failures with a high degree of certainty.
- Comprehensive Documentation: A safety manual detailing how to use the MCU's features correctly in a safety context and FMEDA reports quantifying failure rates.
The ESP32 lacks these features. This means you cannot simply drop it into a design and claim compliance. The entire responsibility for analyzing failure modes, implementing detection and mitigation measures, and justifying every design decision rests on your engineering team.
Path to Compliance: Architectural Patterns for Lower SILs
Despite the challenges, it is possible to construct a safety-related system that incorporates a COTS component like the ESP32, typically for lower integrity levels such as SIL 1. The key is to build safety around the component, rather than expecting it from the component itself.
Functional Safety is defined as the part of the overall safety of a system that depends on the correct functioning of its electrical, electronic, or programmable electronic components in response to their inputs.
For a low-demand system, SIL 1 requires a Probability of Failure on Demand (PFD) between 10⁻² and 10⁻¹. Achieving this with a single, non-certified processor is practically impossible. The foundational pattern is hardware redundancy.
The 1oo2 Architecture: Redundancy is Non-Negotiable
The most common approach is a one-out-of-two (1oo2) architecture. This involves using two independent channels to perform the safety function. In our case, this would mean two separate ESP32s.
- Independent Processing: Each ESP32 runs its own instance of the safety logic, reading sensor data independently.
- Cross-Monitoring: The two ESP32s constantly monitor each other. This can be done via a dedicated UART or SPI link, where they exchange heartbeats and the results of their calculations.
- Discrepancy Detection: A comparator logic (which could be a simple CPLD or a third, much simpler microcontroller) checks for any difference between the outputs of the two channels.
- Transition to Safe State: If a mismatch is detected, or if one channel stops responding, the comparator immediately forces the system into a pre-defined safe state (e.g., de-energizing a motor, closing a valve).
This architecture ensures that a single random hardware failure in one ESP32 doesn't lead to a loss of the safety function.
Introducing Diversity to Combat Common-Cause Failures
A significant risk in a redundant system is a common-cause failure, where the same fault affects both channels simultaneously. This is a particular concern for systematic faults, such as a bug in the software. A 1oo2 architecture using two identical ESP32s running the exact same firmware is vulnerable.
To mitigate this, we introduce diversity. The goal is to make the two channels as different as possible to reduce the chance that the same flaw will bring them both down.
- Compiler Diversity: Compile the firmware for each channel with a different major version of the compiler or with different optimization settings.
- Language Diversity: Write the safety logic for one channel in C++ and the other in C or even MicroPython, if the application allows.
- Team Diversity: Have two separate, independent teams develop the firmware for each channel based on the same set of requirements.
- Component Diversity: For a more robust design, consider pairing the ESP32 with a different, simpler microcontroller from another vendor. The ESP32 could handle complex logic and communication, while a small 8-bit MCU acts as the second channel and final arbiter.
This strategy, as highlighted by industry experts, is a viable path for using non-certified components in systems aiming for lower SILs. It directly addresses the risk of systematic software faults that redundancy alone cannot solve.
Firmware Strategies for Fault Tolerance and Determinism
The architecture is only half the battle. The firmware design must be exceptionally robust.
Segregation: Walling Off Safety-Critical Logic
The ESP32's greatest strength—its connectivity—is also a major liability for functional safety. The Wi-Fi and Bluetooth stacks are incredibly complex, non-deterministic, and a potential source of countless bugs. The safety-critical logic must be isolated from these functions.
A robust pattern is to dedicate one of the ESP32's cores exclusively to the safety function. This core runs a simple, deterministic loop with no dynamic memory allocation and no interaction with the connectivity stacks. The second core can handle non-safety-critical tasks like MQTT reporting, serving a web interface, or logging data. Communication between the cores must be handled with extreme care, typically through a tightly controlled, non-blocking message queue.
The Watchdog is Your Best Friend: Implementing Self-Diagnostics
Since the ESP32 doesn't have built-in safety diagnostics, you must create them in software and augment them with external hardware.
- Utilize On-Chip Watchdogs: The ESP32 provides both a Task Watchdog Timer (TWDT) and an Interrupt Watchdog Timer (IWDT). The TWDT is essential for ensuring that critical tasks are not starved of CPU time or stuck in an infinite loop. The IWDT helps detect frozen interrupt handlers.
- Implement Logic Checks: Your safety loop should include checks for memory corruption (CRC checks on critical data structures), program flow monitoring (using checkpoints to ensure code executes in the correct sequence), and sensor input validation (range and plausibility checks).
- Add an External Hardware Watchdog: An external watchdog timer IC is non-negotiable. The ESP32's internal watchdogs are part of the same silicon that might be failing. An external watchdog, serviced by a GPIO pin, provides a truly independent monitor that can reset the processor or trigger a safe state if the firmware becomes completely unresponsive.
State Management and Safe States
Your system must have a clearly defined safe state, and it must reliably enter this state upon detecting any fault. This state must persist across power cycles. Use the ESP32's non-volatile storage (NVS) to log fault conditions and ensure that after a reset, the system can determine why it reset and remain in a safe state until explicitly cleared by an operator.
:::
The Hidden Costs: Beyond the Bill of Materials
The primary motivation for using an ESP32 is its low component cost. However, this is a classic trade-off. The initial savings are offset by a massive increase in engineering complexity, validation effort, and documentation requirements. The responsibility shifts entirely to you.
Consider the difference in engineering burden:
| Responsibility | Using ESP32 (COTS) | Using Safety-Certified MCU |
|---|---|---|
| Failure Analysis (FMEDA) | Performed entirely by system integrator. | Provided by MCU vendor. |
| Safety Manual | Created entirely by system integrator. | Provided by MCU vendor. |
| Certified Toolchain | N/A. Integrator must justify toolchain. | Provided or recommended by MCU vendor. |
| Burden of Proof for Certification | Rests 100% on the system integrator. | Shared with MCU vendor's documentation. |
This shift in responsibility is the true cost of using a COTS microcontroller in a safety application. The engineering effort required for the analysis and documentation can easily eclipse the hardware cost savings.
Safety vs. Security: A Necessary Distinction
It's easy to confuse functional safety with cybersecurity. The ESP32 has excellent security features like Secure Boot, Flash Encryption, and support for TLS. These are critical for protecting a system from malicious threats and are a focus of standards like IEC 62443.
However, they do not contribute directly to functional safety.
- Functional Safety (IEC 61508): Protects against random hardware failures and systematic design faults to prevent physical harm.
- Cybersecurity (IEC 62443): Protects against intentional, malicious attacks from unauthorized actors.
While a secure system is a prerequisite for a safe one (you cannot guarantee safety if an attacker can alter your code), passing a security audit does not mean your system is functionally safe. The 2025-2026 trend in industrial automation points toward a convergence of these two disciplines, but for now, they require separate analysis and mitigation techniques.
The "Proven in Use" Fallacy
One argument often floated for using COTS components is "proven in use." The idea is that a component used successfully in millions of devices must be reliable. While the ESP32 is certainly field-proven in non-critical applications, this argument is insufficient for an IEC 61508 safety case.
A rigorous "proven in use" claim requires extensive, documented field data on failure rates, operating hours, and environmental conditions that are directly comparable to your target application. This data is almost never available for COTS components. Without it, you must fall back on a more rigorous, evidence-based design and analysis approach as described above.
Key Takeaways
- The ESP32 is not IEC 61508 certified and lacks the hardware features and documentation of safety-rated MCUs.
- Achieving lower SILs requires a redundant hardware architecture (e.g., 1oo2) to mitigate random hardware failures.
- Firmware must be designed for fault tolerance, using watchdogs, self-diagnostics, and strict segregation of safety-critical logic from complex stacks like Wi-Fi.
- Using a COTS MCU trades low component cost for a significant increase in the system integrator's responsibility for analysis, validation, and documentation.
- Functional safety and cybersecurity are distinct disciplines; security features like Secure Boot do not satisfy functional safety requirements.
In conclusion, integrating an ESP32 into a safety-related industrial system is not a task to be taken lightly. It moves the design process from one of component selection to one of intensive system-level safety engineering. While it's a viable path for cost-sensitive applications targeting lower SILs, it demands a high level of expertise in both hardware and software fault tolerance. At GizanTech, our experience in embedded systems for harsh industrial environments helps our clients navigate these complex trade-offs, ensuring that their product is not only functional but also robust and defensible.
Sources & further reading
Häufig gestellte Fragen
Is the ESP32 certified for IEC 61508 functional safety?
No, the ESP32 is not certified for functional safety. It lacks the built-in hardware redundancy and a certified real-time operating system necessary for out-of-the-box compliance with standards like IEC 61508.
How can I achieve SIL 1 with an ESP32?
Achieving SIL 1 requires a multi-faceted approach. A single ESP32 is insufficient; a dual-channel (1oo2) architecture with two ESP32s monitoring each other is a common starting point for hardware redundancy.
What are the biggest challenges of using a COTS MCU for safety?
The primary challenges are the lack of manufacturer-provided safety manuals and FMEDA data. This shifts the entire burden of analysis, justification, testing, and documentation for certification onto the system integrator.
Are the ESP32's security features the same as functional safety?
No. Features like Secure Boot and Flash Encryption address cybersecurity threats, protecting against malicious attacks. Functional safety addresses random and systematic hardware and software failures to prevent harm.
Related solutions
See how we apply this in production, by industry: