Community project

Portable ESP32 Game Console

Photo of Portable ESP32 Game Console
Generated with AI

Mohamed Sherif

Last updated November 29, 2026

Build a handheld gaming device powered by an ESP32 microcontroller, 2.8-inch capacitive touchscreen, and analog joystick. This portable console includes SD card storage for game assets, Class-D amplified audio output through a speaker, and rechargeable 18650 battery power with integrated charging and boost circuitry. The guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions to integrate all components into a 3D-printed enclosure.

The firmware demonstrates core functionality including display rendering, joystick input handling, tactile button debouncing, and I2S audio synthesis. Builders will learn how to interface multiple peripherals over SPI and I2C, manage power delivery from a single-cell lithium battery, and structure a game loop that responds to user input while generating audio feedback. All code and hardware specifications are included to get the console running immediately after assembly.

Wiring diagram

Wiring diagram for Portable ESP32 Game Console
Loading diagram…

Gather all the parts

QtyComponent
1

Waveshare 2.8inch Capacitive Touch LCD V2 (ST7789), 13-pin header

Console hardware as identified by the part name.

1

Adafruit MicroSD SPI/SDIO Breakout Board (3V Only)

MicroSD card breakout for adding file storage to a microcontroller project, wired over SPI (any MCU) or native SDIO (faster, needs SDIO hardware/firmware support like SAMD51). Board has no onboard regulator or level shifter, so it runs on 3.3V logic and power only — do not connect directly to a 5V system.

1

16 GB microSDHC, FAT32

Console hardware as identified by the part name.

1

PS2 Joystick Module (KY-023)

Two-axis analog thumb joystick module (KY-023 / PS2 style) with a push switch under the stick. Two 10 kOhm potentiometers give X and Y voltages that sit near half the supply at rest, and pressing the stick operates a digital switch. It runs from 3.3 to 5 V and connects through a five-pin GND, +5V, VRx, VRy, SW right-angle header.

1

Push Button

12×12 mm normally open tactile

Momentary push button switch

1

Push Button

12×12 mm normally open tactile

Momentary push button switch

1

Push Button

12×12 mm normally open tactile

Momentary push button switch

1

12×12 mm normally open tactile switch

12×12 mm normally open tactile

Active-low switch read on an input-only ADC-capable pin with external pull-up.

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

MAX98357A I2S Class-D Mono Amplifier Breakout

Adafruit MAX98357A breakout, default SD and GAIN

I2S-input Class-D mono audio amplifier IC on a compact breakout board. Accepts I2S digital audio input (BCLK, LRC, DIN) and drives a small speaker or transducer directly. No I2C/SPI control bus is needed. The amplifier supply range is 2.5V-5.5V, and the I2S input pins are compatible with 3.3V logic. SD/MODE controls shutdown and channel selection; GAIN selects 3 dB, 6 dB, 9 dB, 12 dB, or 15 dB gain.

1

8Ω Speaker

8 Ω, 2 W

Generic small 8Ω 0.5-3W loudspeaker (~28mm typical). Pair with an I2S amp (MAX98357A) or class-D amp (TPA3116D2) for usable volume; do not drive directly from a GPIO pin. Audio output for music/voice playback.

1

18650 Li-ion Cell

Protected 3.7 V / 4.2 V 2500 mAh; rated ≥1 A charge and ≥3 A discharge

18650 lithium-ion cell, nominal 3.7 V, ~2500 mAh. Common for higher-capacity portable / battery-bank style projects; needs a holder and protection / charger circuit.

1

18650 Holder

Single-slot holder sized for protected cell

Generic holder for one or two removable 18650 Li-ion cells. It is a mechanical/electrical power holder, not a charger or protection circuit; pair with a charger/BMS and regulator appropriate to the cell count.

1

T6845-C V1.0 USB power-bank charger and boost module

Micro-USB charging input; USB-A regulated output; single protected 4.2 V Li-ion cell.

1

Removable 5 V two-pole service connector, ≥2 A

Console hardware as identified by the part name.

1

Ceramic Capacitor

100 nF ceramic

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

Electrolytic Capacitor

10 µF, ≥10 V

Radial aluminium electrolytic capacitor bought by value and voltage rating, such as 10 µF, 100 µF or 1000 µF 10 V. It is polarised: the + lead goes to the higher voltage and the - lead, marked by the stripe on the sleeve, to the lower voltage or ground. It is mostly used for bulk filtering across a power rail, with a voltage rating comfortably above the rail.

1

Ceramic Capacitor

100 nF ceramic

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

Electrolytic Capacitor

10 µF, ≥10 V

Radial aluminium electrolytic capacitor bought by value and voltage rating, such as 10 µF, 100 µF or 1000 µF 10 V. It is polarised: the + lead goes to the higher voltage and the - lead, marked by the stripe on the sleeve, to the lower voltage or ground. It is mostly used for bulk filtering across a power rail, with a voltage rating comfortably above the rail.

1

Ceramic Capacitor

100 nF ceramic

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

Electrolytic Capacitor

10 µF, ≥10 V

Radial aluminium electrolytic capacitor bought by value and voltage rating, such as 10 µF, 100 µF or 1000 µF 10 V. It is polarised: the + lead goes to the higher voltage and the - lead, marked by the stripe on the sleeve, to the lower voltage or ground. It is mostly used for bulk filtering across a power rail, with a voltage rating comfortably above the rail.

Assemble it in 5 steps

1. Wire the 3.3 V screen and storage

Drive GPIO17 into LCD_BL only on the specified Waveshare board with its onboard backlight transistor. Follow the wiring diagram for the Waveshare V2 13-pin header and Adafruit 3 V-only SD breakout. Share clock and MOSI; leave the screen MISO and all touch lines disconnected. Install the two chip-select pull-ups and place both SD capacitors near the socket. Insert a FAT32-formatted card with power off.

2. Install the joystick and buttons

Feed the joystick 3.3 V even though its header says +5V. Identify the two switch contact groups on each tactile button with a continuity meter; use one leg from each group. Fit the external pull-ups on Select and joystick click.

3. Wire the amplifier and speaker

Match SPK+ to speaker + and SPK- to speaker -. Neither speaker wire is ground. Leave SD and GAIN at the Adafruit breakout defaults. Install the ceramic and electrolytic bypass capacitors near the amp and ESP32 supply pins; the electrolytic stripe faces ground.

4. Assemble and test the charging circuit separately

Use the documented T6845-C V1.0 with micro-USB input and USB-A output. Check holder polarity before installing the protected cell. Connect holder positive to B+ and negative to B-. Take regulated power from a USB-A power lead using VBUS and ground only; verify the lead with a meter rather than relying on wire colors. Disconnect the service feed when charging or plugging USB into the ESP32. Charge from a 5 V USB wall supply rated 2 A. Check module temperature, both rail voltages and current during startup, SD writes and tones, with a full and partly discharged cell. Check for idle auto-off. Do not qualify full-volume audio based on the quiet demo.

  • Do not charge while playing. Never join the charger output and the ESP32 USB supply. Do not use an unprotected cell or a board with different terminals.

5. Fit the tested parts into a printed enclosure

Lay out the screen in the center, joystick on the left, A and B on the right, and Start and Select below the screen. Measure actual board outlines, connector clearances and hole centers before making the print. Use insulated standoffs, a retained cell holder, ventilation over the charger, a speaker grille, and access to the SD card and service connector. Provide a service opening for the removable power feed and arrange a mechanical access cover so the ESP32 USB cannot be plugged in until the service feed is removed. Leave plastic clearance around the antenna and strain-relieve the wires.

Review all connections

1. Connections between "lcd" and "ESP32"

FunctionlcdESP32
powerVCC3V3
groundGNDGND
spiMOSIGPIO 23
spiSCLKGPIO 18
spiLCD_CSGPIO 21
digitalLCD_DCGPIO 22
digitalLCD_RSTGPIO 16
pwmLCD_BLGPIO 17

2. Connections between "sd" and "ESP32"

FunctionsdESP32
power3V3V3
groundGNDGND
spiCLKGPIO 18
spiMISOGPIO 19
spiMOSIGPIO 23
spiCSGPIO 13

3. Connections between "stick" and "ESP32"

FunctionstickESP32
power+5V3V3
groundGNDGND
analogVRXGPIO 34
analogVRYGPIO 35
digitalSWGPIO 4

4. Connections between "a" and "ESP32"

FunctionaESP32
digitalSIGNALGPIO 27
groundGNDGND

5. Connections between "b" and "ESP32"

FunctionbESP32
digitalSIGNALGPIO 14
groundGNDGND

6. Connections between "start" and "ESP32"

FunctionstartESP32
digitalSIGNALGPIO 32
groundGNDGND

7. Connections between "select" and "ESP32"

FunctionselectESP32
analogSIGNALGPIO 36
groundGNDGND

8. Connections between "r_tft" and "ESP32"

Functionr_tftESP32
powerP13V3
digitalP2 → Waveshare 2.8inch Capacitive Touch LCD V2 (ST7789), 13-pin header LCD_CSEXT

9. Connections between "r_sd" and "ESP32"

Functionr_sdESP32
powerP13V3
digitalP2 → Adafruit MicroSD SPI/SDIO Breakout Board (3V Only) CSEXT

10. Connections between "r_select" and "ESP32"

Functionr_selectESP32
powerP13V3
digitalP2 → 12×12 mm normally open tactile switch SIGNALEXT

11. Connections between "r_sw" and "ESP32"

Functionr_swESP32
powerP13V3
digitalP2 → PS2 Joystick Module (KY-023) SWEXT

12. Connections between "amp" and "ESP32"

FunctionampESP32
powerVIN → Removable 5 V two-pole service connector, ≥2 A OUTEXT
groundGNDGND
dataBCLKGPIO 26
dataLRCGPIO 25
dataDINGPIO 33
dataSPK+ → 8Ω Speaker POSEXT
dataSPK- → 8Ω Speaker NEGEXT

13. Connections between "holder" and "ESP32"

FunctionholderESP32
powerBAT+ → T6845-C V1.0 USB power-bank charger and boost module B+EXT
groundBAT- → T6845-C V1.0 USB power-bank charger and boost module B-EXT

14. Connections between "cell" and "ESP32"

FunctioncellESP32
power+V → 18650 Holder BAT+EXT
groundGND → 18650 Holder BAT-EXT

15. Connections between "charger" and "ESP32"

FunctionchargerESP32
powerUSB_VBUS → Removable 5 V two-pole service connector, ≥2 A INEXT
groundUSB_GNDGND

16. Connections between "disconnect" and "ESP32"

FunctiondisconnectESP32
powerOUT5V
groundGNDGND

17. Connections between "cer_esp" and "ESP32"

Functioncer_espESP32
power15V
ground2GND

18. Connections between "bulk_esp" and "ESP32"

Functionbulk_espESP32
power+5V
ground-GND

19. Connections between "cer_amp" and "ESP32"

Functioncer_ampESP32
power15V
ground2GND

20. Connections between "bulk_amp" and "ESP32"

Functionbulk_ampESP32
power+5V
ground-GND

21. Connections between "cer_sd" and "ESP32"

Functioncer_sdESP32
power13V3
ground2GND

22. Connections between "bulk_sd" and "ESP32"

Functionbulk_sdESP32
power+3V3
ground-GND

Deploy the firmware

#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_ST7789.h>
#include <driver/i2s.h>
constexpr int TFT_CS=21, SD_CS=13, TFT_BL=17, STICK_SW=4;
constexpr int16_t DEMO_TONE_LEVEL=2200; // Keep demo tones well below full scale.
Adafruit_ST7789 lcd(&SPI,TFT_CS,22,16);
struct Key { int pin; bool raw=false, stable=false; uint32_t since=0; };
Key keys[]={{27},{14},{32},{36},{39}};
bool mounted=false,audio=false; int x=160,y=120,cx,cy; unsigned score=0;
void beep(int hz) {
 if(!audio)return;
 int16_t samples[256]; unsigned phase=0;
 for(int j=0;j<10;j++) {
  for(int i=0;i<256;i+=2){phase=(phase+hz)%16000; samples[i]=samples[i+1]=j==9?0:(phase<8000?DEMO_TONE_LEVEL:-DEMO_TONE_LEVEL);}
  size_t written=0; if(i2s_write(I2S_NUM_0,samples,sizeof(samples),&written,pdMS_TO_TICKS(30))!=ESP_OK)break;
 }
}
void initAudio(){
 i2s_config_t c={}; c.mode=(i2s_mode_t)(I2S_MODE_MASTER|I2S_MODE_TX); c.sample_rate=16000;
 c.bits_per_sample=I2S_BITS_PER_SAMPLE_16BIT;c.channel_format=I2S_CHANNEL_FMT_RIGHT_LEFT;
 c.communication_format=I2S_COMM_FORMAT_STAND_I2S;c.dma_buf_count=4;c.dma_buf_len=128;c.tx_desc_auto_clear=true;
 i2s_pin_config_t p={};p.mck_io_num=I2S_PIN_NO_CHANGE;p.bck_io_num=26;p.ws_io_num=25;p.data_out_num=33;p.data_in_num=I2S_PIN_NO_CHANGE;
 audio=i2s_driver_install(I2S_NUM_0,&c,0,nullptr)==ESP_OK && i2s_set_pin(I2S_NUM_0,&p)==ESP_OK;
}
void status(const char* msg){lcd.fillRect(0,0,320,62,ST77XX_BLACK);lcd.setCursor(6,5);lcd.setTextColor(ST77XX_WHITE);lcd.setTextSize(2);lcd.println("ESP32 Handheld");lcd.printf(" Score %u | SD %s\n",score,mounted?"OK":"--");lcd.setTextSize(1);lcd.printf(" %s\n A:+  B:reset  Start:save  Select:load",msg);}
void load(){if(!mounted){status("No SD card");return;}File f=SD.open("/save.txt");if(!f){status("No save yet");return;}long n=f.parseInt();f.close();if(n>=0 && n<=999999){score=n;status("Loaded");}}
void setup(){
 Serial.begin(115200);
 for(int i=0;i<5;i++)pinMode(keys[i].pin,i<3?INPUT_PULLUP:INPUT);
 pinMode(TFT_BL,OUTPUT);digitalWrite(TFT_BL,LOW);
 for(int pin:{TFT_CS,SD_CS}){pinMode(pin,OUTPUT);digitalWrite(pin,HIGH);}
 SPI.begin(18,19,23,SD_CS);lcd.init(240,320);lcd.setSPISpeed(16000000);lcd.setRotation(1);lcd.fillScreen(ST77XX_BLACK);digitalWrite(TFT_BL,HIGH);
 mounted=SD.begin(SD_CS,SPI,4000000);initAudio();
 for(int i=0;i<16;i++){cx+=analogRead(34);cy+=analogRead(35);}cx/=16;cy/=16;
 status("Move the stick");
 if(mounted){File f=SD.open("/level.txt");if(f){int a=f.parseInt(),b=f.parseInt();f.close();if(a>=6 && a<=313 && b>=69 && b<=233){x=a;y=b;}}}
 lcd.fillCircle(x,y,5,ST77XX_GREEN);beep(440);
}
void loop(){
 static uint32_t last=0;uint32_t now=millis();if(now-last<16)return;last=now;
 for(int i=0;i<5;i++){auto &k=keys[i];bool down=!digitalRead(k.pin);
 if(down!=k.raw){k.raw=down;k.since=now;}if(k.raw==k.stable || now-k.since<25)continue;k.stable=k.raw;if(!k.stable)continue;
 switch(i){case 0:if(score<999999)score++;status("A pressed");break;case 1:score=0;status("B pressed");break;
 case 2:if(mounted){File f=SD.open("/save.txt",FILE_WRITE);bool ok=false;if(f){ok=f.println(score)>0;f.close();}status(ok?"Saved":"Save failed");}else status("No SD card");break;
 case 3:load();break;case 4:status("Stick clicked");break;}beep(520+i*100);}
 int dx=analogRead(34)-cx,dy=analogRead(35)-cy;
 int nx=constrain(x+(dx>380?3:dx< -380?-3:0),6,313),ny=constrain(y+(dy>380?3:dy< -380?-3:0),69,233);
 if(nx!=x||ny!=y){lcd.fillCircle(x,y,5,ST77XX_BLACK);x=nx;y=ny;lcd.fillCircle(x,y,5,ST77XX_GREEN);}
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik