pdf-icon

M5Bala Quick Start Guide

To use the M5Bala, you need the M5Stack FIRE or M5GO (White).

Preparation

Development Environment

UIFlow Editing

  1. Burn UIFlow firmware
  2. Configure Wi-Fi Connection
  3. Place the POGO Pin spring pins stack on the base of M5Bala.
  1. Press the red button on the side of the M5Core to power on (quick double press to power off).
  1. Press the button on the base of M5Bala to start the power (press twice in succession to turn off the power).
  1. Visit UIFlow , switch the programming mode from Blockly to Python.
  1. Copy and paste the following code, and execute the program.
from m5stack import *
from m5ui import *
from m5bala import M5Bala
import i2c_bus
clear_bg(0x111111)

m5bala = M5Bala(i2c_bus.get(i2c_bus.M_BUS))
btnA = M5Button(name="ButtonA", text="ButtonA", visibility=False)
btnB = M5Button(name="ButtonB", text="ButtonB", visibility=False)
btnC = M5Button(name="ButtonC", text="ButtonC", visibility=False)
title0 = M5Title(title="Title", fgcolor=0xFFFFFF, bgcolor=0x0000FF)

title0.setTitle('calibrate start')
wait(2)
sampleCount = 2000
gyroXSum = 0
gyroYSum = 0
gyroZSum = 0

for _ in range(sampleCount):
    gyroXYZ = m5bala.imu.gyro
    gyroXSum += gyroXYZ[0] # X
    gyroYSum += gyroXYZ[1] # Y
    gyroZSum += gyroXYZ[2] # Z

gyroXMean = gyroXSum / sampleCount
gyroYMean = gyroYSum / sampleCount
gyroZMean = gyroZSum / sampleCount

m5bala.imu.setGyroOffsets(gyroXMean, gyroYMean, gyroZMean)

title0.setTitle('balance start')
while True:
    m5bala.balance()
    wait(0.001)

Arduino IDE Editing

  1. Install the m5stack library in the Arduino IDE's Library Manager.

<img src=" https://static

-cdn.m5stack.com/resource/docs/static/assets/img/getting_started_pics/m5bala/bala_quick_start_19.webp" width="100%">

  1. Install the NeoPixelBus library in the Arduino IDE's Library Manager.
  1. Install the MPU6050_tockn library in the Arduino IDE's Library Manager.
  1. Connect the M5Core to the computer. Click Tools -> Port and select the serial port used by the device.

  2. For the Board option, select M5Stack-Core-ESP32 or M5Stack-Fire.

  1. Use the Shell command to download the M5Bala example programs . If you have not installed Git yet, click here to download.
git clone --recursive https://github.com/m5stack/M5Bala.git
  1. Click Sketch -> Include Library -> Add .ZIP Library.... Choose the downloaded M5Bala file.
  1. Open the BALA program example: Click File -> Examples -> M5Bala -> Basic.
  1. Compile and upload the program.
On This Page