Imagine a glowing cube on your nightstand that tells you your glucose at a glance. No phone. No app. Just COLOR.
Sugar Cube is a glowing cube that shows your real-time glucose level through color. It pulls data from your Dexcom or Libre CGM every 5 minutes and lights up in the color that matches your current glucose:
🔵 BLUE = Low (You need sugar!)
🟢 GREEN = Perfect (You're crushing it!)
🟠 ORANGE = Getting High (Keep an eye on it)
🔴 RED = High (Time to take action)
🟣 PURPLE = Very High (Definitely take action)
No squinting at phones. No opening apps. Just look at the cube.
You literally need ONE thing: The Waveshare ESP32-C3 Zero board. It has the RGB LED BUILT RIGHT IN.
- No soldering
- No wiring
- No electronics knowledge needed
- Just plug in USB-C and you're done
Want it to look amazing? Print the frosted cube enclosure (file included). Don't have a 3D printer? The bare board still looks cyberpunk as hell.
USB-C cable. Any charger. Done.
Your cube creates a network called SugarCube-Setup-XXXX. Connect from your phone - it automatically opens the captive portal (like hotel WiFi).
- Pick your home WiFi
- Enter your Dexcom or Libre login
- Adjust the colors if you want (or leave them - defaults are perfect)
Your cube starts glowing with your current glucose. Setup complete. Forever.
Because checking your phone 50 times a day sucks.
Sugar Cube sits anywhere you want instant glucose awareness:
- Nightstand - See your glucose without waking up your partner
- Desk - Peripheral vision glucose monitoring while working
- Kitchen - Know if you need to treat before you eat
- Living Room - Ambient awareness for the whole family
/sugarcube.ino # The brain
/portal_html.h # Captive portal interface
/hardware/cad/
└── sugar cube.stl # 3D printable frosted cube
/images/ # Documentation images
Waveshare ESP32-C3 Zero - A $10 board with everything built in:
- ESP32-C3 processor
- WiFi
- RGB LED
- USB-C power
Get it from: Waveshare, Amazon, AliExpress (search "ESP32-C3 Zero")
- Connects to Dexcom Share or LibreView
- Updates every 5 minutes
- Stores credentials securely on device
- Auto-recovers from network issues
- Zero maintenance after setup
- Waveshare ESP32-C3 Zero board (~$10)
- Any USB-C cable
- Arduino IDE (free)
- 5 minutes
- Download this repo
- Open
sugarcube.inoin Arduino IDE - Install two libraries:
ArduinoJsonandFastLED - Select board:
ESP32C3 Dev Module - Click Upload
- You now have a Sugar Cube
- File:
/hardware/cad/sugar cube.stl - Material: White or translucent PETG/PLA
- Settings: 0.2mm layers, 20% infill, no supports
- Result: A gorgeous frosted cube that glows beautifully
Don't like the defaults? Set your own ranges in the web portal:
- Maybe you want green up to 140
- Maybe purple should start at 250
- It's YOUR cube
Want faster updates? Edit one line in sugarcube_config.h:
const unsigned long CGM_FETCH_INTERVAL_MS = 300000; // 5 minutes
// Change to 60000 for 1-minute updatesThe cube tells you what it's doing:
| Color | What's Happening |
|---|---|
| White | Need to run setup |
| Yellow (blink) | Connecting to WiFi |
| Magenta | Connected, waiting |
| Cyan (flash) | Getting your glucose |
| Your glucose color | WORKING PERFECTLY |
| Red (solid, not glucose) | Check your CGM login |
- Don't make medical decisions based on the cube
- Use your real CGM app for dosing insulin
- This is for ambient awareness, not treatment
- Credentials stored locally on the device in encrypted flash
- Uses the same APIs as Dexcom Follow / LibreLinkUp
- No cloud service, no subscriptions, no tracking
Cube won't connect? → Only works with 2.4GHz WiFi
Stays red? → Re-enter your CGM password
Not updating? → Check if your CGM app is uploading
Can't find setup network? → Power cycle and try again
The code is surprisingly simple for what it does. Here's how it all works:
When Sugar Cube boots up (or can't connect to WiFi), it creates its own WiFi network and runs a captive portal - that's the popup that automatically appears on your phone when you connect (like at hotels or airports). The portal is a self-contained web server running on the ESP32.
The portal HTML/CSS/JavaScript is stored directly in portal_html.h as a single string - no external files needed. When you connect, it:
- Scans for nearby WiFi networks and shows signal strength
- Tests your WiFi credentials before saving them
- Verifies your CGM login works before committing
- Saves everything to the ESP32's non-volatile memory
Setup Mode:
- Creates WiFi access point:
SugarCube-Setup-XXXX - Runs DNS server that redirects all requests to the portal
- Serves the configuration web interface
- Auto-exits after 60 seconds if unused (or 10 minutes if active)
Normal Mode:
- Connects to your home WiFi
- Every 5 minutes:
- Calls Dexcom or Libre API
- Gets your latest glucose value
- Sets the LED to the appropriate color
- Handles network drops and reconnects automatically
Dexcom Share:
1. Authenticate with username/password → Get Account ID
2. Login with Account ID → Get Session ID
3. Request glucose with Session ID → Get glucose value
LibreView:
1. Login once → Get auth token (saved for reuse)
2. Request connections endpoint with token → Get glucose value
3. Token refreshes automatically when expired
The setGlucoseLedColor() function takes the glucose value and compares it against your custom ranges:
if (glucose <= rangeBlue) { leds[0] = CRGB::Blue; }
else if (glucose <= rangeGreen) { leds[0] = CRGB::Green; }
else if (glucose <= rangeOrange) { leds[0] = CRGB::Orange; }
else if (glucose <= rangeRed) { leds[0] = CRGB::Red; }
else { leds[0] = CRGB::Purple; }- Credentials stored in ESP32's Preferences (encrypted flash storage)
- Portal only accessible via direct WiFi connection (not from internet)
- One user at a time during setup (locks to first connected device)
- SHA256 hashing for Libre authentication
- WiFi drops: Auto-reconnect with visual feedback (yellow blink)
- API failures: Red LED + retry on next cycle
- Invalid credentials: Clear stored tokens to force re-login
- No configuration: White LED until setup
- sugarcube.ino - Main program logic, setup/loop functions
- portal_html.h - Complete web interface in a single HTML string
- led_controller.cpp/h - LED color functions and patterns
- sha256_utils.h - Hashing library for Libre authentication
- sugarcube_config.h - All timing and API constants in one place
The entire codebase is under 1000 lines - clean, readable, and hackable.
For the price of two fancy coffees, you can build a device that shows your glucose as a glowing color 24/7.
No subscriptions. No apps running. No battery to charge. Just a cube that glows your glucose.
License: MIT
Created for the diabetes community



