This instructables show how to combine Arduino Esplora and M5Stack to make a NES game console.
Step 1: What Is Arduino Esplora?
Arduino Esplora is an Atmega32U4 AVR microcontroller board.
It is unique Arduino boards, because it built-in various input sensors out-of-the-box, including a joystick, 4 push buttons, a slider, a temperature sensor, an accelerometer, a microphone, a light sensor, etc.
And also Arduino IDE provided various example for using all of it.
This time I will program Esplora as an I2C slave device to act as an I2C gamepad.
Step 2: What Is M5Stack?
M5Stack start from a kickstarter project at 2017, ESP32 core, built-in 2.0" color LCD, tiny 5 cm form factor, support stackable modules and grove I2C modules.
Now it already have various core models, tens of stackable modules and also support tons of I2C Grove modules.
Step 3: Why Play Retro Game With ESP32?
It is a very popular topic using Raspberry Pi to make a retro game console with Retropie distribution.
It do the job very well, but the most notable problem is the boot time.
I do not want to wait over half a minute to enter a retro game, a real game console no need to wait for this!
Then I found esp32-nesemu no need to wait for boot, so I try to use M5Stack to build a NES game console.
Step 4: Hardware Preparation
The official product is obsoleted but it is still very easy to find a clone on the web.
Any M5Stack core with 2.0" LCD should be ok.
2 pins male-male pin header and 6 pins male-female pin header.
Grove Conversion Cable
Normal 4 pin Male Jumper to Grove 4 pin Conversion Cable preferred. I did not have this cable in hand, so I just patch 1 to connect SCL and SDA pins myself.
Step 5: Software Preparation
Download and install Arduino IDE if not yet:
Follow the setup guide to install ESP-IDF if not yet:
Step 6: Program I2C Gamepad
I have written a simple program to read the joystick and buttons input and translate it into I2C message.
Here is the program steps:
- Download esplora-i2c-gamepad.ino at GitHub: https://github.com/moononournation/esplora-i2c-gam...
- Connect Esplora to the computer
- Open Arduino
- Upload program
Step 7: Breakout Esplora I2C
Arduino Esplora have most I/O and user interfaces, but ironically it is lack of I2C (Grove System) breakout pins.
Fortunately, the I2C pins in the ATMega32U4 are not yet used for other purpose. And also the left hand side pin header on the Esplora is "not currently connected", we can use this pin header to break out the I2C pins.
Simply use 2 wires and some soldering work to connect ATMega32U4 pin 18 (SCL) and pin 19 (SDA) to the left pin header.
Step 8: Use Pin Headers to Fix M5Stack on Esplora
The most 2 bottom pins at the Esplora right side pin header is GND and 5V, it can matched with M5Stack core base pinout. So we can bend a 2 pins male-male pin header to connect each other.
The Esplora left side pin header not connected anything, the previous steps used 2 top most pins as I2C break out. There are remain 6 pins, we can bend a 6 pins male-female pin header to fix the M5Stack on the Esplora.
Step 9: Connect I2C Pins
Esplora and M5Stack communicate with I2C protocol, M5Stack act as I2C master and Esplora is I2C slave.
Since GND and 5V already connected at the previous steps, only SCL and SDA required further connection.
Step 10: Program M5Stack
- Download revised version of esp32-nesemu from GitHub: https://github.com/moononournation/esp32-nesemu
- Under esp32-nesemu, run "make menuconfig"
- Enter "Nofrendo ESP32-specific configuration" submenu
- Select "Hardware to run on" to "M5Stack"
- Enable "Analog audio on GPIO26"
- Select "Controller type" to "I2C Gamepad"
- Exit menuconfig
- Run "make -j5 all" to compile the program
- Connect M5Stack to the computer
- Run "make flash" to flash the compiled binary to M5Stack
- Run "sh flashrom.sh PATH_TO_YOUR_NES_ROM_FILENAME"
Step 11: Enjoy!
It's time to play your favour game!
This is an entry in the
Arduino Contest 2019