Equipped with ultrasonic sensors, the robot can detect and avoid obstacles in its path.
Equipped with ultrasonic sensors, the robot can detect and avoid obstacles in its path.
The robot can follow a predetermined path using its onboard sensors and algorithms.
The robot can be controlled remotely using a smartphone or computer via Bluetooth or Wi-Fi.
The robot can be integrated with other IoT devices and sensors to expand its capabilities and interact with its environment.
Key Features
ESP32-WROVER-E, a high-performance Wi-Fi and Bluetooth-enabled microcontroller with 4MB of Flash and 520KB of SRAM.
+ MPU6050 6-axis accelerometer and gyroscope for balance and motion detection.
+ Ultrasonic sensors for obstacle avoidance.
+ Infrared sensors for line following.
Dual 1.5A motor drivers for precise control of the robot's movements.
2S 7.4V 1500mAh lithium-ion battery with charging and discharging protection.
Wi-Fi, Bluetooth 4.0, and USB-C for programming and debugging.
Compatible with M5Stack modules and accessories, including GPS, camera, and audio modules.
Supports MicroPython, Arduino, and C++ programming languages.
Dimensions and Weight
140mm (5.5 inches)
90mm (3.5 inches)
70mm (2.75 inches)
450g (15.9 oz)
What's Included
M5Stack BALA2 FIRE Self-Balancing Robot Kit
2S 7.4V 1500mAh lithium-ion battery
USB-C cable
Quick start guide
Access to online documentation and community resources
Target Applications
Robotics enthusiasts and hobbyists
IoT developers and researchers
Educational institutions and universities
Commercial product development and prototyping
M5Stack BALA2 FIRE Self-Balancing Robot Kit DocumentationOverviewThe M5Stack BALA2 FIRE Self-Balancing Robot Kit is a comprehensive IoT development platform that combines the M5Stack Core ESP32 module with a balance car robot, designed for robotics and IoT enthusiasts. This kit is equipped with a MPU6050 gyroscope, L298N motor driver, and other essential components, allowing users to build and program a self-balancing robot.Hardware ComponentsM5Stack Core ESP32 module
BALA2 FIRE balance car robot
MPU6050 gyroscope
L298N motor driver
2x DC motors
Power management module
USB-C port for programming and power supplySoftware RequirementsM5Stack Arduino library (for ESP32)
Arduino IDE (version 1.8.x or later)Code Examples### Example 1: Basic Self-Balancing RobotThis example demonstrates how to use the BALA2 FIRE Self-Balancing Robot Kit to create a basic self-balancing robot.Code:
```cpp
#include <M5Stack.h>
#include <Wire.h>#define MPU6050_ADDRESS 0x68M5Stack m5;void setup() {
// Initialize M5Stack
m5.begin();
// Initialize MPU6050
Wire.begin();
Wire.beginTransmission(MPU6050_ADDRESS);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0x00); // reset
Wire.endTransmission();
// Initialize motors
pinMode(MOTOR_LEFT, OUTPUT);
pinMode(MOTOR_RIGHT, OUTPUT);
}void loop() {
// Read MPU6050 data
int16_t ax, ay, az;
Wire.beginTransmission(MPU6050_ADDRESS);
Wire.write(0x3B); // ACCEL_XOUT_H register
Wire.endTransmission();
Wire.requestFrom(MPU6050_ADDRESS, 6);
ax = Wire.read() << 8 | Wire.read();
ay = Wire.read() << 8 | Wire.read();
az = Wire.read() << 8 | Wire.read();
// Calculate angle
float angle = atan2(ay, az) 180 / PI;
// Control motors
if (angle > 10) {
digitalWrite(MOTOR_LEFT, HIGH);
digitalWrite(MOTOR_RIGHT, LOW);
} else if (angle < -10) {
digitalWrite(MOTOR_LEFT, LOW);
digitalWrite(MOTOR_RIGHT, HIGH);
} else {
digitalWrite(MOTOR_LEFT, LOW);
digitalWrite(MOTOR_RIGHT, LOW);
}
delay(50);
}
```
Description: This code initializes the M5Stack, MPU6050, and motor pins. It then reads the MPU6050 data to calculate the robot's angle. Based on the angle, it controls the motors to maintain balance.### Example 2: Remote Controlled Self-Balancing Robot (using WiFi)This example demonstrates how to use the BALA2 FIRE Self-Balancing Robot Kit to create a remote-controlled self-balancing robot using WiFi.Code:
```cpp
#include <M5Stack.h>
#include <WiFi.h>
#include <Wire.h>#define MPU6050_ADDRESS 0x68
#define MOTOR_LEFT 2
#define MOTOR_RIGHT 3M5Stack m5;
WiFiClient client;const char ssid = "your_wifi_ssid";
const char password = "your_wifi_password";void setup() {
// Initialize M5Stack
m5.begin();
// Initialize WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.println("Starting robot...");
// Initialize MPU6050
Wire.begin();
Wire.beginTransmission(MPU6050_ADDRESS);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0x00); // reset
Wire.endTransmission();
// Initialize motors
pinMode(MOTOR_LEFT, OUTPUT);
pinMode(MOTOR_RIGHT, OUTPUT);
}void loop() {
// Read MPU6050 data
int16_t ax, ay, az;
Wire.beginTransmission(MPU6050_ADDRESS);
Wire.write(0x3B); // ACCEL_XOUT_H register
Wire.endTransmission();
Wire.requestFrom(MPU6050_ADDRESS, 6);
ax = Wire.read() << 8 | Wire.read();
ay = Wire.read() << 8 | Wire.read();
az = Wire.read() << 8 | Wire.read();
// Calculate angle
float angle = atan2(ay, az) 180 / PI;
// Send data to server
client.setServer("your_server_ip", 80);
client.print("GET /robot_data?angle=");
client.print(angle);
client.println(" HTTP/1.1");
client.println("Host: your_server_ip");
client.println("Connection: close");
client.println();
// Receive commands from server
int command = client.parseInt();
if (command == 1) {
digitalWrite(MOTOR_LEFT, HIGH);
digitalWrite(MOTOR_RIGHT, LOW);
} else if (command == 2) {
digitalWrite(MOTOR_LEFT, LOW);
digitalWrite(MOTOR_RIGHT, HIGH);
} else {
digitalWrite(MOTOR_LEFT, LOW);
digitalWrite(MOTOR_RIGHT, LOW);
}
delay(50);
}
```
Description: This code initializes the M5Stack, WiFi, and motor pins. It then reads the MPU6050 data to calculate the robot's angle. The angle data is sent to a server using WiFi, and the robot receives commands from the server to control its movement.Note: You will need to set up a server to receive the robot's data and send commands to the robot. You can use a platform like ESP8266WebServer or a Raspberry Pi as the server.