Display and HMI

EDA-Piano: 12-Key Touch Piano (ESP8266 + SC12B)

A low-cost 12-key touch piano based on ESP8266 and SC12B, with chord support, OLED display, and WiFi control.

Display and HMI touchaudiooledwifi ESP8266, SC12B, TP4056

Official path: https://oshwhub.com/course-examples/eda-piano2

01 Overview

EDA-Piano is an ESP8266-based 12-key touch piano project designed for low cost and easy learning.

Core components are the ESP8266 module and the SC12B touch controller; the TP4056 charger is optional.

It supports simultaneous 12-key detection, chord playing, real-time OLED feedback, and WiFi-based web control.

It replaces mechanical keys with touch electrodes, simplifying assembly and reducing cost.

Ideal for electronics courses, maker education, and music introduction; also a prototype for IoT audio interaction.

It is not a professional instrument—the buzzer produces simple tones—but it demonstrates touch sensing, chord logic, and IoT control.

02 Hardware

MCU: ESP8266 module, providing WiFi and GPIO interfaces.

Touch sensing: SC12B chip, communicates via I2C, supports 12-key simultaneous detection with high accuracy for chords.

Audio output: buzzer driven via PWM or GPIO; for richer tones, an I2S DAC and speaker can be added (extra circuitry required).

Display: OLED screen (I2C interface, e.g., SSD1306) showing current keys and note information.

Power: TP4056 Li-ion charging module (optional), provides charging and protection for 3.7V Li-ion; if removed, use USB 5V directly.

Touch electrodes: 12 copper pads on PCB, routed to SC12B inputs; layout must avoid interference.

Total BOM cost is low, dominated by the ESP8266 and SC12B.

03 Software flow

Flash firmware: use Arduino IDE or ESP-IDF, select ESP8266 board, verify GPIO assignments before flashing.

Initialize: power-on, init I2C (for SC12B and OLED), configure WiFi (STA or SoftAP).

Touch scan: periodically read SC12B key state registers to detect presses and releases.

Chord logic: based on simultaneous key combinations, generate note frequencies and output via PWM to buzzer.

OLED display: update current keys and note names, show chord type (e.g., C major, Am).

Web control: start HTTP server, provide web page to remotely view key states or trigger notes.

Error handling: if WiFi fails, enter AP mode; if touch chip unresponsive, retry I2C communication.

Low power: optional sleep mode, enter deep sleep when idle, wake on touch (requires hardware support).

04 Core points

SC12B I2C address and register map must be checked in the datasheet; minor variations may exist.

Touch electrode layout affects sensitivity; follow SC12B design guidelines, avoid long or parallel traces.

Buzzer tone is simple; for multi-timbre or chord mixing, use I2S DAC and amplifier.

WiFi communication may introduce latency; for real-time play, reduce web polling or disable it.

TP4056 charging module requires battery protection; if removed, ensure stable power supply.

ESP8266 has limited ADC pins; for additional analog inputs, watch pin multiplexing.

中文

显示与人机

EDA-Piano 简易电子琴(ESP8266 + SC12B)

基于 ESP8266 和 SC12B 的 12 键触摸电子琴,支持和弦、OLED 显示和 WiFi 控制,低成本教学方案。

显示与人机 touchaudiooledwifi ESP8266, SC12B, TP4056

官方路径: https://oshwhub.com/course-examples/eda-piano2

01 项目概述

EDA-Piano 是一个基于 ESP8266 的 12 键触摸电子琴项目,硬件成本低,适合入门和教学。

核心器件为 ESP8266 模组和 SC12B 触摸芯片,可选 TP4056 锂电池充电管理。

支持 12 键同时触摸检测、和弦演奏、OLED 实时显示,以及通过 WiFi 进行 Web 控制。

它解决了传统按键钢琴机械结构复杂、成本高的问题,用触摸电极替代物理按键,简化装配。

适用于电子制作课程、创客教育、音乐启蒙等场景,也可作为智能家居的音频交互原型。

它不是专业乐器,音色简单(蜂鸣器),但足以演示触摸检测、和弦逻辑和物联网控制。

02 项目硬件描述

主控:ESP8266 模组,提供 WiFi 和 GPIO 接口,运行固件并控制外设。

触摸检测:SC12B 芯片,通过 I2C 接口与 ESP8266 通信,支持 12 键同时检测,精度高,可实现和弦。

音频输出:蜂鸣器,通过 PWM 或 GPIO 驱动,产生方波音调;若需更丰富音色,可改用 I2S DAC 和扬声器(需额外电路)。

显示:OLED 屏幕(I2C 接口,如 SSD1306),实时显示按键和音符信息。

电源:TP4056 锂电池充电模块(可选),提供 3.7V 锂电充电和放电保护;若删除,可用 USB 5V 直接供电。

触摸电极:PCB 上铺设 12 个铜箔电极,通过走线连接 SC12B 输入引脚,布局需避免相互干扰。

整体 BOM 成本较低,主要成本集中在 ESP8266 和 SC12B。

03 项目软件流程描述

烧录固件:使用 Arduino IDE 或 ESP-IDF,选择 ESP8266 开发板,烧录前确认 GPIO 分配。

初始化:上电后初始化 I2C(连接 SC12B 和 OLED),配置 WiFi 连接(STA 模式或 SoftAP)。

触摸扫描:周期读取 SC12B 的按键状态寄存器,检测 12 键的按下和释放。

和弦逻辑:根据同时按下的键组合,生成对应的音符频率,通过 PWM 输出到蜂鸣器。

OLED 显示:更新当前按键和音符名称,显示和弦类型(如 C 大调、Am)。

Web 控制:启动 HTTP 服务器,提供网页界面,可远程查看按键状态或触发音符。

错误处理:若 WiFi 连接失败,进入 AP 模式;若触摸芯片无响应,重试 I2C 通信。

低功耗:可选休眠模式,无操作时进入 deep sleep,通过触摸唤醒(需硬件支持)。

04 项目核心点

SC12B 的 I2C 地址和寄存器映射需查阅数据手册,不同批次可能略有差异。

触摸电极布局影响灵敏度,需参考 SC12B 设计指南,避免走线过长或平行。

蜂鸣器音色单一,若需多音色或和弦混音,需改用 I2S DAC 和功放。

WiFi 通信可能引入延迟,实时演奏时建议关闭或降低 Web 轮询频率。

TP4056 充电模块需注意电池保护,避免过放;若删除,确保电源稳定。

ESP8266 的 ADC 引脚有限,若需扩展模拟输入,需注意引脚复用。