Skip to content

Commit 05a26c5

Browse files
committed
switch time delay, diagnostic screen
- time delay for switch is now working - controling the switch is now in new separate file - new diagnostic screen added including the tests for gps, rtc and eeprom - milliseconds removed from printDelay() due to use for uptime counter - precision parameter changed semantics in printDate...() functions - some optimizations for smaller code size
1 parent 40e53e5 commit 05a26c5

File tree

12 files changed

+1356
-257
lines changed

12 files changed

+1356
-257
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ depending on sunset/sunrise at actual geo position. With GPS and RTC.
55
## Hardware used
66
* Arduino Nano
77
* GPS module NEO-6M
8-
* RTC module DS3231 with eeprom AT24C32
8+
* RTC module DS3231 with EEPROM AT24C32
99
* LCD display 20x4 LCD2004A
10-
* some pushbuttons, cables, etc.
10+
* some pushbuttons, relay, wires, etc.
1111

1212
## Libraries used
1313
* TinyGPSPlus

SolarTimer.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
/*
22
* This file is only here to make the Arduino IDE happy.
33
* Please continue to "src/main.cpp" where are setup() and loop().
4+
*
5+
* SolarTimer
6+
* Timer switch for Arduino (fits Arduino Nano) that turns night lights
7+
* (like street lamps or decorative lighting) on/off depending on sunset/sunrise
8+
* at actual geo position. With GPS and RTC.
9+
*
10+
* Copyright (C) 2025 by Štěpán Škrob. Licensed under GNU GPL v3.0 license.
11+
* https://github.com/solamyl/SolarTimer
412
*/
513

614
// version string, at least this file has some use...
7-
const char * appVersion = "SolarTimer v1.1.1";
15+
const char * appVersion = "SolarTimer v1.2.0";

docs/notes.txt

Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
global variables memory occupation:
2+
====================================
3+
4+
-- main.cpp --
5+
sizeof(gps)=173
6+
sizeof(ss)=31
7+
sizeof(rtc)=24
8+
sizeof(eeprom)=10
9+
sizeof(lcd)=27
10+
sizeof(buttonSelect)=10
11+
sizeof(buttonPlus)=21
12+
sizeof(buttonMinus)=21
13+
sizeof(detectReset)=9
14+
sizeof(uptimeSecs)=4
15+
= 330 bytes
16+
Sketch uses 27810 bytes (90%) of program storage space. Maximum is 30720 bytes.
17+
Global variables use 1846 bytes (90%) of dynamic memory, leaving 202 bytes for local variables. Maximum is 2048 bytes.
18+
*** memory overflow!! ***
19+
20+
-- config.cpp + DateTime.cpp + display.cpp --
21+
sizeof(config)=18
22+
sizeof(DateTime::daysInMonth)=12
23+
sizeof(backlightTS)=4
24+
sizeof(backlightOn)=1
25+
sizeof(refreshScreen)=1
26+
sizeof(selectScreen)=2
27+
= 38 bytes
28+
Sketch uses 27708 bytes (90%) of program storage space. Maximum is 30720 bytes.
29+
Global variables use 1808 bytes (88%) of dynamic memory, leaving 240 bytes for local variables. Maximum is 2048 bytes.
30+
*** memory looks sufficient ***
31+
32+
-- gps.cpp --
33+
sizeof(rtcSetTS)=4
34+
sizeof(positionSetTS)=4
35+
sizeof(sunsetCalcTS)=4
36+
sizeof(sunsetTimeLocal)=6
37+
sizeof(sunriseTimeLocal)=6
38+
sizeof(switchOnTimeUtc)=6
39+
sizeof(switchOnTimeLocal)=6
40+
sizeof(switchOffTimeUtc)=6
41+
sizeof(switchOffTimeLocal)=6
42+
sizeof(TZ_offset)=4
43+
sizeof(DST_offset)=4
44+
= 56 bytes
45+
Sketch uses 27914 bytes (90%) of program storage space. Maximum is 30720 bytes.
46+
Global variables use 1934 bytes (94%) of dynamic memory, leaving 114 bytes for local variables. Maximum is 2048 bytes.
47+
*** memory overflow!! ***
48+
49+
-- switch.cpp --
50+
sizeof(currentSwitchState)=1
51+
sizeof(newSwitchState)=1
52+
sizeof(switchDelayStartTS)=4
53+
= 6 bytes
54+
Sketch uses 27606 bytes (89%) of program storage space. Maximum is 30720 bytes.
55+
Global variables use 1754 bytes (85%) of dynamic memory, leaving 294 bytes for local variables. Maximum is 2048 bytes.
56+
*** memory looks sufficient ***
57+
58+
total in global vars = 430 bytes
59+
60+
61+
GPS runtime stats:
62+
====================
63+
64+
GPS OK speed 9600
65+
66+
Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
67+
(deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail
68+
----------------------------------------------------------------------------------------------------------------------------------------
69+
**** ***** ********** *********** **** 01/03/2026 17:45:47 29 ****** ****** ***** *** ******** ****** *** 145 0 1
70+
0 100.0 ********** *********** **** 01/03/2026 17:45:48 166 ****** ****** ***** *** ******** ****** *** 619 0 1
71+
0 100.0 ********** *********** **** 01/03/2026 17:45:49 252 ****** ****** ***** *** ******** ****** *** 1097 0 1
72+
0 100.0 ********** *********** **** 01/03/2026 17:45:50 333 ****** ****** ***** *** ******** ****** *** 1561 0 1
73+
0 100.0 ********** *********** **** 01/03/2026 17:45:51 376 ****** ****** ***** *** ******** ****** *** 1955 0 1
74+
0 100.0 ********** *********** **** 01/03/2026 17:45:52 382 ****** ****** ***** *** ******** ****** *** 2349 0 1
75+
0 100.0 ********** *********** **** 01/03/2026 17:45:53 383 ****** ****** ***** *** ******** ****** *** 2743 0 1
76+
0 100.0 ********** *********** **** 01/03/2026 17:45:54 391 ****** ****** ***** *** ******** ****** *** 3137 0 1
77+
0 100.0 ********** *********** **** 01/03/2026 17:45:55 397 ****** ****** ***** *** ******** ****** *** 3531 0 1
78+
0 100.0 ********** *********** **** 01/03/2026 17:45:56 407 ****** ****** ***** *** ******** ****** *** 3925 0 1
79+
0 100.0 ********** *********** **** 01/03/2026 17:45:57 414 ****** ****** ***** *** ******** ****** *** 4319 0 1
80+
0 100.0 ********** *********** **** 01/03/2026 17:45:58 421 ****** ****** ***** *** ******** ****** *** 4713 0 1
81+
0 100.0 ********** *********** **** 01/03/2026 17:45:59 426 ****** ****** ***** *** ******** ****** *** 5107 0 1
82+
0 100.0 ********** *********** **** 01/03/2026 17:46:00 435 ****** ****** ***** *** ******** ****** *** 5501 0 1
83+
0 100.0 ********** *********** **** 01/03/2026 17:46:01 443 ****** ****** ***** *** ******** ****** *** 5895 0 1
84+
0 100.0 ********** *********** **** 01/03/2026 17:46:02 448 ****** ****** ***** *** ******** ****** *** 6289 0 1
85+
0 100.0 ********** *********** **** 01/03/2026 17:46:03 457 ****** ****** ***** *** ******** ****** *** 6683 0 1
86+
0 100.0 ********** *********** **** 01/03/2026 17:46:04 464 ****** ****** ***** *** ******** ****** *** 7077 0 1
87+
0 100.0 ********** *********** **** 01/03/2026 17:46:05 471 ****** ****** ***** *** ******** ****** *** 7471 0 1
88+
0 100.0 ********** *********** **** 01/03/2026 17:46:06 479 ****** ****** ***** *** ******** ****** *** 7865 0 1
89+
3 6.7 ********** *********** **** 01/03/2026 17:59:54 199 ****** ****** ***** *** ******** ****** *** 25352 0 0
90+
3 6.7 ********** *********** **** 01/03/2026 17:59:55 282 ****** ****** ***** *** ******** ****** *** 25396 0 0
91+
3 6.7 ********** *********** **** 01/03/2026 17:59:56 339 ****** ****** ***** *** ******** ****** *** 25434 0 0
92+
3 6.7 ********** *********** **** 01/03/2026 17:59:57 347 ****** ****** ***** *** ******** ****** *** 25470 0 0
93+
3 6.7 50.007389 14.582209 245 01/03/2026 17:59:58 372 288.50 0.00 7.19 N 1046 284.82 WNW 25517 2 0
94+
3 6.7 50.007396 14.582252 302 01/03/2026 17:59:59 417 288.50 0.00 3.11 N 1046 284.82 WNW 25563 4 0
95+
3 6.7 50.007400 14.582280 312 01/03/2026 18:00:00 428 288.50 0.00 2.07 N 1046 284.82 WNW 25609 6 0
96+
3 6.7 50.007396 14.582283 322 01/03/2026 18:00:01 437 288.50 0.00 1.22 N 1046 284.82 WNW 25656 8 0
97+
3 6.7 50.007400 14.582310 331 01/03/2026 18:00:02 447 288.50 0.00 3.82 N 1046 284.82 WNW 25702 10 0
98+
3 6.7 50.007404 14.582242 344 01/03/2026 18:00:03 458 288.50 0.00 2.20 N 1046 284.82 WNW 25749 12 0
99+
3 6.7 50.007404 14.582286 351 01/03/2026 18:00:04 467 288.50 0.00 4.13 N 1046 284.82 WNW 25795 14 0
100+
3 6.7 50.007408 14.582276 361 01/03/2026 18:00:05 477 288.50 0.00 2.28 N 1046 284.82 WNW 25841 16 0
101+
102+
charsProcessed=1954
103+
sentencesWithFix=2
104+
failedChecksum=6
105+
passedChecksum=21
106+
107+
charsProcessed=3575
108+
sentencesWithFix=18
109+
failedChecksum=0
110+
passedChecksum=59
111+
112+
--------------
113+
114+
GPS wrong serial speed 4800
115+
116+
Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
117+
(deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail
118+
----------------------------------------------------------------------------------------------------------------------------------------
119+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
120+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 198 0 22
121+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 396 0 43
122+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 709 0 76
123+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 990 0 106
124+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1188 0 126
125+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1386 0 146
126+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1658 0 172
127+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1980 0 207
128+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2178 0 228
129+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2376 0 249
130+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2606 0 271
131+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2970 0 312
132+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 3168 0 332
133+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 3366 0 352
134+
135+
charsProcessed=2207
136+
sentencesWithFix=0
137+
failedChecksum=303
138+
passedChecksum=0
139+
140+
charsProcessed=2653
141+
sentencesWithFix=0
142+
failedChecksum=358
143+
passedChecksum=1
144+
145+
--------------
146+
147+
GPS wrong speed 2400
148+
149+
Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
150+
(deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail
151+
----------------------------------------------------------------------------------------------------------------------------------------
152+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
153+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 200 0 0
154+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 300 0 0
155+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 500 0 0
156+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 600 0 0
157+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 700 0 0
158+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 900 0 0
159+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1000 0 0
160+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1200 0 0
161+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1300 0 0
162+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1416 0 0
163+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1600 0 0
164+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1700 0 0
165+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 1900 0 0
166+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2000 0 0
167+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2118 0 0
168+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2300 0 0
169+
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 2400 0 0
170+
171+
charsProcessed=1356
172+
sentencesWithFix=0
173+
failedChecksum=0
174+
passedChecksum=0
175+
176+
charsProcessed=1264
177+
sentencesWithFix=0
178+
failedChecksum=0
179+
passedChecksum=0
180+
181+
--------------
182+
183+
184+
185+
draft of screen designs:
186+
============================
187+
188+
189+
.........|.........|
190+
sila signalu 95%
191+
24.12.2024 14:35:02
192+
UTC+01:00 zimni cas
193+
pozice [50.0N] 14.6E
194+
.........|.........|
195+
zap/vych 17:01-08:15
196+
slunce [-3.1] stupnu
197+
sviceni 17:35-07:45
198+
zpozdeni [+20] sec
199+
.........|.........|
200+
TEST sviceni
201+
vypnuti za [5] min
202+
.........|.........|
203+
204+
GPS pozice/cas FAIL
205+
RTC hodiny FAIL
206+
EEPROM config FAIL
207+
208+
209+
.........|.........|
210+
GPS (8) 50.1N 15.2E
211+
UTC 24.12.2024 00:35
212+
TZ +2:00
213+
214+
sun -5: 16:55-08:10
215+
ZAPNUTO TEST
216+
217+
218+
.........|.........|
219+
31.12.2024 08:58
220+
zapad 17:01-08:15
221+
slunce [-10] stupnu
222+
sviceni 17:35-07:45
223+
.........|.........|
224+
GPS sat 8 - dobry
225+
50.13484N 15.26454E
226+
UTC 24.12.2024 00:35
227+
TZ [+1:00] [zimni]
228+
.........|.........|
229+
31.12.2024 08:58
230+
TESTOVACI mod
231+
vypnuti za [5] min
232+
.........|.........|
233+
31.12.2024 08:58
234+
baterka - dobry
235+
posun zap [30] sec
236+
.........|.........|
237+
238+
239+
-----
240+
GPS 8 satelitu
241+
LOC 50.0075, 14.5820
242+
UTC 30.11.2025 01:36
243+
TZ +0100 evropa zima
244+
.........|.........|
245+
246+
247+
248+
TOTO VYPADA OK:
249+
250+
.........|.........|
251+
30.11.2025 01:36:30
252+
zap-vych 17:01-08:15
253+
sviceni 17:35-07:45
254+
slunce [-10] stupnu
255+
.........|.........|
256+
GPS 8 satelitu
257+
aktualni 50.00 14.58
258+
ulozeno 50.00 14.58
259+
[nechat ulozeny]
260+
[ulozit aktualni]
261+
.........|.........|
262+
serizeni pred 1 hod
263+
TZ evropa +0100 zima
264+
cas leto/zima [ano]
265+
posun spinac [+30s]
266+
.........|.........|
267+
268+
269+
270+
.........|.........|
271+
GPS 8 50.00,14.58
272+
30.11.2025 23:24:00
273+
zap-vych 17:01-08:15
274+
svic -10 17:35-07:45
275+
.........|.........|
276+
277+
.........|.........|
278+
GPS 100% 10 satelitu
279+
50.007625, 14.581941
280+
serizeni pred 6h
281+
posun spinace +0s
282+
.........|.........|
283+
slunce -2.0 stupnu
284+

0 commit comments

Comments
 (0)