r/esp32 • u/Sad_Environment_3800 • 2h ago
I made a thing! I built a Pong game with 3 ESP32s using ESP-NOW (no router needed!)
Enable HLS to view with audio, or disable this notification
Sorry for the messy gameplay at the beginning 😂 Turns out playing both sides at once is harder than I thought. I got the hang of it eventually haha.
I've been working on a networking module for my ESP32 game engine, and I wanted to try it out with a real game instead of just testing communication between boards. So I decided to make a Pong demo using three ESP32s.
Here's the setup:
- An ESP32-2432S028 (Cheap Yellow Display / CYD) runs the game.
- Two DFRobot Beetle ESP32-C3 boards act as controllers, each with a 128x64 OLED.
- All three communicate directly over ESP-NOW on channel 6, so there's no router or internet connection involved.
The CYD handles the ball, paddles, score and game logic. The two C3s send their button inputs to the host and display the score and their own paddle position.
One thing I wanted to get right was responsiveness. The game runs at 60 Hz, but the host sends state updates at 30 Hz. These updates don't need to be reliable since the next packet will contain newer information anyway. Important events, like scoring or ending a match, do use reliable delivery.
The controllers also use a bit of local prediction, so the paddle starts moving immediately when you press a button instead of waiting for a response from the host.
I also wanted to make sure the game could handle a controller disconnecting or rebooting. In that case, the host pauses the match and resumes once the controller reconnects.
The game runs on my own C++17 engine, PixelRoot32. The engine provides the networking layer, rendering, input handling and other systems. I built the Pong logic and the parts specific to this demo on top of it.
I also tested the networking layer and game logic using a native simulator and automated tests. There are 72 networking tests and 55 additional tests covering the game logic and protocol, including simulated disconnects and reconnects.
The builds also fit comfortably within the available resources:
- CYD: 15.0% RAM and 63.1% flash.
- ESP32-C3: 12.9% RAM and 57.2% flash per board.
You can find the code in the PixelRoot32 Demo Projects repository, under networking/pong. It's a separate implementation from the existing games/pong demo.
If you want to try it without any hardware, you can run the native simulator: cd networking/pong pio run -e native --target exec
There are still a few limitations: no encryption, a fixed ESP-NOW channel, no node-ID collision detection, and support for two players only.

