Esp32 Keyboard



ESP32 can perform as a complete standalone system or as a slave device to a host MCU, reducing communication stack overhead on the main application processor. ESP32 can interface with other systems to provide Wi-Fi and Bluetooth functionality through its SPI / SDIO or I2C / UART interfaces. Bluetooth HID (Human Interface Device) is the protocol used by regular Bluetooth keyboard and mice and its possible to emulate this with just an ESP32, which is great! With some ESP32 development boards starting at less than $5. delivered, this is a really inexpensive and simple way to create wireless custom keyboards such as a Macro keypads. While the ESP32 boasts an extensive feature list (Wikipedia), the biggest feature that draws the eye is the built-in bluetooth v4.2 with BLE support. But that statement can be a misleading, while the hardware is there, the software support for using Bluetooth is missing. Very nicely designed boards, works well and easy to build. Great platform for the ESP32/ FabGL, easy to construct. Just be careful to grab the BOM for the latest version of the board. Super nice seller, helped me out with the SD card sockets which were backordered thru vendors.

  • 1Features
    • 1.3'Chip' on the module
  • 2Video DAC LTSpice Simulation
  • 3Headers (Rev 1 board)
    • 3.2H2 - 5V SRC Select Jumper (Rev 1 Board)
  • 4Connectors (Rev 1 board)
    • 4.3J2 - FTDI #1 - Rev 1
    • 4.4J6 - FTDI #2 - Rev 1
  • 5Headers (Rev 2 board)
  • 6Connectors (Rev 2 board)
    • 6.6J2 - FTDI #1 - Rev 2
    • 6.7J3 - FTDI #2 - Rev 2
  • 8FabGL GPIOs assignment summary - fabgl dev board rev2
  • 9Software
    • 9.2FabGL

Features[edit]

  • ESP32 Module
  • 6-bit VGA color
    • 2:2:2 R:G:B
  • 2 x PS-2 DIN connectors
    • 5V mouse/keyboard
    • 3.3V to 5V level shifters
      • Better than 5V keyboard with series resistors
    • 10K pull-ups on both sides
  • 2 x FTDI connectors
  • 5V DC Jack
  • 3.3V regulator (optional)
  • GVS pins for extra ESP32 pins
  • 95x95mm form factor
  • 6-32 mounting holes

ESP-32 Module[edit]

  • Uses the ESP32 DevKit ESP32-WROOM GPIO Pinout
  • On board Blue LED = Arduino Pin 2
  • There are various modules out there with different pinouts, but this card uses this one

ESP-32 Module Pinout[edit]

'Chip' on the module[edit]

ESP32 Pin Usage - Rev 1[edit]

ESP32 Pin Usage - Rev 2[edit]

Module Features[edit]

  • Architecture: Xtensa Dual-Core 32-bit LX6
  • CPU frequency: up to 240MHz
  • Total RAM available: 528KB (part of it reserved for system)
  • BootROM: 448KB
  • Internal FlashROM: none
  • External FlashROM: code and data, via SPI Flash; usual size 4MB
  • GPIO: 34 (GPIOs are multiplexed with other functions, including external FlashROM, UART, etc.)
  • UART: 3 RX/TX UART (no hardware handshaking), one TX-only UART
  • SPI: 4 SPI interfaces (one used for FlashROM)
  • I2C: 2 I2C (bitbang implementation available on any pins)
  • I2S: 2
  • ADC: 12-bit SAR ADC up to 18 channels
  • DAC: 2 8-bit DACs
  • RMT: 8 channels allowing accurate pulse transmit/receive
  • Programming: using BootROM bootloader from UART - due to external FlashROM and always-available BootROM bootloader, the ESP32 is not brickable

Video DAC LTSpice Simulation[edit]

  • Video is 2:2:2 - R:G:B

Summing Resistor DAC[edit]

  • 5% resistors are 'good enough'
  • 1V into 75 Ohm VGA load
  • 3.3V drive
  • ESP32 has 40 mA drive
    • Uses 10 mA (max)
    • R4 = 1.2 mA to -10 mA
    • R3 = 1.1 mA to -5.3 mA
  • Output in 4 steps
    • 0V
    • 0.3V
    • 0.65V
    • 0.96V

Headers (Rev 1 board)[edit]

H1 - 3.3V SRC select[edit]

  • 1-2 = Get 3.3V from ESP32 on-board regulator
  • 2-3 = Get 3.3V from on-board regulator (Default)

H2 - 5V SRC Select Jumper (Rev 1 Board)[edit]

  • 5V power options for the 5V to 3.3V regulator
  • 2x4 header
  • Care must be taken to install the correct jumpers
  • USB jumper sends out 5V when a USB cable is connected to the ESP32 module

Power from DC Jack[edit]

  • Do not connect USB cable when the DC jack is used
  • 1-2 = VUSB - Install - Power to ESP32
  • 3-4 = DCIN - Install - Power comes from DC jack
  • 5-6 = FTDI5V_1 - Do not install
  • 7-8 = FTDI5V_2 - Do not install

Power from USB on ESP32 module[edit]

  • 1-2 = VUSB - Install - 5V comes from USB on ESP32 module
  • 3-4 = DCIN - Do not install
  • 5-6 = FTDI5V_1 - Do not install
  • 7-8 = FTDI5V_2 - Do not install

Power from FTDI #1 (Rev 1)[edit]

  • Do not use this position with 'most' FTDI cards since they will drive 5V on the Rx/Tx pins when the FTDI jumper is set to 5V

Power from FTDI #2[edit]

  • Do not use this position with 'most' FTDI cards since they will drive 5V on the Rx/Tx pins when the FTDI jumper is set to 5V

Connectors (Rev 1 board)[edit]

Ble keyboard

P2/P4 = GVS - Rev 1[edit]

  • Ground/Voltage/Signal lines
  1. GPIO13
  2. GPIO14
  3. GPIO16
  4. GPIO17
  5. GPIO35
  6. GPIO34
  7. VN
  8. VP

P3 - VGA - Rev 1[edit]

  • ESP32 pins
  • This table is incorrect - it has the Lower/Higher bits swapped

J2 - FTDI #1 - Rev 1[edit]

  1. GND
  2. RTS (Not used)
  3. 5V (Power in if H2 is configured)
  4. RX (from card to External FTDI)
  5. TX (from External FTDI to card)
  6. CTS (Not used)

Connect to FTDI card - Rev 1[edit]

  • Set FTDI jumper to 3.3V (unlike picture below)
  • Cross-over pins 4 and 5 when connecting to FTDI card (Rev 1 only)

J6 - FTDI #2 - Rev 1[edit]

  • Rev 1 board won't program or boot with FDTI #2 card attached
  • This interface is in common with the USB-to-Serial interface on the ESP32 module
  1. GND
  2. RTS (Not used)
  3. 5V (Power in if H2 is configured)
  4. TX2 (from card to External FTDI)
  5. RX2 (from External FTDI to card)
  6. CTS (Not used)
  • Requires a cross-over of the Transmit and Receive pins if directly connecting to an FTDI part
  • Earlier versions of the FabGL schematics used pin 12 for RX
  • Most recent (2020-02) ANSI terminal uses pin 34
  • Board won't boot with an FTDI interface attached and USB cable attached
    • This is an issue for the ANSI Terminal sketch
  • Original pins were (Rev 1 matches original)

Here's why using pin 12 is a bad idea:

UART2 Rework[edit]

  • The easiest way to do this is to wire the FTDI to GPIO34 pin instead of pin J6-5
    • Not pretty, but it does work fine
  • This is what is needed to permanently rework the board
  • Rework is only needed to run 'stock' FabGL code that uses the UART2 port on the ESP32 (like the ansi terminal)
  • Cut trace/adding jumper to rev 1 board
    • Route to GPIO34
  • Cut as follows (cut in white)
  • Add wire as follows (add wire in white)
  • [2020-01-20] Tested rework on card and it worked

Connect to FTDI card - Rev 1[edit]

  • Set FTDI jumper to 3.3V
  • Cross-over pins 4 and 5 when connecting to FTDI card (Rev 1 only)

J3 - PS/2 Keyboard - Rev 1[edit]

  • Purple DIN 6 connector
  • ESP32 pins

J4 - PS/2 Mouse - Rev 1[edit]

  • DIN 6 connector
  • ESP32 pins

J5 - Audio Out - RCA Jack - Rev 1[edit]

  • ESP32 pins

J15 - 5mm Terminal Block - Rev 1[edit]

  • 5V
  • Gnd

Headers (Rev 2 board)[edit]

  • The Rev 2 board changes around headers and connectors

H1 - 5V - Rev 2[edit]

  • The ESP32-VGA can be powered from either the DC Jack or ESP32 USB power
  • Warning: Do not power from 5V Power jack and connect USB cable to the ESP32 module at the same time
    • The ESP32 module has blocking diode to protect the module
      • If the 5V DC jack has a power supply attached with lower voltage it could result in the supplied being shorted between the USB 5V and the DC power jack
      • This is not an issue if the DC power jack is disconnected
  • This could be used for an external power switch

H2/H3 - GVS - Rev 2[edit]

  • 3x4 header
  • Ground/Voltage/Signal lines
  1. GPIO35
  2. GPIO12
  3. VN/I39
  4. VP/I36

Connectors (Rev 2 board)[edit]

P1 - PS/2 Mouse - Rev 2[edit]

  • DIN 6 connector
  • ESP32 pins

P2 - PS/2 Keyboard - Rev 2[edit]

  • Purple DIN 6 connector
  • ESP32 pins

P3 - VGA - Rev 2[edit]

  • ESP32 pins
  • This table is incorrect - it has the video bits reversed

P4 - Audio Out - RCA Jack - Rev 2[edit]

  • ESP32 pins

J1 - 5V Power - Rev 2[edit]

  • Center +5V
Keyboard

J2 - FTDI #1 - Rev 2[edit]

  • This interface is in common with the USB-to-Serial interface on the ESP32 module
  • Pinout
  1. GND
  2. RTS (Not used)
  3. 5V (Not used)
  4. RX (from card to External FTDI)
  5. TX (from External FTDI to card)
  6. CTS (Not used)

Connect to FTDI card - Rev 2[edit]

  • Set FTDI jumper to 3.3V

Esp32 Connect Bluetooth Keyboard

J3 - FTDI #2 - Rev 2[edit]

  • Most recent (2020-02) ANSI terminal uses pin 34 for Rx
  • Pinout
  1. GND
  2. RTS (Not used)
  3. 5V (Power in if H2 is configured)
  4. RX (from External FTDI to ESP32 card)
  5. TX (from ESP32 card to External FTDI)
  6. CTS (Not used)

Connect to FTDI card - Rev 2[edit]

  • Set FTDI jumper to 3.3V (image below shows jumper set to 5V which is wrong)

J4 - SD Card - Rev 2[edit]

  • Brought to GVS header pins (Rev 1)
  • Brought to SD Card (Rev 2)

VGA - Resistor Selection[edit]

  • ESP32 has a 3.3V driver which can drive more than 10 mA
  • Ideal case drive current
    • 0.7V (full scale VGA level) into 75 Ohms = 9.33 mA
    • 2/3 of the current or 6.16 mA comes from the lower value resistor (digital most significant bit)
    • 1/3 of the current or 3.08 mA comes from the higher value resistor (digital least significant bit)
  • R-2R values
    • Ideal resistor values are 417.9 ohms and 835.7 ohms
    • 1% standard values are 422 (Mouser), 845 (Mouser) Ohms
      • Get closest values
      • 0V, 0.228V, 0.460V, 0.693V
  • Voltage steps are:
  • Current steps are:

FabGL GPIOs assignment summary - fabgl dev board rev2[edit]


I2C (not usable with VGA)[edit]

SPI Display - VSPI (not usable with VGA)[edit]

Esp32 Ble Keyboard

Software[edit]

Arduino Programming[edit]

  • Board : 'DOIT ESP32 DEVKIT V1'

FabGL[edit]

Keyboard
  • Display Controller features/applications
    • VGA
    • SSD1306
    • PS/2 Mouse and Keyboard Controller
    • Graphics Library
    • Sound Engine
    • Game Engine
    • ANSI/VT Terminal for the ESP32

FabGL Libraries[edit]

  • FabGL - ESP32 Display Controller and Graphics Library

FabGL Arduino library[edit]

Installing the released library

Using Latest FabGL builds[edit]

Here's how I did it

  1. Install drivers via Arduino from the Library Manager. These are not the latest files. Space Invaders should run but not have sound (as of now because it's the older version).
  2. Move the FabGL from the Arduino libraries file folder to the desktop.
  3. Copy the FabGL from the GitHub download to the Arduino files folder (where you removed the other folder).
  4. Examples will now be the latest.
  5. Compile/download/test the new files. You know it works if you now get sound from Space Invaders.
  6. Save as where you would normally save your Arduino sketches.

MicroPython[edit]

  • MicroPython Homepage
  • GitHub repo (MicroPython)
    • Examples (MicroPython)
    • Libraries (MicroPython)

ESP-IDF[edit]

Operating Systems[edit]

  • ESP32 DEVKITV1 module schematics (also helpful discussion)

Schematic[edit]

Rev 2 Changes[edit]

  • Rev 1 board won't program or boot with FDTI #2 card attached
    • Earlier FabGL had GPIO12 instead of GPIO34
    • Move FTDI Rx line (GPIO12 to GPIO34)
  • Swap FTDI pins 4 and 5 (FTDI connectors)
    • Allow direct connect to FTDI card (no swap)
  • Add SD Card connector
    • MISO => GPIO 16
    • MOSI => GPIO 17
    • CLK => GPIO 14
    • CS => GPIO 13
    • Remove I/O pins from GVS connector
  • Replace H1/H2 with 1x2 to select/remove DC jack power
  • Remove Polysilicone fuse
  • Change ESP32 board name silkscreen
  • Add SD card connector

Prototype[edit]

  • PS2X49
    • Purple = Keyboard
    • Green = Mouse
  • 6-32/4-40 Standoffs, screws, nuts
  • Cabling

Assembly Sheet[edit]

Retrieved from 'http://land-boards.com/blwiki/index.php?title=ESP32-VGA&oldid=3535'
Robust Design

Esp32 Keyboard

ESP32 is capable of functioning reliably in industrial environments, with an operating temperature ranging from –40°C to +125°C. Powered by advanced calibration circuitries, ESP32 can dynamically remove external circuit imperfections and adapt to changes in external conditions.

Ultra-Low Power Consumption

Engineered for mobile devices, wearable electronics and IoT applications, ESP32 achieves ultra-low power consumption with a combination of several types of proprietary software. ESP32 also includes state-of-the-art features, such as fine-grained clock gating, various power modes and dynamic power scaling.

High Level of Integration

ESP32 is highly-integrated with in-built antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules. ESP32 adds priceless functionality and versatility to your applications with minimal Printed Circuit Board (PCB) requirements.

Hybrid Wi-Fi & Bluetooth Chip

ESP32 can perform as a complete standalone system or as a slave device to a host MCU, reducing communication stack overhead on the main application processor. ESP32 can interface with other systems to provide Wi-Fi and Bluetooth functionality through its SPI / SDIO or I2C / UART interfaces.