Esplora X M5Stack

by 陳亮 in Circuits > Arduino

7895 Views, 43 Favorites, 0 Comments

Esplora X M5Stack

IMG_7587.jpg

This instructables show how to combine Arduino Esplora and M5Stack to make a NES game console.

What Is Arduino Esplora?

螢幕快照 2019-04-20 下午11.41.31.png

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.

Ref.: https://store.arduino.cc/usa/arduino-esplora

What Is M5Stack?

螢幕快照 2019-04-20 下午11.42.49.png
螢幕快照 2019-04-20 下午11.44.05.png

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.:

https://www.kickstarter.com/projects/179167367/m5s...

https://m5stack.com/

Why Play Retro Game With ESP32?

IMG_5679.jpg
IMG_5784a.jpg

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.

Hardware Preparation

螢幕快照 2019-04-21 上午8.22.37.png
螢幕快照 2019-04-21 上午8.23.27.png
ORG_DSC07617.jpg
螢幕快照 2019-04-21 上午8.27.05.png

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.

Software Preparation

螢幕快照 2019-04-10 下午3.58.58.png

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:

https://docs.espressif.com/projects/esp-idf/en/sta...

Program I2C Gamepad

螢幕快照 2019-04-21 下午3.29.31.png
螢幕快照 2019-04-21 下午3.26.58.png

I have written a simple program to read the joystick and buttons input and translate it into I2C message.

Here is the program steps:

  1. Download esplora-i2c-gamepad.ino at GitHub: https://github.com/moononournation/esplora-i2c-gam...
  2. Connect Esplora to the computer
  3. Open Arduino
  4. Upload program

Breakout Esplora I2C

IMG_7224.jpg
螢幕快照 2019-04-21 上午8.15.59.png
Arduino_Esplora_pinout.png

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.

Ref.: http://wiki.seeedstudio.com/Grove_System/

Use Pin Headers to Fix M5Stack on Esplora

IMG_7215.jpg
IMG_7214.jpg
core_base_05.png

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.

Connect I2C Pins

IMG_7225.jpg
basic_07.png

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.

Program M5Stack

螢幕快照 2019-04-22 下午10.44.28.png
螢幕快照 2019-04-21 上午12.02.05.png
螢幕快照 2019-04-21 上午12.02.49.png
螢幕快照 2019-04-21 上午12.03.02.png

  1. Download revised version of esp32-nesemu from GitHub: https://github.com/moononournation/esp32-nesemu
  2. Under esp32-nesemu, run "make menuconfig"
  3. Enter "Nofrendo ESP32-specific configuration" submenu
  4. Select "Hardware to run on" to "M5Stack"
  5. Enable "Analog audio on GPIO26"
  6. Select "Controller type" to "I2C Gamepad"
  7. Exit menuconfig
  8. Run "make -j5 all" to compile the program
  9. Connect M5Stack to the computer
  10. Run "make flash" to flash the compiled binary to M5Stack
  11. Run "sh flashrom.sh PATH_TO_YOUR_NES_ROM_FILENAME"

Enjoy!

IMG_7588.jpg

It's time to play your favour game!