13 Commits

Author SHA1 Message Date
Splatink
df98815fc8 Update LICENSE 2025-09-28 20:58:08 +03:00
Splatink
34ebe62aaa Update readme.md 2025-09-28 20:53:11 +03:00
Splatink
152c83114f Create LICENSE 2025-03-07 09:10:24 +02:00
Splatink
679db9a5f3 Update main.cpp 2024-08-07 17:03:43 +03:00
Splatink
3d2c67157b Add files via upload 2024-07-26 22:46:18 +03:00
Splatink
53ce038f45 Delete main.cpp 2024-07-26 22:45:35 +03:00
Splatink
22ce569fcb Add files via upload 2024-07-26 22:43:32 +03:00
Splatink
7f51df11e1 Add files via upload 2024-07-08 09:16:52 +03:00
Splatink
55412b3bc9 Add files via upload 2024-07-08 09:06:04 +03:00
Splatink
cafe931162 Add files via upload 2024-07-08 09:03:20 +03:00
Splatink
487ead73dd Update readme.md 2024-07-07 10:07:35 +03:00
Splatink
cd011bfcb2 Update readme.md 2024-07-07 10:02:14 +03:00
Splatink
7f7c606aa5 Add files via upload 2024-07-07 09:58:36 +03:00
6 changed files with 147 additions and 19 deletions

28
LICENSE Normal file
View File

@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2025, Splatink
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

@@ -1,3 +1,15 @@
A digital clock and thermomter/hydrometer written in Arduino for the Raspberry Pi Pico using an SH1106 OLED dispaly and a BME280 environment sensor
A digital NTP clock and thermomter/hydrometer written in Arduino for the Raspberry Pi Pico using an SH1106 OLED dispaly and a BME280 environment sensor
Pin definitions and display drivers (as long as the display is 128x64) can easily be changed in the code
Pin definitions and display drivers (as long as the display is 128x64) can easily be changed in the code
Theoretical battery life is ~153 hours (6 days 9 hours) with a standard 2000mAh 18650 Li-Ion battery, power draw is around 12.5-13.5 mA
The battery level is read by the battery going into a simple 10k resistor voltage divider into ADC1
The OLED display and BME280 share the same I2C lines into the Pico
Pin definitions and display drivers (as long as the display is 128x64) can easily be changed in the code
28/09/25 WARNING: This code has bugs and holes. It is the first piece of software ever written by me, and since then, I've (unfotunetly) given up programming.
I am not responsible for anything that happens if you use this neither do I care.
If you want to run this, do so at your own risk and on an isolated IOT network.

View File

@@ -16,15 +16,68 @@
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
const char* ssid = "Limbo";
const char* password = "95H2O862U235@#";
const char* ssid = "teo";
const char* password = "teo";
bool lpmode;
bool lpmode, debugmode;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "gr.pool.ntp.org", 0, 1296000000);
Adafruit_BME280 bme;
void serialDebugInfo(float firmwareVersion, float batteryVoltage, float batteryPrecentage, int wifiRSSI, int wifiStatus, const char* day, bool brightness, float temperature, float humidity, float pressure, bool disconnected)
{
Serial1.print("Firmware Version: ");
Serial1.println(firmwareVersion, 1);
Serial1.print("Battery Voltage: ");
Serial1.println(batteryVoltage, 1);
Serial1.print("Battery Precentage: ");
Serial1.println(batteryPrecentage, 0);
Serial1.print("WiFi RSSI: ");
Serial1.println(wifiRSSI);
Serial1.print("WiFi Status: ");
Serial1.println(wifiStatus);
Serial1.print("Day: ");
Serial1.println(day);
Serial1.print("Brightness: ");
if (brightness == true)
{
Serial1.println("LOW");
}
else
{
Serial1.println("HIGH");
}
Serial1.print("Manually Disconnected WiFi: ");
if (disconnected == false)
{
Serial1.println("NO");
}
else
{
Serial1.println("YES");
}
Serial1.print("Low Power Mode: ");
if (lpmode == false)
{
Serial1.println("INACTIVE");
}
else
{
Serial1.println("ACTIVE");
}
Serial1.print("Temperature: ");
Serial1.print(temperature, 1);
Serial1.println(" C");
Serial1.print("Humidity: ");
Serial1.print(humidity, 1);
Serial1.println(" %");
Serial1.print("Pressure: ");
Serial1.print((pressure * 0.01), 1);
Serial1.println(" hPa");
Serial1.println("");
}
int batteryReader()
{
static int battery, readings, batterya;
@@ -40,15 +93,15 @@ int batteryReader()
return battery;
}
float getBatteryVoltage()
float getBatteryVoltage(int battery)
{
float battv = (batteryReader() * 3.3 / 4095) * 2;
float battv = (battery * 3.3 / 4095) * 2;
return battv;
}
float getBatteryPrecentage()
float getBatteryPrecentage(float battv)
{
float battp = (getBatteryVoltage() - 2.5) / (4.2 - 2.5) * 100;
float battp = (battv - 2.5) / (4.2 - 2.5) * 100;
if (battp <= 0)
{
battp = 1;
@@ -79,8 +132,7 @@ int getWifiRSSI()
return RSSI;
}
int getWifiStatus(){
int RSSI = getWifiRSSI();
int getWifiStatus(int RSSI){
int wifiStatus;
if (RSSI >= -55 && WiFi.status() == WL_CONNECTED)
{
@@ -106,10 +158,10 @@ int getWifiStatus(){
return wifiStatus;
}
const char* getDay()
const char* getDay(int dayInt)
{
const char* day;
switch (timeClient.getDay())
switch (dayInt)
{
case 0:
day = "Sun";
@@ -298,7 +350,7 @@ void setup()
Wire.setSCL(SCK);
Wire.setSDA(SDA);
WiFi.mode(WIFI_STA);
WiFi.hostname("pico-clock");
WiFi.hostname("pico-clock");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
@@ -318,21 +370,48 @@ void setup()
}
for (int i = 0; i < 10; i++)
{
getBatteryPrecentage();
getBatteryPrecentage(getBatteryVoltage(batteryReader()));
getWifiRSSI();
}
if (digitalRead(BUTTON) == true)
{
Serial1.setTX(0);
Serial1.setRX(1);
Serial1.begin(115200);
debugmode = true;
}
}
void loop()
{
bool disconnected;
static bool disconnected = false;
static int counter = 29;
timeClient.update();
displayClock(getDay(), getBatteryPrecentage(), getWifiStatus(), timeClient.getHours(), timeClient.getMinutes(), checkBrightness(), readTemperature(), readHumidity());
const char* day = getDay(timeClient.getDay());
float batteryVoltage = getBatteryVoltage(batteryReader());
float batteryPrecentage = getBatteryPrecentage(batteryVoltage);
int wifiRSSI = getWifiRSSI();
int wifiStatus = getWifiStatus(wifiRSSI);
int hours = timeClient.getHours();
int minutes = timeClient.getMinutes();
bool brightness = checkBrightness();
float temperature = readTemperature();
float humidity = readHumidity();
displayClock(day, batteryPrecentage, wifiStatus, hours, minutes, brightness, temperature, humidity);
if (debugmode == true && counter >= 30)
{
float pressure = bme.readPressure();
serialDebugInfo(2.2 ,batteryVoltage, batteryPrecentage, wifiRSSI, wifiStatus, day, brightness, temperature, humidity, pressure, disconnected);
counter = 0;
}
counter++;
sleep_ms(1000);
if (lpmode == true && disconnected == false)
{
WiFi.disconnect();
set_sys_clock_khz(20000, true);
disconnected = true;
}
}
}

View File

@@ -1,5 +1,14 @@
**CHANGELOG:**
2.2:
* Changed baudrate to standard 115200 baud
* Added a firmware version printout to serial
2.1:
* Added a serial debugging mode. This mode is activated if the BUTTON is held at bootup. Serial debugging info (variables) are output on GPIO0(TX) at 9600 baud every 30 seconds.
* All functions are now called seperately and their return values placed in variables to be given to displayClocl() and serialDebugInfo()
* Removed functions calling other functions by themselves
2.0:
* Removed DHT reading capabilities, second core is now unused
* Added BME280 sensor reading, displayClock() now requires the temperature and humidity to be provided instead of being global variables
@@ -54,4 +63,4 @@
1.0:
* Updated battery precentage calculator math to original (measurement - min) / (max - min) * 100
* Created this updates.md file
* Created this updates.md file