Skip to the content
2 layers76.8 × 72.6 mmLM358 Audio Input Sensor, the printed circuit board in 3D

LM358 Audio Input Sensor

Shantu-2580/Prototypes

A two-wheeled self-balancing robot using ESP32, MPU6050 (accelerometer + gyroscope), TB6612FNG motor driver, and Bluetooth gamepad control via Bluepad32.

Size
76.8 × 72.6 mm
Copper layers
2
Thickness
1.6 mm
Parts
25
Nets
23
Pads
74
Tracks, vias
121, 7
Pours
1
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
18 Mar 2026
Updated
31 Jul 2026

Overview

LM358 Audio Input Sensor is an open-source printed circuit board by Shantu-2580, from the Shantu-2580/Prototypes repository on GitHub. It is a 2-layer board of 76.8 × 72.6 mm with 25 parts on 23 nets, routed with 121 tracks and 7 vias.

It is built around the LM3915 and L7805. Its parts include 11 diodes, 5 resistors, 4 capacitors, 3 ICs and 2 connectors. It belongs with the sensors and measurement and audio and music boards of this library.

Main components

2

README

ESP/Self_Balancing_Bot/README.md

Self-Balancing Bot

A two-wheeled self-balancing robot using ESP32, MPU6050 (accelerometer + gyroscope), TB6612FNG motor driver, and Bluetooth gamepad control via Bluepad32.

Hardware Requirements

ComponentNotes
ESP32 DevKit30+ GPIO pins
MPU6050I2C address 0x68 (SDA=21, SCL=22)
TB6612FNGDual H-bridge motor driver
2x DC MotorsWith encoder support (optional)
LiPo Battery2S-3S (7.4V-11.1V) with voltage regulator
Bluetooth GamepadTested with Xbox/PS4/8BitDo controllers

Pinout

text
ESP32          TB6612FNG          MPU6050
────────────────────────────────────────────
GPIO 33   →    PWMA
GPIO 14   →    AIN1
GPIO 15   →    AIN2
GPIO 32   →    PWMB
GPIO 26   →    BIN1
GPIO 27   →    BIN2
GPIO 21   →    SDA
GPIO 22   →    SCL
3.3V      →    VCC
GND       →    GND

Firmware Files

Codes/P1/P1.ino — Original Version

Status: Reference implementation (has placeholder values)

Features:

  • Basic PID balance control (100Hz loop)
  • Complementary filter for sensor fusion (MPU6050 accel + gyro)
  • Bluetooth gamepad control via Bluepad32
  • TB6612FNG motor driver interface
  • Fall detection safety cutoff (>45°)

Known Issues:

  • ❌ Kp, Ki, Kd, base_setpoint set to Add_Values_Later — won't compile
  • ❌ No calibration routine — base_setpoint must be manually tuned per robot
  • ❌ No integral anti-windup — causes overshoot after disturbances
  • ❌ No motor deadband compensation — motors stall at low PWM
  • ❌ No gamepad deadzone — joystick drift causes unwanted movement
  • ❌ No controller watchdog — robot keeps moving if controller dies
  • ❌ No MPU6050 verification — silent failure if sensor disconnected
  • ❌ No serial telemetry — blind PID tuning

Codes/P1/Program2.ino — Optimized Version

Status: Production-ready with all fixes

All Original Features Plus:

CategoryImprovements
CompilableReal PID defaults: Kp=25.0, Ki=0.8, Kd=1.2
Calibration2-second startup routine averages accelerometer to find base_setpoint automatically
Anti-WindupDual protection: integral clamped at ±400 + integration pauses when output saturates (±255)
Motor DeadbandMIN_PWM=25 ensures TB6612FNG overcomes static friction
Gamepad DeadzoneIgnores joystick input < 20 (prevents center drift)
WatchdogAuto-stops motors if controller disconnects >500ms
Sensor VerifyChecks WHO_AM_I register (0x68) at startup, halts if missing
DLPF ConfigHardware low-pass filter set to 44Hz (accel) / 42Hz (gyro)
Telemetry1Hz serial output: angle, setpoint, PID terms for tuning
I2C OptimizedSingle 14-byte read transaction per loop

PID Tuning Guide (Program2)

Open Serial Monitor at 115200 baud. You'll see:

text
Angle: 0.12 | Setpoint: 0.00 | Out: -15.3 | P: -3.0 I: -0.2 D: -12.1

Tuning Order:

  1. Kp only (set Ki=0, Kd=0): Increase until sustained oscillation, then reduce ~30%
  2. Kd: Add to dampen oscillations (start ~0.5-2.0)
  3. Ki: Small value (0.5-2.0) to eliminate steady-state drift

Tips:

  • Hold robot upright during 2-second calibration (LED on ESP32 blinks during this)
  • Test on carpet first — smoother surface = easier balance
  • If robot falls backward consistently, increase base_setpoint slightly (or add weight forward)
  • Kp typically 20-50, Kd 0.5-3, Ki 0.5-2 for this hardware

Building & Flashing

Arduino IDE

  1. Install ESP32 board package: https://dl.espressif.com/dl/package_esp32_index.json
  2. Install Bluepad32 library via Library Manager
  3. Open Program2.ino, select board ESP32 Dev Module, upload

PlatformIO (Recommended)

ini
; platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
    ricardoquesada/Bluepad32 @ ^2.0.0
monitor_speed = 115200

Troubleshooting

SymptomLikely CauseFix
Won't compileUsing P1.inoUse Program2.ino
Falls immediatelyPID not tunedFollow tuning guide above
Drifts forward/backWrong base_setpointRe-calibrate (reset ESP32)
Oscillates violentlyKp too high / Kd too lowReduce Kp, increase Kd
Slow to correctKp too lowIncrease Kp
Motors hum but don't turnDeadband too lowIncrease MIN_PWM (try 30-40)
Controller doesn't pairBluepad32 keys storedBP32.forgetBluetoothKeys() runs on startup
MPU6050 not detectedWiring / I2C addressCheck SDA/SCL, try 0x69 (AD0=HIGH)

License

MIT — Feel free to use, modify, distribute.

Parts

25
QtyValueFootprintReferences
10LEDLED_THT:LED_D5.0mmD2, D3, D4, D5, D6, D7, D8, D9, D10, D11
2100kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR1, R3
21uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC3, C4
11.2kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR5
1100nFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mmC1
110kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR4
110uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC2
11N4007Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD1
1Audio_inConnector_PinSocket_2.54mm:PinSocket_1x02_P2.54mm_VerticalJ2
1Battery_inConnector_Phoenix_MSTB:PhoenixContact_MSTBA_2,5_2-G-5,08_1x02_P5.08mm_HorizontalJ1
1L7805Package_TO_SOT_THT:TO-220-3_VerticalU3
1LM3915LM3915:DIP795W45P254L2286H533Q18BU2
1PotentiometerConnector_PinSocket_2.54mm:PinSocket_1x03_P2.54mm_VerticalR2
1~Package_DIP:DIP-8_W7.62mmU1

More from Shantu-2580/Prototypes

1
  • 2 layers120 × 75 mmSelf Balancing Bot, the printed circuit board in 3D

    Self Balancing Bot

    Shantu-2580/Prototypes

    A two-wheeled self-balancing robot using ESP32, MPU6050 (accelerometer + gyroscope), TB6612FNG motor driver, and Bluetooth gamepad control via Bluepad32.

    11 parts

Similar boards

  • 2 layers32 × 70 mmAudio Power Meter, the printed circuit board in 3D

    Audio Power Meter

    jjrh/LM3915_audio

    kicad schematic for a powermeter using the LM3915 IC.

    23 parts1MIT
  • 2 layers142 × 166.9 mmFPGAPRO, the printed circuit board in 3D

    FPGAPRO

    SFMonsun/FPGA-I2S-IIR-Filter-implementation

    257 parts
  • 2 layers100 × 100 mmBulkyMIDI-32 VU SIDi, the printed circuit board in 3D

    BulkyMIDI-32 VU SIDi

    tebl/BulkyMIDI-32

    A HW build of the MT32-PI project, allowing you to emulate a Roland MT-32 using a Raspberry Pi. Includes enough additional modules to build a MIDI-mountain as well as adapters for connecting to most things retro.

    96 parts80CC-BY-SA-4.0
  • 2 layersLab 4 PSE, the printed circuit board in 3D

    Lab 4 PSE

    D10G0S1LVA/Trabalhos-Faculdade

    Rep para guardar projetos e trabalhos desenvolvidos na faculdade

    50 parts
  • 2 layers40.6 × 110 mmEuropi surface mount, the printed circuit board in 3D

    Europi surface mount

    Allen-Synthesis/EuroPi

    EuroPi: A reprogrammable Eurorack module based on the Raspberry Pi Pico

    92 parts584CC0-1.0
  • 2 layers132.1 × 45.7 mmIPoS, the printed circuit board in 3D

    IPoS

    peterheinrich/InternetOverSpaghetti

    Transmitting IP packages over a pair of spaghetti thus demonstrating how media independent IP really is.

    42 parts342
  • 2 layers59.7 × 57.5 mmFunBox, the printed circuit board in 3D

    FunBox

    GuitarML/FunBox

    Stereo guitar pedal platform using Daisy Seed.

    61 parts289MIT

Questions

How big is the LM358 Audio Input Sensor PCB?

It measures 76.8 × 72.6 mm and has 2 copper layers, 1.6 mm thick.

What parts does the LM358 Audio Input Sensor use?

25 parts, built around the LM3915 and L7805. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the LM358 Audio Input Sensor KiCad files?

From the Shantu-2580/Prototypes repository on GitHub, at the commit this page was made from: the board is ESP/LM358_Audio_Input_Sensor/LM358_Audio_Input_Sensor/LM358_Audio_Input_Sensor.kicad_pcb and its schematic ESP/LM358_Audio_Input_Sensor/LM358_Audio_Input_Sensor/LM358_Audio_Input_Sensor.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the LM358 Audio Input Sensor design in my own project?

Its repository states no licence, so its author keeps all rights: ask Shantu-2580 before reusing the design.