ESP32 Handheld Game Console

by 陳亮 in Circuits > Electronics

49731 Views, 246 Favorites, 0 Comments

ESP32 Handheld Game Console

IMG_7782.jpg
ESP32 handheld play demo

This instructables show how to use a ESP32 and ATtiny861 to build a NES emulator game console.

Hardware Preparation

IMG_7245.jpg
IMG_7244.jpg
IMG_7246.jpg
IMG_7365.jpg
IMG_7616.jpg
IMG_7347.jpg
IMG_7614.jpg
IMG_7617.jpg
IMG_7618.jpg

ESP32 Dev Board

This time I am using a TTGO T8 ESP32 dev board. This board have built-in Lipo charging and regulating circuit, it can help reduce the extra components.

Display

This time I am using a 2.4" IPS LCD. The driver controller is ST7789V and the resolution is 320 x 240. This resolution is best fit for NES emulator 252 x 224 resolution.

Battery

This time I am using a 454261 Lipo battery. 4.5 mm is the thickness of ESP32 dev board, and 61 mm is the width of the board.

Pin Header

A 4 pins male round pin header and a 4 pins female round pin header for connecting I2C gamepad.

PETG Plate

A small PET/PETG plate for supporting the dev board and Lipo battery, you can easily find it in product packing.

Multiple Purpose PCB

2 PCB required, 1 0.4 mm thick for supporting the Display, 1 1.2 mm thick for a I2C gamepad.

Buttons

A 5 directions button, 2 small buttons for Select and Start and 2 for A and B button.

I2C Gamepad Controller

This time I use a ATtiny861 microcontroller as an I2C gamepad controller.

Others

1 SMD 12 Ohm resistor, a ISP programmer (e.g. TinyISP)

Software Preparation

螢幕快照 2019-05-05 下午3.21.54.png
螢幕快照 2019-05-05 下午3.25.19.png
螢幕快照 2019-05-05 下午10.25.27.png

Arduino IDE

Download and install Arduino IDE if not yet: https://www.arduino.cc/en/Main/Software

ATTinyCore Support

Follow the installation steps to add ATTinyCore support if not yet: https://github.com/SpenceKonde/ATTinyCore/blob/mas...

ESP-IDF

Follow the ESP-IDF get started guide to setup the development environment if not yet: https://docs.espressif.com/projects/esp-idf/en/sta...

3D Printing

螢幕快照 2019-05-05 下午3.10.12.png

Download and print the case: https://www.thingiverse.com/thing:3591170

LCD Support

IMG_7344.jpg
IMG_7345.jpg

Cut a 24 x 27 holes 0.4 mm PCB for LCD support. Remember reserve some space for folding LCD FPC. Then use some double side adhesive tape fix the LCD on the PCB.

Prepare PETG Plate

IMG_7348.jpg
IMG_7349.jpg

Cut out a 62 mm x 69 mm PETG plate for dev board and Lipo battery support.

Fix ESP32 Dev Board

IMG_7350.jpg

Use double side adhesive tape to fix dev board on the PETG plate.

Fix Lipo Battery

IMG_7351.jpg

Use double side adhesive tape to fix Lipo battery besides the dev board.

Connect Battery & Dev Board

IMG_7352.jpg

Prepare Display Pins

IMG_7346.jpg

LCD display have many variation form different vendors. Please obtain the correct datasheet and read it before any patch and connection.

Some pins are reserved for touch panel. Since this LCD do not have touch panel, simply cut out those pins can reduce the disturbance.

Connect GND Pins

IMG_7353.jpg
IMG_7354.jpg

In most case, there are few pins require connect to GND. To reduce soldering effort, I cut a copper tape shape to reach all the GND pins and then soldering altogether.

Connect Vcc Pins

IMG_7355.jpg

There are 2 pins required connect to Vcc, LCD power and LED power. According to data sheet, LCD power can direct connect to dev board 3.3 V pin but LED power operate a little bit lower than 3.3 V. So it is better add a SMD resistor in the middle, e.g. 12 Ohm resistor.

Connect LCD & Dev Board Support

IMG_7356.jpg

use tape connect LCD support and dev board support together. Both support should reserve around 5 mm gap for folding.

Connect SPI Pins

IMG_7357.jpg

Here are the connection summary:

LCD     ESP32
GND  -> GND
RST  -> GPIO 33
SCL  -> GPIO 18
DC   -> GPIO 27
CS   -> GPIO 5
SDI  -> GPIO 23
SDO  -> not connected
Vcc  -> 3.3 V
LED+ -> 12 Ohm resistor -> 3.3 V
LED- -> GND

Flash Program

螢幕快照 2019-05-05 下午10.45.05.png
螢幕快照 2019-05-05 下午10.58.56.png
螢幕快照 2019-05-05 下午10.59.03.png
螢幕快照 2019-05-05 下午10.59.10.png
螢幕快照 2019-05-05 下午10.59.16.png
螢幕快照 2019-05-05 下午10.59.45.png
IMG_7362.jpg
  1. Download the source code at GitHub: https://github.com/moononournation/esp32-nesemu
  2. Under source code folder, run "make menuconfig"
  3. Select "Nofrendo ESP32-specific configuration"
  4. Select "Hardware to run on" -> "Custom Hardware"
  5. Select "LCD Type" -> "ST7789V LCD"
  6. Fill pin settings: MISO -> -1, MOSI -> 23, CLK -> 18, CS -> 5, DC -> 27, RST -> 33, Backlight -> -1, IPS -> Y
  7. Exit and Save
  8. Run "make -j5 flash"
  9. Run "sh flashrom.sh PATH_TO_YOUR_ROM_FILE"

I2C Connector

IMG_7363.jpg
IMG_7366.jpg
IMG_7367.jpg
IMG_7368.jpg
IMG_7369.jpg

Breakout the I2C pins, ESP32 default I2C pins are:

Pin 1 (SCL) -> GPIO 22
Pin 2 (SDA) -> GPIO 21
Pin 3 (Vcc) -> 3.3 V (no 5 V power while powered by Lipo battery)
Pin 4 (GND) -> GND

Assembly Part 1

ESP32 Handheld Console Assembly Part 1

Follow the video steps to fold and squeeze all the parts into the case.

Prototype I2C Gamepad

IMG_7584.jpg
IMG_7590.jpg
IMG_7603.jpg
IMG_7601.jpg
IMG_7602.jpg

The program for the I2C Gamepad is very simple, only 15 lines of code. But it is a little bit hard to reprogram the ATtiny861 after soldering, so it is better test it on the breadboard first.

Download, compile and flash the program from GitHub: https://github.com/moononournation/attiny861_i2c_...

Build I2C Gamepad

IMG_7615.jpg
IMG_7619.jpg
IMG_7620.jpg
IMG_7621.jpg
IMG_7622.jpg

Here are the connection Summary:

ATtiny861       Button
GND          -> All buttons one pin
Pin 20 (PA0) -> Up button
Pin 19 (PA1) -> Down button
Pin 18 (PA2) -> Left button
Pin 17 (PA3) -> Right button
Pin 14 (PA4) -> Select button
Pin 13 (PA5) -> Start button
Pin 12 (PA6) -> A button
Pin 11 (PA7) -> B button
Pin 6 (GND) -> I2C male pin header pin 4
Pin 5 (Vcc) -> I2C male pin header pin 3
Pin 3 (SCL) -> I2C male pin header pin 1
Pin 1 (SDA) -> I2C male pin header pin 2

Assembly Part 2

ESP32 Handheld Console Assembly Part 2
IMG_7672.jpg

Follow the video steps to install the cover and the I2C gamepad to the main body.

Optional: Audio Breakout Pins

IMG_7702.jpg
IMG_7703.jpg
IMG_7763.jpg
ESP32 NES emulator with headphones sound output

ESP32 dev board Pin 25 and 26 is outputting the analog audio signal, it is very easy to breakout the these 2 pins and also power pins (3.3 V and GND) on the top. Then you can patch a earphone to plug on it. Or even you can add an audio amplifier module with speaker to play it loud.

What's Next?

IMG_7701.jpg

NES emulator is not the only interesting thing you can make with ESP32. E.g. you can build a micro python console with it. The only component you need to change is from I2C gamepad to I2C keyboard. I think it is not so difficult to make it with a ATtiny88 controller. You may follow my twitter to see the status.