mirror of
https://github.com/Legolas-2025/Standalone-electricity-price-ticker.git
synced 2026-08-18 12:44:54 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a0fd42161 | ||
|
|
a7d479546d | ||
|
|
0f6fadd1f8 | ||
|
|
28f7be344f | ||
|
|
5c870f240c | ||
|
|
707ebcd99c | ||
|
|
4e9b9495cd | ||
|
|
1b17a7b80c | ||
|
|
91dea24da8 | ||
|
|
52c3727d39 | ||
|
|
824170a6d1 | ||
|
|
dfb11004ba | ||
|
|
739b21609e | ||
|
|
5ef53916ea | ||
|
|
b55a7b4945 | ||
|
|
d7e27b4f56 | ||
|
|
614be25a1f | ||
|
|
1e5fa661f0 |
@@ -2,6 +2,93 @@
|
||||
|
||||
All notable changes to this project are documented here.
|
||||
|
||||
## v6.2.4 - Exact-boundary display refresh bug (2026-04-01):
|
||||
|
||||
**Summary**
|
||||
|
||||
Top of the hour auto display refresh glitch fix where display automatically refreshed but showed the PREVIOUS hour's data.
|
||||
|
||||
### Problem:
|
||||
- At the exact top of the hour (e.g., 20:00:00), the display automatically refreshed but showed the PREVIOUS hour's data (19:00). This happened because the "next-boundary" rounding logic in findCurrentPriceIndex() incorrectly excluded the current interval if the time was exactly on the boundary.
|
||||
|
||||
### Solution:
|
||||
- Simplified findCurrentPriceIndex() to use a robust "last entry <= now" comparison. This ensures the display transitions to the new hour instantaneously at XX:00:00.
|
||||
|
||||
---
|
||||
|
||||
## v6.2.3 - State-based display refresh logic fix (2026-04-01):
|
||||
|
||||
**Summary**
|
||||
|
||||
The refresh logic should be "State-Based" rather than "Event-Based." Instead of checking if the minute is zero, it should check if the current hour is different from the last recorded hour.
|
||||
|
||||
### Problem: Screen would occasionally fail to update if the ESP32 was busy
|
||||
- fetching data or reconnecting WiFi) during the exact 00/15/30/45 minute mark.
|
||||
|
||||
### Solution: Switched from "Event-Based" (refresh only AT minute X) to "State-Based"
|
||||
|
||||
(refresh IF current time != last refresh time).
|
||||
- This ensures the screen updates immediately even if the device was busy during the transition.
|
||||
|
||||
---
|
||||
|
||||
## v6.2.2 - Display blank lines issue fix (2026-03-31):
|
||||
|
||||
**Summary**
|
||||
|
||||
Fixed a bug where the display was showing blank lines
|
||||
|
||||
### Problem: Sometimes rows 0 and 1 (current 15-min prices and current hour) were blank
|
||||
|
||||
**Cause:** The "hour suppression" logic was hiding the current hour unexpectedly
|
||||
|
||||
### Solution:
|
||||
|
||||
- Row 1 (current hour) now ALWAYS shows - suppression logic only applies to rows 2-3
|
||||
- Row 0 (15-min details) also always shows for the current hour
|
||||
|
||||
---
|
||||
|
||||
## v6.2.1 – Current Interval Fix (2026‑03‑29)
|
||||
|
||||
**Summary**
|
||||
|
||||
Fixed a bug where the display was showing prices one hour ahead of the current time.
|
||||
|
||||
### Problem: Display Showing Next Hour Instead of Current
|
||||
|
||||
**Root Cause:**
|
||||
|
||||
The `findCurrentPriceIndex()` function was finding the **next** 15-minute interval (first entry with timestamp >= now), but it should find the **current** interval (the one we're currently IN).
|
||||
|
||||
For example, at 17:57:
|
||||
- The current 15-minute interval is **17:45-18:00** (price indexed at 17:45)
|
||||
- The **next** interval is 18:00-18:15 (price indexed at 18:00)
|
||||
- The buggy function returned the index for **18:00** instead of **17:45**
|
||||
- Result: Display showed hour **18** instead of hour **17**
|
||||
|
||||
### Solution
|
||||
|
||||
The fix calculates the **next 15-minute boundary** and finds the last entry **strictly before** that boundary:
|
||||
|
||||
```cpp
|
||||
// Calculate the next 15-minute boundary
|
||||
const int QUARTER_SECONDS = 15 * 60; // 900 seconds
|
||||
time_t nextQuarter = ((now + QUARTER_SECONDS - 1) / QUARTER_SECONDS) * QUARTER_SECONDS;
|
||||
|
||||
// Find the last entry strictly before nextQuarter
|
||||
for (size_t i = unixSeconds.size(); i > 0; i--) {
|
||||
if ((time_t)unixTime < nextQuarter) {
|
||||
return (int)(i - 1);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Example:**
|
||||
- At 17:57: nextQuarter = 18:00, finds last entry < 18:00 = 17:45 ✅
|
||||
- At 18:00: nextQuarter = 18:15, finds last entry < 18:15 = 18:00 ✅
|
||||
- At 18:46: nextQuarter = 19:00, finds last entry < 19:00 = 18:45 ✅
|
||||
|
||||
---
|
||||
|
||||
## v6.2.0 – DST (Daylight Saving Time) Handling Fixed (2026‑03‑29)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5,13 +5,38 @@
|
||||
This project is an Arduino‑IDE‑friendly firmware for the **Seeed XIAO ESP32‑C3** that:
|
||||
|
||||
- Connects to Wi‑Fi.
|
||||
- Fetches **day‑ahead electricity prices** from [Energy‑Charts.info](https://energy-charts.info) (Bundesnetzagentur / SMARD.de).
|
||||
- Fetches **day‑ahead electricity prices** from [Energy‑Charts.info](https://energy-charts.info).
|
||||
- Computes final consumer prices (including configurable power‑company fee + VAT).
|
||||
- Displays current and upcoming prices on a **20x4 I²C 2004 LCD**.
|
||||
- Uses a white LED and an optional presence sensor to give quick visual feedback.
|
||||
- Stores daily price data in **NVS** to survive reboots and reduce API calls.
|
||||
|
||||
The latest sketch implements **Version 6.2.0**, focusing on:
|
||||
The latest sketch implements **Version 6.2.4**.
|
||||
|
||||
---
|
||||
|
||||
## Version Highlights
|
||||
|
||||
### v6.2.4 - Exact-boundary display refresh bug (critical fix of v6.2.3 update)
|
||||
- Problem: At the exact top of the hour (e.g., 20:00:00), the display automatically refreshed but showed the PREVIOUS hour's data (19:00). This happened because the "next-boundary" rounding logic in findCurrentPriceIndex() incorrectly excluded the current interval if the time was exactly on the boundary.
|
||||
- Fix: Simplified findCurrentPriceIndex() to use a robust "last entry <= now" comparison. This ensures the display transitions to the new hour instantaneously at XX:00:00.
|
||||
|
||||
### v6.2.3 - State-based display refresh logic (critical fix of v6.2.2 update)
|
||||
- Problem: Screen would occasionally fail to update if the ESP32 was busy (fetching data or reconnecting WiFi) during the exact 00/15/30/45 minute mark.
|
||||
- Fix: Switched from "Event-Based" (refresh only AT minute X) to "State-Based" (refresh IF current time != last refresh time). This ensures the screen updates immediately even if the device was busy during the transition.
|
||||
|
||||
### v6.2.2 - Display Blank Lines Issue Fix (critical fix of v6.2.1 update)
|
||||
- Problem: Sometimes rows 0 and 1 (current 15-min prices and current hour) were blank.
|
||||
- Cause: The "hour suppression" logic was hiding the current hour unexpectedly.
|
||||
- Fix:
|
||||
- Row 1 (current hour) now ALWAYS shows - suppression logic only applies to rows 2-3.
|
||||
- Row 0 (15-min details) also always shows for the current hour.
|
||||
|
||||
### v6.2.1 – Current Interval Fix (critical fix of v6.2.0 update)
|
||||
- Fixed display showing prices one hour ahead of the current time.
|
||||
- `findCurrentPriceIndex()` now correctly returns the current 15-minute interval.
|
||||
|
||||
Major update sketch implements **Version 6.2.0**, focusing on:
|
||||
|
||||
- **Version 6.2.0 FIX**: **DST (Daylight Saving Time) handling fully fixed** – the ticker now works correctly on ALL days including DST switch days (spring forward and fall back). Uses timestamp-based price lookups instead of arithmetic calculations.
|
||||
- Version 6.1.2 fix: restore correct **white LED indicator** behavior (ESP32 PWM fix; no dim glow when off).
|
||||
|
||||
+82
-8
@@ -2,13 +2,89 @@
|
||||
|
||||
## Current firmware
|
||||
|
||||
- **Version:** 6.2.0
|
||||
- **Release date:** 2026-03-29
|
||||
- **Version:** 7.0
|
||||
- **Release date:** 2026-04-03
|
||||
- **Target MCU:** Seeed XIAO ESP32‑C3
|
||||
- **Display:** 20x4 I²C LCD (PCF8574, default address `0x27`)
|
||||
- **API endpoint:** `https://api.energy-charts.info/price?bzn=SI`
|
||||
- **Resolution:** 15‑minute intervals, hourly averages for overview
|
||||
|
||||
## Highlights of v7.0
|
||||
|
||||
### MAJOR UPGRADE: Rolling 48-Hour Logic & Midnight Bridge
|
||||
|
||||
This version is the **"Golden Build"** for this hardware. It represents the culmination of hardware stability fixes from v6.2.4 combined with revolutionary new 48-hour price prediction capabilities.
|
||||
|
||||
#### 1. The Midnight Bridge (Rollover Logic)
|
||||
|
||||
The most complex part of electricity tickers is handling the midnight transition. This code now correctly detects the moment the local clock moves from 23:59:59 to 00:00:00.
|
||||
|
||||
**The Swap:** Instead of waiting for a slow API call at midnight (which usually fails because the server hasn't updated yet), the code instantly promotes the "Tomorrow" buffer to become "Today" data.
|
||||
|
||||
**The NVS Update:** The code correctly serializes the new "Today" data and saves it to NVS immediately after the swap. This ensures that if power cuts at 00:05 AM, the device reboots with the correct data already loaded.
|
||||
|
||||
#### 2. Dual-Buffer NVS System
|
||||
|
||||
The ticker now stores "Today" and "Tomorrow" data independently in NVS:
|
||||
|
||||
- **Today buffer (`doc`)**: Contains the current day's price data
|
||||
- **Tomorrow buffer (`docTomorrow`)**: Contains the next day's price data
|
||||
- **NVS keys**: `data_prc`/`data_day`/`data_mon`/`data_year` for today, `data_prc_t`/`data_store_t` for tomorrow
|
||||
|
||||
#### 3. Smart Fetching & API URL
|
||||
|
||||
The logic for fetching tomorrow's data is implemented correctly:
|
||||
|
||||
- **URL Construction**: Adding `&start=YYYY-MM-DD` dynamically after 14:00 (2 PM) queries the Energy-Charts API for the next day
|
||||
- **Validation**: In `processJsonData()`, the code compares the timestamp in the JSON against the target date, preventing the "Tomorrow" buffer from being filled with "Today's" data if the API is lagging
|
||||
|
||||
#### 4. Seamless 48H Scrolling
|
||||
|
||||
If next-day data is available, the button allows scrolling up to **47 hours ahead**:
|
||||
|
||||
- **Visual Distinction**: Using `HH:>>` for tomorrow's hours prevents the user from confusing a cheap price "tomorrow" with a cheap price "today"
|
||||
- **Index Safety**: The code correctly uses `lowestPriceIndexTomorrow` and `highestPriceIndexTomorrow` when the display is in the "tomorrow" range, ensuring the Min/Max icons appear on the correct 15-minute segments
|
||||
|
||||
#### 5. Hardware Stability (Inherited from v6.2.4)
|
||||
|
||||
All v6.2.4 hardware stability fixes are preserved:
|
||||
|
||||
- **Refresh Logic**: "State-Based" refresh ensures the display updates exactly at 00, 15, 30, and 45 minutes past the hour, even if the CPU is busy with a background fetch
|
||||
- **LED Indicators**: White LED for low price and Built-in LED for connectivity remain pinned to the actual current price, even when the user is scrolling through future data on the screen
|
||||
|
||||
#### Final "Sanity Check" Verdict
|
||||
|
||||
**Status:** Verified. The code is safe to deploy. The transition from 15-minute intervals to the midnight rollover is now seamless. The "1 AM fetch gap" that plagues most electricity tickers has been successfully bypassed.
|
||||
|
||||
---
|
||||
|
||||
## Highlights of v6.2.4
|
||||
|
||||
- **BUG FIX:** Exact-boundary display refresh bug
|
||||
- Problem: At the exact top of the hour (e.g., 20:00:00), the display automatically refreshed but showed the PREVIOUS hour's data (19:00). This happened because the "next-boundary" rounding logic in findCurrentPriceIndex() incorrectly excluded the current interval if the time was exactly on the boundary.
|
||||
- Fix: Simplified findCurrentPriceIndex() to use a robust "last entry <= now" comparison. This ensures the display transitions to the new hour instantaneously at XX:00:00.
|
||||
|
||||
## Highlights of v6.2.3
|
||||
|
||||
- **BUG FIX**: State-based display refresh logic
|
||||
- Problem: Screen would occasionally fail to update if the ESP32 was busy (fetching data or reconnecting WiFi) during the exact 00/15/30/45 minute mark.
|
||||
- Fix: Switched from "Event-Based" (refresh only AT minute X) to "State-Based" (refresh IF current time != last refresh time). This ensures the screen updates immediately even if the device was busy during the transition.
|
||||
|
||||
## Highlights of v6.2.2
|
||||
|
||||
- **BUG FIX**: Display blank lines issue
|
||||
- Problem: Sometimes rows 0 and 1 (current 15-min prices and current hour) were blank
|
||||
- Cause: The "hour suppression" logic was hiding the current hour unexpectedly
|
||||
- Fix:
|
||||
- Row 1 (current hour) now ALWAYS shows - suppression logic only applies to rows 2-3
|
||||
- Row 0 (15-min details) also always shows for the current hour
|
||||
|
||||
## Highlights of v6.2.1
|
||||
|
||||
- **BUG FIX**: Fixed `findCurrentPriceIndex()` to return the correct current interval.
|
||||
- Problem: At 17:57, it returned index for 18:00 instead of 17:45, causing display to show hour 18 instead of hour 17.
|
||||
- Fix: Now calculates next 15-minute boundary and finds the last entry before that boundary.
|
||||
|
||||
## Highlights of v6.2.0
|
||||
|
||||
- **CRITICAL FIX**: DST (Daylight Saving Time) handling is now fully fixed for all days.
|
||||
@@ -21,11 +97,6 @@
|
||||
- The ticker now works correctly on all days, including DST switch days, with no manual intervention.
|
||||
- **Future-proof**: If EU cancels DST, only the `TZ_CET_CEST` string needs updating (one line of code).
|
||||
|
||||
For full details, see:
|
||||
|
||||
- [CHANGELOG.md](./CHANGELOG.md)
|
||||
- [README.md](./README.md)
|
||||
|
||||
## Previous firmware
|
||||
|
||||
- **Version:** 6.1.2
|
||||
@@ -43,4 +114,7 @@ For full details, see:
|
||||
- **Version:** 6.1.0 (2026-01-30) – Midnight fetch and market day detection fixes
|
||||
- **Version:** 6.0.0 (2026-01-27) – NVS storage and daily fetch
|
||||
|
||||
For detailed history, see [CHANGELOG.md](./CHANGELOG.md).
|
||||
For full details, see:
|
||||
|
||||
- [CHANGELOG.md](./CHANGELOG.md)
|
||||
- [README.md](./README.md)
|
||||
|
||||
Reference in New Issue
Block a user