Introduction: Esplora X M5Stack
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.
Ref.:
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
Arduino Esplora
The official product is obsoleted but it is still very easy to find a clone on the web.
M5Stack
Any M5Stack core with 2.0" LCD should be ok.
Pin Headers
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
Arduino IDE
Download and install Arduino IDE if not yet:
https://www.arduino.cc/en/Main/Software
ESP-IDF
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!

Participated in the
Arduino Contest 2019
15 Comments
1 year ago on Introduction
link no longer leads to git hub also when looked up on github file is differnt from instructions on your other esp32 nes projects no cmake.txt file so can not complete with new version of esp-idf
Reply 1 year ago
Yes, it is a little bit old. You may try this instead: https://www.instructables.com/Camera-Robot-Controller/
Question 3 years ago
I've managed to make it work correctly, but for some reason the colors of the screen are inverted. Do you think there is any solution?
Answer 3 years ago
I have just exposed IPS (invert color) setting, please pull update and make menuconfig to toggle the setting.
Reply 3 years ago
Thank you! But I managed to solve it by modifying the file "spi_lcd.c" according to a problem similar of another user.
Another question I have is that the M5STACK has a high pitched noise. I don't know why it may be due, but it's quite annoying. Is there a way to lower the audio gain?
Reply 3 years ago
how did you invert the colors back? using an m5stack with the nes emulator. i've looked in some of the files (including spi_lcd.c) and i can't figure out how to toggle the invert colors off. help!
Reply 3 years ago
toggle IPS option while make menuconfig
Reply 3 years ago
I guess I dont understand...but thanks for replying. Where is this? My experience with M5stack is zero. All I've done is use the esp32 flashing tool to upload nes roms...not sure where the config files are
Reply 3 years ago
you should read and follow the above steps
Reply 3 years ago
Thanks but I am not trying to build anything. Just bought an m5 stack faces kit and put some NES roms on it and the colors are all inverted. That's all I am trying to do
Reply 3 years ago
I think you should seek M5Stack support instead.
Reply 3 years ago
Thanks! I was actually just hoping Jorge Galarza would chime in. He fixed the same problem with his M5 stack and commented above.
Reply 3 years ago
Hi! Sorry if I haven't answered before. I solved the problem by modifying some attributes of the DRAM memory in the "spi_lcd.c" file. Since I don't remember the changes I made, I'm going to share a Drive link to this file: https://drive.google.com/file/d/1JMDDReZExSnrLxygS...
I will also include a link with all the files I used for the project: https://drive.google.com/file/d/17Ezu8_MOhqkemETGp...
I hope this helps you!
Question 3 years ago
In step 9, the two pins connected to the Esplora are the ones marked with a rectangle in this pic? How did you connected them like in your pic from step 9?
Answer 3 years ago
bend the male pin headers in right angle