From Smart Lighting to Cybernetic Hell: The Unlikely Porting of DOOM to a Sonoff Smart Switch

The adage that "DOOM can run on anything" has evolved from a niche hacker joke into a rigorous benchmark of modern engineering. From pregnancy tests to oscilloscopes and ATMs, id Software’s 1993 masterpiece has been ported to hardware that its original creators could never have envisioned in their wildest fantasies. The latest chapter in this saga comes from the DIY hardware community, where developer [piuppi] has successfully managed to render a DOOM-style engine on the humble, unassuming Sonoff Basic R2 smart switch.
Main Facts: The "Sonoff DOOM" Project
The Sonoff Basic R2 is a ubiquitous piece of smart home infrastructure. Designed specifically to toggle power to light fixtures via Wi-Fi, it is built around the ESP8285—a chip essentially identical to the famous ESP8266, featuring a mere 1MB of flash memory and a processor clocked at 80MHz. It was never intended to handle the 2.5D ray-casting mathematics required to render the corridors of Phobos or the pits of Hell.
[Piuppi]’s project, titled "Sonoff-DOOM," does not represent a full, playable port of the original game in the traditional sense. Due to the severe memory constraints of the ESP8285, the project serves as a highly optimized tech demo. It renders graphical data extracted from a legitimate copy of DOOM—specifically the WAD files—within a restricted environment. By utilizing a custom-built engine, the device renders a simplified map that mirrors the iconic aesthetics of the 1993 classic.
Crucially, the device does not lose its primary functionality. Even while the processor is busy calculating light levels and wall textures, the underlying firmware maintains its control over the relay, allowing the user to operate their lights through a web browser while simultaneously navigating a virtual environment.
A Chronology of the "It Runs DOOM" Phenomenon
To understand why this development is significant, one must look at the historical trajectory of the DOOM community.
The Early Days (1993–2000)
Immediately following the release of DOOM for MS-DOS, enthusiasts began exploring the source code. When John Carmack and the team at id Software released the source code in 1997, the floodgates opened. The game was ported to Linux, OS/2, and eventually early handheld devices like the Palm Pilot.
The Era of Ubiquity (2000–2015)
As embedded systems became more powerful, the DOOM community focused on unconventional platforms. This period saw the game running on early digital cameras, iPods, and custom-built FPGA hardware. It became a rite of passage for every new piece of consumer hardware to have a DOOM port.
The "Absurdist" Era (2015–Present)
In the last decade, the community shifted toward "absurdist" hardware. We have seen DOOM run on the touchbar of a MacBook Pro, inside a text editor, on a LEGO brick, and famously, on a hacked pregnancy test. The Sonoff Basic R2 port represents the current frontier: the "Internet of Things" (IoT) space. It is no longer about the hardware being capable of running the game; it is about the hacker’s ingenuity in stripping away all non-essential overhead to reach the bare metal.
Technical Analysis: Constraints and Engineering
The challenge of porting DOOM to a Sonoff switch is essentially a battle against memory and clock cycles. The original 1993 version of DOOM required roughly 4MB of RAM—a luxury the ESP8285 does not possess.
Memory Management and Rendering
[Piuppi]’s solution involves a sophisticated data-streaming process. The user must provide their own DOOM.WAD file, which is then parsed to extract only the essential textures and map geometry. The engine uses a technique called "fixed-point math" to handle the calculations for the 2.5D view, avoiding the need for a Floating Point Unit (FPU), which the ESP8285 lacks.
The Network Interface
The most innovative aspect of this project is the integration of the local network stack. The device serves as a lightweight web server. Users access the game through a standard browser, where the device streams the rendered frames. By using the browser as a "thin client," the Sonoff switch handles the heavy logic of the game state while the browser handles the final display output. This hybrid approach effectively bypasses the device’s lack of a physical screen.
Supporting Data and Documentation
The project is hosted on GitHub, complete with detailed documentation that allows users to replicate the process. The requirements are standard for an electronics enthusiast:
- Hardware: Sonoff Basic R2, a USB-to-TTL serial adapter for flashing the firmware, and a basic soldering iron.
- Software: The Arduino IDE or PlatformIO, the
Sonoff-Doomsource code, and a legitimate copy of the original DOOM data files.
The documentation emphasizes that the process is "involved," requiring a deep understanding of flash partitions. Because the ESP8285 has such limited storage, the user must carefully manage how much of the original DOOM game data is uploaded to the device. The repository also highlights the importance of the LwIP (Lightweight IP) stack in maintaining the network connection while the processor cycles are dedicated to the game engine.
Implications for Home Automation and Security
Beyond the entertainment value, the existence of "Sonoff-DOOM" raises interesting questions regarding the security and modularity of modern IoT devices.
The "Moddability" of IoT
The fact that a smart switch can be reprogrammed to run a high-performance game engine speaks to the open nature of the ESP8266/ESP8285 ecosystem. This accessibility has fueled the rise of custom firmwares like Tasmota and ESPHome, which allow users to reclaim control over their devices from manufacturer clouds.
Security Vulnerabilities
While DOOM is a harmless application, the ease with which a user can flash custom code onto a Sonoff switch highlights potential security risks. If a device can be forced to run a game, it can theoretically be forced to run a malicious script or act as a bridge for a network attack. The project serves as a practical demonstration of why firmware signing and secure boot processes are becoming standard in the enterprise sector, even as they remain elusive in the affordable DIY market.
The Future of "It Runs DOOM"
Is there an end to this trend? The developer community seems to think not. As noted in the project’s commentary, the shift is already moving toward more modern titles. With the recent discussions surrounding ports of Duke Nukem 3D and other mid-90s classics, the "It Runs DOOM" ethos is being replaced by a broader, more ambitious goal: "It Runs Everything."
Conclusion
The porting of DOOM to a Sonoff Basic R2 is a testament to the persistent curiosity of the human mind. It takes a device intended for the banal task of turning a light bulb on and off and turns it into a platform for one of the most culturally significant pieces of software ever created.
While you might not choose to play DOOM on your light switch for a marathon gaming session, the project serves as a reminder that modern technology is far more flexible—and far more vulnerable—than we often assume. As long as there is silicon, there will be hackers determined to find the hidden potential within, one "rip and tear" at a time. The Sonoff Basic R2 has officially joined the ranks of the legendary, proving that even in the world of smart home infrastructure, there is always room for a little bit of demon-slaying.
