Upgrade to 1.2
This commit is contained in:
@@ -57,7 +57,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 |
|
||||
| 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 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 |
|
||||
|
||||
|
||||
@@ -163,6 +163,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).
|
||||
|
||||
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
|
||||
|
||||
// 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 V_REF = 1.0; // ESP8266 ADC reference voltage
|
||||
const float V_REF = 3.3; // ESP8266 ADC reference voltage
|
||||
|
||||
float readBatteryVoltage() {
|
||||
int rawADC = analogRead(ADC_PIN);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
void interactiveCubeDemo() {
|
||||
const int cx = SCREEN_WIDTH / 2;
|
||||
const int cy = SCREEN_HEIGHT / 2;
|
||||
const int size = 15; // small cube
|
||||
const int cy = SCREEN_HEIGHT / 2 - 10;
|
||||
const int size = 14; // small cube
|
||||
float angle = 0;
|
||||
float speed = 0.05;
|
||||
bool rotating = true;
|
||||
@@ -53,6 +53,19 @@ void interactiveCubeDemo() {
|
||||
} else {
|
||||
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 sinA = sin(angle);
|
||||
|
||||
|
@@ -8,4 +8,10 @@
|
||||
#define PIN_BTN_L 12 // D6
|
||||
#define PIN_BTN_M 13 // D7
|
||||
#define PIN_BTN_R 14 // 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.2 // Full battery voltage
|
||||
#define VOLTAGE_MIN 3.0 // Empty battery voltage
|
15
src/main.cpp
15
src/main.cpp
@@ -1,10 +1,11 @@
|
||||
#include "example_config.h" // Include the configuration header file
|
||||
#include <Arduino.h> // Include the core Arduino library
|
||||
#include <Adafruit_SSD1306.h> // Include the Adafruit library for the SSD1306 OLED display
|
||||
#include "SmartCube/cubeSound.h" // Include custom header for sound 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/cubeDemo.h" // Remove this if not using demo functions
|
||||
#include "example_config.h" // Include the configuration header file
|
||||
#include <Arduino.h> // Include the core Arduino library
|
||||
#include <Adafruit_SSD1306.h> // Include the Adafruit library for the SSD1306 OLED display
|
||||
#include "SmartCube/cubeSound.h" // Include custom header for sound 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/cubeBattery.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
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
Reference in New Issue
Block a user