Compare commits
8 Commits
f7c1039826
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bfe9076a3 | |||
| 7d8a9eafc8 | |||
| 55cb9177db | |||
| 128085056b | |||
| 9ea3f3c8f9 | |||
| a828f10d8b | |||
| cca9c19c9f | |||
| 4802ed0da3 |
12
Readme.md
12
Readme.md
@@ -1,8 +1,10 @@
|
|||||||
# SmartCube
|
# SmartCube
|
||||||
|
|
||||||
**SmartCube** is a tiny and customizable desk toy using the ESP8266 D1 Mini.
|
is a compact, customizable desk companion powered by an ESP8266 microcontroller.
|
||||||
Built entirely from cheap, easy-to-find parts, it can connect to Wi-Fi and can be programmed to do just about anything:
|
Built entirely from cheap, easy-to-find parts, it can be programmed for a variety of tasks:
|
||||||
show notifications, display the weather, monitor stuff, show a clock, serve a web site, mine crypto, be a virtual pet or whatever else your caffeine-fueled brain can imagine.
|
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!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ show notifications, display the weather, monitor stuff, show a clock, serve a we
|
|||||||
| 2x2mm screw | 4 (Optional) | Small screws for the front | Mostly for cosmetic purposes |
|
| 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 |
|
| 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 |
|
| TP4056 Module | 1 (Optional) | Charging and protection circuit | USB connector not required |
|
||||||
| Resistors (220kΩ and 56kΩ)| 1 (Optional) | Voltage divider | For monitoring the battery charge level |
|
| 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 |
|
| Micro Slider Switch (SS-12D00) | 1 (Optional) | On/Off switch | Only needed if installing the battery |
|
||||||
|
|
||||||
|
|
||||||
@@ -163,6 +165,8 @@ Although it's not shown in any of the pictures or schematics, both the case and
|
|||||||
|
|
||||||
This scales the battery voltage safely down for measurement (~0-0.85V).
|
This scales the battery voltage safely down for measurement (~0-0.85V).
|
||||||
|
|
||||||
|
As mentioned in the [Bill of Materials](#bill-of-materials) you can also use 100kΩ and 47kΩ resistors, just be sure to edit [example config](https://git.kopic.hr/tomislav/SmartCubeV1/src/branch/main/src/example_config.h)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|||||||
BIN
hardware/pictures/IMG_0044.jpg
Normal file
BIN
hardware/pictures/IMG_0044.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
BIN
hardware/pictures/IMG_0052.jpg
Normal file
BIN
hardware/pictures/IMG_0052.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
BIN
hardware/pictures/IMG_0053.jpg
Normal file
BIN
hardware/pictures/IMG_0053.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 MiB After Width: | Height: | Size: 1.2 MiB |
@@ -1,13 +1,7 @@
|
|||||||
#define ADC_PIN A0 // ESP8266 ADC pin
|
#define ADC_PIN A0 // ESP8266 ADC pin
|
||||||
|
|
||||||
// Tuneable min and max battery voltages
|
|
||||||
float VOLTAGE_MAX = 4.2; // Full battery voltage
|
|
||||||
float VOLTAGE_MIN = 3.0; // Empty battery voltage
|
|
||||||
|
|
||||||
const float R1 = 220000.0; // 220k ohms
|
|
||||||
const float R2 = 56000.0; // 56k ohms
|
|
||||||
const float ADC_MAX = 1023.0; // 10-bit ADC resolution
|
const float ADC_MAX = 1023.0; // 10-bit ADC resolution
|
||||||
const float V_REF = 1.0; // ESP8266 ADC reference voltage
|
const float V_REF = 3.3; // ESP8266 ADC reference voltage
|
||||||
|
|
||||||
float readBatteryVoltage() {
|
float readBatteryVoltage() {
|
||||||
int rawADC = analogRead(ADC_PIN);
|
int rawADC = analogRead(ADC_PIN);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
void interactiveCubeDemo() {
|
void interactiveCubeDemo() {
|
||||||
const int cx = SCREEN_WIDTH / 2;
|
const int cx = SCREEN_WIDTH / 2;
|
||||||
const int cy = SCREEN_HEIGHT / 2;
|
const int cy = SCREEN_HEIGHT / 2 - 10;
|
||||||
const int size = 15; // small cube
|
const int size = 14; // small cube
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
float speed = 0.05;
|
float speed = 0.05;
|
||||||
bool rotating = true;
|
bool rotating = true;
|
||||||
@@ -44,7 +44,7 @@ void interactiveCubeDemo() {
|
|||||||
display.setCursor(40, 18);
|
display.setCursor(40, 18);
|
||||||
display.println("version");
|
display.println("version");
|
||||||
display.setCursor(52, 28);
|
display.setCursor(52, 28);
|
||||||
display.println("1.1");
|
display.println("1.2");
|
||||||
display.drawLine(0, 40, SCREEN_WIDTH, 40, WHITE);
|
display.drawLine(0, 40, SCREEN_WIDTH, 40, WHITE);
|
||||||
display.setCursor(0, 44);
|
display.setCursor(0, 44);
|
||||||
display.println("by besna_shnita");
|
display.println("by besna_shnita");
|
||||||
@@ -53,6 +53,19 @@ void interactiveCubeDemo() {
|
|||||||
} else {
|
} else {
|
||||||
if (rotating) angle += speed;
|
if (rotating) angle += speed;
|
||||||
|
|
||||||
|
float voltage = readBatteryVoltage();
|
||||||
|
int percent = batteryPercentage(voltage);
|
||||||
|
display.setCursor(0, 55);
|
||||||
|
display.print("Battery:");
|
||||||
|
display.setCursor(66, 55);
|
||||||
|
display.print(voltage, 2);
|
||||||
|
display.print("V");
|
||||||
|
display.setCursor(98, 55);
|
||||||
|
display.print("(");
|
||||||
|
display.print(percent);
|
||||||
|
display.print("%");
|
||||||
|
display.print(")");
|
||||||
|
|
||||||
float cosA = cos(angle);
|
float cosA = cos(angle);
|
||||||
float sinA = sin(angle);
|
float sinA = sin(angle);
|
||||||
|
|
||||||
|
|||||||
@@ -9,3 +9,9 @@
|
|||||||
#define PIN_BTN_M 13 // D7
|
#define PIN_BTN_M 13 // D7
|
||||||
#define PIN_BTN_R 15 // D8
|
#define PIN_BTN_R 15 // D8
|
||||||
#define PIN_BUZZER 0 // D3
|
#define PIN_BUZZER 0 // D3
|
||||||
|
|
||||||
|
// Battery measurement
|
||||||
|
#define R1 220000.0 // 220k ohms
|
||||||
|
#define R2 56000.0 // 56k ohms
|
||||||
|
#define VOLTAGE_MAX 4.1 // Full battery voltage
|
||||||
|
#define VOLTAGE_MIN 3.0 // Empty battery voltage
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "SmartCube/cubeSound.h" // Include custom header for sound functions
|
#include "SmartCube/cubeSound.h" // Include custom header for sound functions
|
||||||
#include "SmartCube/cubeButtons.h" // Include custom header for button handling functions
|
#include "SmartCube/cubeButtons.h" // Include custom header for button handling functions
|
||||||
#include "SmartCube/cubeWifiManager.h" // Include custom header for managing WiFi connections
|
#include "SmartCube/cubeWifiManager.h" // Include custom header for managing WiFi connections
|
||||||
|
#include "SmartCube/cubeBattery.h" // Remove this if not using demo functions
|
||||||
#include "SmartCube/cubeDemo.h" // Remove this if not using demo functions
|
#include "SmartCube/cubeDemo.h" // Remove this if not using demo functions
|
||||||
|
|
||||||
// Initialize the OLED display with specified width, height, and reset pin
|
// Initialize the OLED display with specified width, height, and reset pin
|
||||||
|
|||||||
Reference in New Issue
Block a user