SmartCube
is a compact, customizable desk companion powered by an ESP8266 microcontroller. Built entirely from cheap, easy-to-find parts, it can be programmed for a variety of tasks: show notifications, display the weather, monitor sensors, act as a clock, host a simple web page, serve as a WiFi extender, run small background tasks, or even be a virtual pet
Whatever you feel like experimenting with!
Info
- This is a hobby project I work on and develop for when I have literally nothing else to do, do not expect regular updates. You are free to clone this and do whatever you like with it
- Code: I have a few projects developed for the Cube. You can see the list here on my Gitea
- V2: There is also a more powerful version, it's pretty much the same but with extra features and is using ESP32, I only made one of them and I don't like it yet, it needs work.
- Case: 3D-printable design included in
/hardware
directory - Schematics: and assembly instructions are also in the
/hardware
directory
Table of Contents
- Bill of Materials
- 3D-Printing the Case
- Assembly Instructions
- Schematics
- GPIO Pin Reference Table
- Demo Code Explanation
- Tips and tricks
Bill of Materials
Component | Quantity | Description | Notes |
---|---|---|---|
Enclosure | 1 | 3D-printed case | 3D printable STL files are in hardware/case/ |
ESP8266 D1 Mini | 1 | Microcontroller module | |
SSD1306 OLED Display | 1 | 128x64 resolution, I2C interface | |
6x6 Push Buttons | 3 or 4 | Tactile push buttons | |
Resistors (10kΩ) | 3 or 4 | Pull-down resistors for buttons | Generally any resistor between 1kΩ and 100kΩ will work |
20mm Piezo Buzzer | 1 | Caseless buzzer for audio | |
Wires | Several | Thin wires for connections | I used wires from inside an old ethernet cable |
2x6mm screw | 8 | Small screws for assembling the case | Does not have to be exactly 6mm long |
2x2mm screw | 4 (Optional) | Small screws for the front | Mostly for cosmetic purposes |
14250 Rechargeable Battery | 1 (Optional) | Lithium-ion battery | Make sure it's rechargeable; most 14250 aren't |
TP4056 Module | 1 (Optional) | Charging and protection circuit | USB connector not required |
Resistors (220kΩ and 56kΩ) | 1 (Optional) | Voltage divider for measuring battery level | You can also use 100kΩ and 47kΩ |
Micro Slider Switch (SS-12D00) | 1 (Optional) | On/Off switch | Only needed if installing the battery |
3D-Printing the Case
The SmartCube case is fully 3D-printable. STL files are included this repository in the /hardware/case/
directory:
File | Description |
---|---|
SmartCube_Body_3_button.stl |
Main cube body with slots for 3 buttons |
SmartCube_Body_4_button.stl |
Body variant for 4 buttons |
SmartCube_Front.stl |
Front panel for OLED display |
SmartCube_Front_No_Holes.stl |
Front panel variant without decorative screw holes |
SmartCube_Back_Speaker_Side_Hole.stl |
Back panel |
SmartCube_Back_Speaker_Power_Switch.stl |
Back panel variant with power switch slot |
- Use PLA or PETG
- 0.2 mm layer hight is more than enough, you can print finer if you want to.
- Supports may be required depending on your printer
Assembly Instructions
Body
Push the ESP8266 microcontroller in the ledge on the bottom the cube body, it should 'click in' with the USB-C port facing the hole.
Body with 3 or 4 button slots is available in the hardware/case/
Buttons
At this step, glue the buttons into the top slots and solder resistors to their outputs. You can connect the resistor outputs together, and don't forget to attach an extra wire to the button inputs, this will later be used to connect them to the 3.3V line.
Next, solder all of the button outputs to the microcontroller.
Pin numbers for the buttons (and other components) are defined in the example config, and the schematic for the D1 Mini is here. You don't have to follow my exact pin definitions, but I've found this setup to be the easiest way to assemble and fit everything in. The 3-button variant is the standard. If you decide to go with 4 buttons, you'll need to define the extra pin yourself in the code.
- Button Left (PIN_BTN_L): (D6) GPIO12
- Button Middle (PIN_BTN_M): (D7) GPIO13
- Button Right (PIN_BTN_R): (D8) GPIO15
Finally, solder the GND wire to the resistor outputs and connect 3.3V to the button inputs.
OLED Display
Screw in the 2x2mm screws and hot glue the SSD1306 to the front part of the cube solder the 4 wires to the OLED display, make sure you have some extra length, 4-5cm should be more than enough
The OLED display must be connected via I2C on pins:
- SDA: D2 (GPIO4)
- SCL: D1 (GPIO5)
- GND: GND
- VCC: 3.3V pin or directly to the TP4056 output
Buzzer
Glue in the buzzer to the back part of the cube with superglue
As defined in the example config connect:
- the positive wire of the buzzer to the 3.3V
- the negative wire to PIN_BUZZER (D3) GPIO0
Battery Setup
The battery is optional. Your SmartCube will work fine when powered via USB; however, adding one makes it portable (and much cuter).
A single 700 mAh 14250 battery lasts about 24 hours. The TP4056 prevents the cell from being completely drained and should protect it from damage.
Although it's not shown in any of the pictures or schematics, both the case and the back cover are updated to include a slot for 8.5mm SPDT slider switch(SS-12D00), in case you actually want to have a power switch instead of letting it run until the battery drains.
- Solder the 14250 battery to the TP4056 input pins.
- Wire the TP4056 output to the 3.3V pin on the D1 Mini to power the device.
- Connect the 5V output pin from the D1 Mini to the TP4056 input port to allow charging through the USB data port on the ESP8266.
- (Optional) Add a voltage divider to monitor battery level on the ESP8266 A0 pin:
-
R1 = 220kΩ (between battery positive and A0)
-
R2 = 56kΩ (between A0 and GND)
This scales the battery voltage safely down for measurement (~0-0.85V).
-
As mentioned in the Bill of Materials you can also use 100kΩ and 47kΩ resistors, just be sure to edit example config
Schematics
This is the basic drawing of the circuit without the battery
This is the complete circuit including the battery and a voltage divider
GPIO Pin Reference Table
Component | GPIO Pin | PlatformIO / Code Macro |
---|---|---|
Left Button | D6 (GPIO12) | PIN_BTN_L |
Middle Button | D7 (GPIO13) | PIN_BTN_M |
Right Button | D8 (GPIO15) | PIN_BTN_R |
Buzzer | D3 (GPIO0) | PIN_BUZZER |
OLED SDA | D2 (GPIO4) | SDA |
OLED SCL | D1 (GPIO5) | SCL |
Battery Voltage Divider | A0 | A0 |
Demo Code Explanation
This repository contains a basic "Hello, World!" project for the SmartCube.
Getting Started:
- Download and install VSCode or VSCodium.
- Install the PlatformIO IDE extension.
- Clone this repository and open the project folder in VSCode/VSCodium.
- PlatformIO will automatically handle environment setup and dependencies when you open the project.
Uploading with PlatformIO
Once you open this git repository in VSCode and install the PlatformIO extension.
You can click on the PlatformIO icon on the left sidebar
In the PlatformIO panel, expand d1_mini_lite → General to reveal the available tasks.
Click Build to compile the firmware, and then click Upload to flash it to your SmartCube.
Project Structure:
All source code is located in the src/
directory.
You should start by opening src/main.cpp
, which contains the entry point and initialization logic.
What the Code Does:
This demo handles basic system functionality, including:
- System initialization
- Button input handling
- OLED display output configuration
- WiFi management
Key Features
WiFi Management
- The cubeWifiManager class manages WiFi connectivity seamlessly.
- If no known WiFi network is available, it starts a configuration portal and creates an access point (AP), allowing users to connect the SmartCube to a network from another WiFi-enabled device.
- The OLED display shows the access point details, such as the AP name and IP address, making the setup process very easy.
Button Handling
- Buttons are mapped to specific GPIO pins:
PIN_BTN_L
(Left),PIN_BTN_M
(Middle), andPIN_BTN_R
(Right). - The cubeButtonHandler function, executed in the loop(), monitors and interprets button presses, differentiating between short and long presses.
Default Button Actions
-
Right Button:
- Long Press: Turns the OLED display on (if previously off).
-
Left + Middle Buttons (Simultaneous Long Press):
- Triggers an ESP8266 reboot, effectively restarting the device.
This is meant to provide a minimal starting point for further development with the SmartCube.
Tips and tricks
- It's not as hard to make as it looks.
- Battery is the trickiest part to fit in, it's best to put in the case last.
- Test if everything works before completely closing the case shut.
- Make sure all connections are secure and not short-circuited.
- Hot glue is your friend, it will add extra protection from short-circuits and keep wires in place.
- Everything is pretty tightly packed in there and it can be quite a mess.
For questions or additional details, feel free to reach out! I would love to hear some feedback. Good luck and have fun :)