Activity

gabrielpereiratoribio

Shipped this project!

Hours: 6.58
Cookies: 🍪 149
Multiplier: 22.62 cookies/hr

I’ve created a wireless Pong game that works without Wi-Fi by connecting two ESP32s using the ESP-NOW protocol.
The biggest challenge was overcoming input lag. I fixed it by making one ESP32 the ‘Master’ that processes all the logic, while the other acts as a ‘Slave’ that just receives data.
This was my first time using MicroPython and my first hardware project based on Python. I’m really proud of how it turned out because ESP-NOW isn’t commonly used, but it’s a super efficient way to communicate between devices. I definitely plan to use it again soon!

gabrielpereiratoribio

I’ve finished the website where you can see how it works. I didn’t know I needed to make a website to show how it works, this discourages me from making more hardware projects. My next project will be an app. The hardest thing about this project was the CSS because I have almost never used it. Luckily, I just had to make squares and text. At first, I wanted to draw the cables, but I gave up because I couldn’t figure out how to do it, so I added a button where you can see the schematics. This project helped me learn the ESP-NOW protocol, which I plan to use in future projects. All the documentation is on GitHub, so anyone can replicate it or improve it. It also helped me learn MicroPython, which was much easier for me than C++ in Arduino IDE.

Attachment
Attachment
0
gabrielpereiratoribio

I realized that I need to create a way for people to experience it, so I’m building a website that simulates the project. I don’t know anything about CSS or HTML, so I’m sure this will take a long time since I’m starting from scratch. I’ve been trying to make a website where you can interact with it and see how it works.

Attachment
1

Comments

Foxreef
Foxreef about 2 months ago

It’s pretty nice that you also want to make a browser version, but you should probably create a separate project for that

gabrielpereiratoribio

THE PROJECT IS FINISHED!
Today at school I tested the game by asking a friend to go as far as he could to see the maximum distance. It worked, but sometimes it lagged when there was a lot of distance and walls in between.
I’ve completed the README so now anyone can follow the project. It’s my first time writing a README, so if something isn’t clear, let me know. I’ll publish the project and, in the future, I’ll probably improve some things, like making the game more complex or building a case for it. For now it’s functional.
This project made me realize the potential the ESP-NOW protocol has, and I already have ideas for what to build next.
Check out the video to see how it works.

Attachment
1

Comments

yusufumben09
yusufumben09 about 2 months ago

Perfect use for my spare 2 esp32s, cool project

gabrielpereiratoribio

The problem was easier than I initially thought. I simply had to add the function that draws the players directly into the actual library, SSD1306 (as shown in the first picture). Once I added this function, the game improved significantly, but it still didn’t work perfectly it had a small amount of lag.

The solution was to increase the I2C speed to 1 MHz; before, it was running at 400 kHz. After this change, the game now works perfectly without any noticeable lag, and it can be played anywhere.

Next, I will focus on writing the README and creating the actual circuit schematics, a step I probably should have done earlier.

Attachment
0
gabrielpereiratoribio

I have finished the logic, i had already the game done i just had to implement the button logic. The problem I have had is that this code is funcional but having to iterate to draw the character uses a lot of resources so on one screee it works well and on the other it lags, I iterate because I know I can’t use the drawing functions of the library because for some reason in python they do not work and only work in c++ I could take my code and tell an ai to translate it from python to c++ but that is not the goal because I would not understand anything since I do not know c++, I will try to fix it but if it does not work I will have no choice but to pass the code to c++ for now micropython is not working properly for me.

Attachment
0
gabrielpereiratoribio

Before starting the game logic, I wanted the esp32 to run without being connected to the computer, the code was not running as it should. What I did to fix it was just rename the files to main, the problem was that the esp32 was not executing the code because it was not named main.py. Now the code runs perfectly, so now you can play without being in the same room, once was done with that I could start with the actual game

Attachment
0
gabrielpereiratoribio

During these first 25 minutes, I was trying to communicate the two ESP32s. On both screens, I put a text that says ‘Released’ or ‘Pressed’, if a button is pressed, it should be shown on both screens. I decided that one ESP32 will run the game logic and send the data to the other to avoid lag and prevent desync issues.

The first problem I had to fix was that the main ESP32 was sending its button info and the other was receiving it, but not the other way around. I read the code and found that the problem was a logic error, the screen was being cleared just a millisecond after receiving the input, so the text didn’t show even if the button was pressed. Once I fixed the logic, it still didn’t work because the buttons weren’t connected to the pins I intended to use, so that was probably the main problem at the beginning. Now I just have to implement the button logic the the game logic. The most difficult part will be sending the thata, I hope it’s easier than I think.

0
gabrielpereiratoribio

I’m working on my first project! This is so exciting. I can’t wait to share more updates as I build.

Attachment
0