
Corrector de postura
agustin-arg/Posture
Dispositivo electrónico de corrección de postura corporal

A comprehensive self-balancing robot implementation using ESP32 NodeMCU-32S board with GY-521 MPU6050 module, featuring FreeRTOS multi-tasking architecture, DMP (Digital Motion Processor) sensor fusion, and a real-time…
BreakoutBoard is an open-source printed circuit board by sphanhoang, from the sphanhoang/Self-balancing-robot repository on GitHub. It is a 4-layer board of 110 × 84 mm with 12 parts on 41 nets, routed with 82 tracks and 0 vias.
It is built around the NODEMCU-32SLUA and LM2596S-5.0. Its parts include 4 connectors and 2 ICs. It belongs with the microcontroller boards boards and the ESP8266 boards of this library.
A comprehensive self-balancing robot implementation using ESP32 NodeMCU-32S board with GY-521 MPU6050 module, featuring FreeRTOS multi-tasking architecture, DMP (Digital Motion Processor) sensor fusion, and a real-time web interface for parameter tuning.
| ESP32 Pin | Component | Function |
|---|---|---|
| GPIO 21 | MPU6050 | SDA (I2C) |
| GPIO 22 | MPU6050 | SCL (I2C) |
| GPIO 14 | Motor Driver | ENA (Right Motor PWM) |
| GPIO 32 | Motor Driver | ENB (Left Motor PWM) |
| GPIO 27 | Motor Driver | IN1 (Right Motor Direction) |
| GPIO 26 | Motor Driver | IN2 (Right Motor Direction) |
| GPIO 25 | Motor Driver | IN3 (Left Motor Direction) |
| GPIO 33 | Motor Driver | IN4 (Left Motor Direction) |
| GPIO 16 | Left Encoder | Channel A |
| GPIO 17 | Left Encoder | Channel B |
| GPIO 18 | Right Encoder | Channel A |
| GPIO 19 | Right Encoder | Channel B |
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Sensor Task │───▶│ Control Task │───▶│ Motor Task │
│ (Priority 5) │ │ (Priority 4) │ │ (Priority 3) │
│ 100Hz reading │ │ 100Hz control │ │ 100Hz update │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ MPU6050 DMP │ │ PID Controllers│ │ Motor Drivers │
│ Sensor Fusion │ │ Roll & Speed │ │ PWM Control │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Encoder Task │ │ Web Server │ │ Monitor Task │
│ (Priority 3) │ │ (Priority 2) │ │ (Priority 1) │
│ 1Hz reading │ │ WiFi + HTTP │ │ 0.5Hz logging │
└─────────────────┘ └─────────────────┘ └─────────────────┘// Roll control (primary balancing)
#define KP_ROLL 18.0f // Proportional gain (best results: 18)
#define KI_ROLL 50.0f // Integral gain (best results: 50)
#define KD_ROLL 0.4f // Derivative gain (best results: 0.4)
// Speed control (for forward/backward movement)
#define KP_SPEED 0.01f // Proportional gain
#define KI_SPEED 0.01f // Integral gain
#define KD_SPEED 0.01f // Derivative gain
#define TILT_ANGLE 0.6f // Target tilt angle for speed control#define MAX_MOTOR_SPEED 255.0f // Maximum PWM value
#define MIN_MOTOR_SPEED 30.0f // Minimum PWM value (38.25)
#define MAX_ANGLE 15.0f // Normal operation limit (degrees)
#define MIN_ANGLE -15.0f // Normal operation limit (degrees)
#define PWM_FREQ_HZ 100 // PWM frequency#define CONFIG_WIFI_SSID "your_wifi_ssid"
#define CONFIG_WIFI_PASSWORD "your_wifi_password"
#define WEB_SERVER_PORT 80Connect MPU6050:
Connect Motor Driver:
Mount Components:
Install PlatformIO (if not already installed)
Clone/Download this project
Configure WiFi (in src/web_interface.cpp):
#define CONFIG_WIFI_SSID "your_wifi_ssid"
#define CONFIG_WIFI_PASSWORD "your_wifi_password"Build and Upload:
pio run -t uploadMonitor Output:
pio device monitorAccess Web Interface:
http://[robot_ip_address]The system uses pre-calibrated MPU6050 offsets. You'll see:
I (xxxx) MPU6050: Testing device connections...
I (xxxx) MPU6050: MPU6050 connection successful
I (xxxx) MPU6050: Initializing DMP...
I (xxxx) MPU6050: DMP is ready!The robot includes a comprehensive web interface accessible via WiFi:
GET / - Main web interfaceGET /data - JSON data for real-time updatesGET /pid?kp_r=X&ki_r=Y&kd_r=Z - Update PID parametersGET /control?enable=1 - Enable/disable balancingtypedef struct {
float yaw, pitch, roll; // Euler angles (degrees)
float accel_x, accel_y, accel_z; // Linear acceleration (g)
uint32_t timestamp; // System timestamp
float dt_since_last; // Time delta since last reading
} sensor_data_t;typedef struct {
float roll_output; // Roll PID output
float speed_output; // Speed PID output
float left_motor_speed; // Left motor PWM (-255 to 255)
float right_motor_speed; // Right motor PWM (-255 to 255)
float left_motor_feedback; // Left motor speed feedback (RPS)
float right_motor_feedback; // Right motor speed feedback (RPS)
uint32_t timestamp; // System timestamp
} control_data_t;typedef struct {
uint32_t left_encoder_pulseCount; // Left encoder pulse count
uint32_t right_encoder_pulseCount; // Right encoder pulse count
float left_motor_speed; // Left motor speed (RPS)
float right_motor_speed; // Right motor speed (RPS)
} encoder_data_t;typedef struct {
float kp_roll, ki_roll, kd_roll; // Roll PID parameters
float kp_speed, ki_speed, kd_speed; // Speed PID parameters
bool enable_balance; // Balance enable flag
float target_angle; // Target tilt angle
} web_control_t;The system provides detailed logging:
I (xxxx) MPU: MPU6050 connection successful
I (xxxx) MPU: DMP is ready!
I (xxxx) WEB: Connect to: http://192.168.1.100
motor rps: LEFT: 2.1 RIGHT: 2.3Robot falls immediately:
Oscillations:
No response:
Web interface not accessible:
web_interface.cppEncoder issues:
The project includes a custom breakout board design in KiCad:
BreakoutBoard.kicad_pcb - Main PCB layoutBreakoutBoard.kicad_sch - Schematic designGerbers/ - Manufacturing files ready for PCB fabricationBluetooth Control:
Enhanced Web Interface:
Data Logging:
Advanced Control:
The code supports various motor drivers through the set_motor_speed() function:
void set_motor_speed(int motor, float speed) {
// Current implementation supports L298N-style drivers
// Easily adaptable for TB6612FNG, DRV8833, etc.
// motor: 0 = right, 1 = left
// speed: -255 to 255 (PWM value)
}This project is open source. Feel free to use, modify, and distribute.
For questions and support:
Happy Balancing! 🤖⚖️
| Qty | Value | Footprint | References |
|---|---|---|---|
| 4 | MountingHole | MountingHole:MountingHole_3.2mm_M3_Pad | H1, H2, H3, H4 |
| 2 | Screw_Terminal_01x04 | TerminalBlock:ScrewTerminal_TB007-508-04BE | J1, J2 |
| 1 | Conn_01x02_Pin | Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical | JP1 |
| 1 | Conn_01x08_Pin | Connector_PinHeader_2.54mm:PinHeader_1x08_P2.54mm_Vertical | J3 |
| 1 | GY-521 | Sensor_Motion:GY-521 | ACC1 |
| 1 | LM2596 | Module:LM2596 WC00100 Module | U2 |
| 1 | NODEMCU-32S | RF_Module:ESP32-NODEMCU-32S | U1 |
| 1 | Screw_Terminal_01x02 | TerminalBlock:ScrewTerminal_TB007-508-02BE | J4 |

agustin-arg/Posture
Dispositivo electrónico de corrección de postura corporal

unla-investigacion-desarrollo/ecosistema-iot
Antes de desarrollar el sistema final, realizamos una etapa de exploración donde investigamos y experimentamos con las siguientes tecnologías:


bytecod3/lora-life-jacket
Electronic device for life jackets with LORA data transmission

hopkinskong/eie553-iot-hardware
ESP32 IOT Smart Lock Device Hardware Schematic and PCB used in the course "EIE553 Security in Data Communication".

2026MakerClub/PCB
projects with pcb, custom and commonly used schemes, footprints...etc.

ANTzacalie/termo-pro-esp32
Full-featured smart thermostat built on the ESP32 platform.

It measures 110 × 84 mm and has 4 copper layers, 1.6 mm thick.
12 parts, built around the NODEMCU-32SLUA and LM2596S-5.0. 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.
From the sphanhoang/Self-balancing-robot repository on GitHub, at the commit this page was made from: the board is BreakoutBoard/BreakoutBoard.kicad_pcb and its schematic BreakoutBoard/BreakoutBoard.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask sphanhoang before reusing the design.