Skip to content

CyberRagz/Magic-Cube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧊 MagicCube ESP32/ESP8266

An implementation of the Aqara MagicCube using ESP32/ESP8266-based smart IoT cube with gesture recognition, orientation detection, and Home Assistant integration via MQTT.


✨ Features

  • 12 gesture/action types — shake, tap, flip, rotate, vibration, face detection, and more
  • 6-face orientation detection using MPU6050 IMU (top, bottom, left, right, front, back)
  • Deep sleep power management — wakes on vibration or 5-minute timer (~10–50µA in sleep)
  • Battery monitoring with voltage and percentage reporting
  • Home Assistant MQTT integration — plug-and-play sensor/automation support
  • Remote commands — reset, sleep, and status request via MQTT

🔌 Hardware

Component Purpose
ESP32 DevKit (30-pin) Main controller
MPU6050 (GY-521) 6-axis IMU — gesture & orientation
SW-420 Vibration Sensor Knock/vibration detection
LiPo Battery (3.7V, 500–2000mAh) Power source
TP4056 Charger Module Battery charging & protection

Enclosure: 60×60×60mm cube (3D printable STL available)


📡 MQTT Topics

Topic Direction Description
home/magiccube/status Publish Sensor data & actions
home/magiccube/command Subscribe Remote commands (reset, sleep, status)

Payload Example

{
  "action": "shake",
  "face": "top",
  "battery_voltage": 4.28,
  "battery_percentage": 100,
  "pitch": 12.34,
  "roll": 45.67,
  "rssi": -45,
  "boot_count": 6,
  "cube_status": "active"
}

🎮 Supported Actions

Action Trigger
boot Power on / wake from sleep
shake 3 shakes > 20 m/s² within 500ms
flip Rapid 180° rotation
rotate_clockwise Spin > 150°/s clockwise
rotate_counterclockwise Spin > 150°/s counterclockwise
tap Single impact > 12 m/s²
vibration Hardware vibration sensor
idle End of 5s active window

🏠 Home Assistant

The configuration.yaml snippet in the full documentation sets up all sensors, buttons, and a complete Lovelace dashboard. Automations are available for:

  • Toggle lights on shake
  • Brightness/volume control via rotation
  • Scene switching by face orientation
  • Bedtime routines, security alerts, climate control, and more

⚡ Power

Mode Consumption Duration
Active ~80–120mA 5 seconds per wake
Deep Sleep ~10–50µA Up to 5 minutes

Typical battery life (1000mAh): 1–10 days depending on usage.


🛠️ Getting Started

  1. Wire components per the schematic in the full documentation
  2. Flash firmware via Arduino IDE
  3. Update secrets.h with your WiFi and MQTT credentials
  4. Add the MQTT sensor/button config to Home Assistant
  5. Place the cube and start automating!

📄 License

MIT License — free for personal and commercial use.


Firmware Version: 1.0 | Author: Raghu

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors