Compare commits
798 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71e7e779da | ||
|
|
99904f9097 | ||
|
|
89015191de | ||
|
|
a7d3382947 | ||
|
|
abef32c73c | ||
|
|
b52c580f6f | ||
|
|
429f0ba699 | ||
|
|
d918a593ce | ||
|
|
fb410ecfef | ||
|
|
ee6c249370 | ||
|
|
05b340738e | ||
|
|
86663f53f6 | ||
|
|
bd11dee1e5 | ||
|
|
29c8011cda | ||
|
|
4884d3a0e2 | ||
|
|
6079b17e3d | ||
|
|
d069d4e102 | ||
|
|
e1162ad970 | ||
|
|
71be381e1a | ||
|
|
a19901b58f | ||
|
|
361d3a38ed | ||
|
|
c22bca3130 | ||
|
|
2bfd863882 | ||
|
|
17c87c40df | ||
|
|
10b76ab2e6 | ||
|
|
15c3b2067c | ||
|
|
e366f10632 | ||
|
|
fc1850195b | ||
|
|
b85d11b1f3 | ||
|
|
fff6d1b068 | ||
|
|
bdb0bf3df0 | ||
|
|
c6e111c347 | ||
|
|
063b960fc2 | ||
|
|
95967aaf59 | ||
|
|
34e103c1d8 | ||
|
|
bdd2ec10cd | ||
|
|
37f90cb267 | ||
|
|
db90dbfd8f | ||
|
|
61d23ab453 | ||
|
|
864cd1fbbb | ||
|
|
517869f43d | ||
|
|
766849d6fc | ||
|
|
67e6a51a8a | ||
|
|
4093b64dd0 | ||
|
|
4068f127ba | ||
|
|
71abe188ca | ||
|
|
5022f42692 | ||
|
|
6c1401d042 | ||
|
|
7041a29894 | ||
|
|
e292f79421 | ||
|
|
d7ce808321 | ||
|
|
210ddad515 | ||
|
|
449257ae3f | ||
|
|
def9867990 | ||
|
|
26a63e30e0 | ||
|
|
9efdf1daa5 | ||
|
|
f2e7879974 | ||
|
|
b8ac1a9565 | ||
|
|
14eb27e0d9 | ||
|
|
f68666bd4a | ||
|
|
2087c287bf | ||
|
|
d85da6c9cb | ||
|
|
6a99b0a6a7 | ||
|
|
dfca5e37dc | ||
|
|
1f74f1e6b2 | ||
|
|
bdba6a0254 | ||
|
|
7c4c096e94 | ||
|
|
1ab5a4d2cb | ||
|
|
4bd2b5230b | ||
|
|
c0945abfa0 | ||
|
|
d94f27949c | ||
|
|
6a427b513d | ||
|
|
47a7d4e13b | ||
|
|
263ce9749a | ||
|
|
13d0521984 | ||
|
|
e3511f0ee2 | ||
|
|
f4de3e6178 | ||
|
|
2bb5361b22 | ||
|
|
9caec71e1c | ||
|
|
7813d3ea08 | ||
|
|
73ed4f87e4 | ||
|
|
c06dabba51 | ||
|
|
23cbcf9a0a | ||
|
|
785cefabb5 | ||
|
|
aa6283de5b | ||
|
|
2b563c7230 | ||
|
|
45d0fa2bfa | ||
|
|
09fdd2dc22 | ||
|
|
ab2086f909 | ||
|
|
16d1ee9761 | ||
|
|
348488af72 | ||
|
|
9103a5b730 | ||
|
|
830e22d182 | ||
|
|
21bff28aee | ||
|
|
e9472513d2 | ||
|
|
b6e69ca5d0 | ||
|
|
d28ef99cee | ||
|
|
3b531fab5b | ||
|
|
e575ab755c | ||
|
|
1ba452213d | ||
|
|
a2c20575c8 | ||
|
|
9a767d9ac4 | ||
|
|
52bc2f6a9b | ||
|
|
cfa4502af8 | ||
|
|
6fe308b5f6 | ||
|
|
80be1ceef1 | ||
|
|
bfa1a65dfd | ||
|
|
afcc542e25 | ||
|
|
f334847e82 | ||
|
|
9eb56beb6c | ||
|
|
87c565763a | ||
|
|
87ddf00afa | ||
|
|
e7ca408baa | ||
|
|
1d5c45c43c | ||
|
|
183cb1e2b1 | ||
|
|
768dc97c9c | ||
|
|
fe3f100edb | ||
|
|
8a59fcb89a | ||
|
|
333169ef8f | ||
|
|
d497aa91f4 | ||
|
|
b951fe9099 | ||
|
|
48ab87ba50 | ||
|
|
bad107926c | ||
|
|
6012c19fc4 | ||
|
|
460238e99d | ||
|
|
64870cf9ca | ||
|
|
cd446f8cb8 | ||
|
|
f68a3a321a | ||
|
|
9ff6cf355f | ||
|
|
453492b5eb | ||
|
|
f11263a48f | ||
|
|
fffd95dcf2 | ||
|
|
fa87cfaa61 | ||
|
|
50de5abf93 | ||
|
|
b1294fdd86 | ||
|
|
ce2a67a284 | ||
|
|
39e42d5333 | ||
|
|
7503f9a077 | ||
|
|
651f72489c | ||
|
|
3596a87ff9 | ||
|
|
5c1acf5c45 | ||
|
|
c46b7972d0 | ||
|
|
df26c91a3b | ||
|
|
7a70bd7511 | ||
|
|
c583c2b44a | ||
|
|
4c28d512a1 | ||
|
|
1775d0abce | ||
|
|
8e65f1fe14 | ||
|
|
c1d1bf6bb5 | ||
|
|
fc09ab5cc9 | ||
|
|
6e3a6f71e2 | ||
|
|
557ba659d5 | ||
|
|
32ad71bba6 | ||
|
|
8816097bca | ||
|
|
378b67a5bd | ||
|
|
859868c99b | ||
|
|
d7ca741c92 | ||
|
|
d49753ed33 | ||
|
|
2ae15ac13a | ||
|
|
00278659f8 | ||
|
|
0c1525b018 | ||
|
|
ed778441d5 | ||
|
|
c43c07386a | ||
|
|
91958f5464 | ||
|
|
194905237b | ||
|
|
f3805ad111 | ||
|
|
0f22fd561e | ||
|
|
ee462ec468 | ||
|
|
ed899440ed | ||
|
|
8e9e60ec03 | ||
|
|
a121fbd28e | ||
|
|
d823d747a5 | ||
|
|
c1b35b8ce0 | ||
|
|
fd996f44ba | ||
|
|
0606c47367 | ||
|
|
b6cd55719c | ||
|
|
b79f48d6ac | ||
|
|
ad342d2b7a | ||
|
|
8eb7136981 | ||
|
|
1c5303e771 | ||
|
|
9efc19090e | ||
|
|
a30cd76354 | ||
|
|
ddd08e25df | ||
|
|
09d255d656 | ||
|
|
7239f295e8 | ||
|
|
111bd70763 | ||
|
|
0e6abd0f18 | ||
|
|
2b0626b203 | ||
|
|
afa013ca03 | ||
|
|
6d4d901dba | ||
|
|
9c66a47464 | ||
|
|
5dc405f1da | ||
|
|
a2977180c1 | ||
|
|
725af5150d | ||
|
|
f734cb2179 | ||
|
|
8a0c0298ab | ||
|
|
56b6a720c9 | ||
|
|
76d76844a9 | ||
|
|
ae82914795 | ||
|
|
0fa178a617 | ||
|
|
8cada69aaf | ||
|
|
6bdd7855a7 | ||
|
|
faafc5a993 | ||
|
|
bbaf96f532 | ||
|
|
133c8bc967 | ||
|
|
f04e15f5d0 | ||
|
|
445973f9ce | ||
|
|
d6af7374c2 | ||
|
|
63c3d31552 | ||
|
|
d82e705875 | ||
|
|
206c90ca46 | ||
|
|
92ceb316cb | ||
|
|
a6d8857655 | ||
|
|
98858315de | ||
|
|
1ceffd0bc9 | ||
|
|
f7cb022e3e | ||
|
|
4634050700 | ||
|
|
60fff4533a | ||
|
|
6a0921a445 | ||
|
|
2a44f89a7b | ||
|
|
7b025ddb01 | ||
|
|
f9b4680b9c | ||
|
|
2a10096306 | ||
|
|
17d8d325c0 | ||
|
|
88ddc6ea15 | ||
|
|
3af19c9b15 | ||
|
|
2d6b523e37 | ||
|
|
28a6a62907 | ||
|
|
be9b7a16e4 | ||
|
|
81dedcbf6e | ||
|
|
248660e818 | ||
|
|
1a265492dd | ||
|
|
7b0c2eea33 | ||
|
|
f459b0af14 | ||
|
|
545be710ba | ||
|
|
fc01d7fd56 | ||
|
|
954984d8ee | ||
|
|
dd47523fd0 | ||
|
|
9b9d535dd0 | ||
|
|
e2ff7613b6 | ||
|
|
b9d6f16529 | ||
|
|
96c9c4c3a2 | ||
|
|
3229ae237e | ||
|
|
ecea4977b1 | ||
|
|
a3551316ba | ||
|
|
03edc65a7a | ||
|
|
40215ee746 | ||
|
|
b76efc42db | ||
|
|
94debd4233 | ||
|
|
dfbfbab531 | ||
|
|
b91dc5a17d | ||
|
|
67ca1fed01 | ||
|
|
baf8dc8310 | ||
|
|
6b0ea0abc0 | ||
|
|
bcea9698dd | ||
|
|
b435f0eaaf | ||
|
|
61c5500fdd | ||
|
|
719ceb610c | ||
|
|
fc42d4391b | ||
|
|
53afd37d08 | ||
|
|
103fe5c457 | ||
|
|
494cb55ef4 | ||
|
|
0a08767c9b | ||
|
|
49fd79f367 | ||
|
|
1ba168b268 | ||
|
|
c765746c62 | ||
|
|
e8016025d8 | ||
|
|
7cbcbd4bc8 | ||
|
|
4a3d884526 | ||
|
|
9c25eaff55 | ||
|
|
76f09b306a | ||
|
|
7c5a1b1fb8 | ||
|
|
84fe477783 | ||
|
|
4b34df091c | ||
|
|
7aa7f6adc6 | ||
|
|
c462b3bb00 | ||
|
|
4f90954084 | ||
|
|
1132db9bfa | ||
|
|
9d09c619e4 | ||
|
|
78891e8d33 | ||
|
|
e629bb0d68 | ||
|
|
ca1c237776 | ||
|
|
5b6b9879b1 | ||
|
|
06a0366762 | ||
|
|
538624b6eb | ||
|
|
4496b958ff | ||
|
|
b2a93c0b4c | ||
|
|
2cbe566910 | ||
|
|
a4b07f4097 | ||
|
|
f8cb9d187f | ||
|
|
5e9fe74dd0 | ||
|
|
5b7b30c0d0 | ||
|
|
9d902c63de | ||
|
|
a57405a7a5 | ||
|
|
550d32ee33 | ||
|
|
9f7e174c7b | ||
|
|
104617afd2 | ||
|
|
959664f61d | ||
|
|
5834b07393 | ||
|
|
8dbcf2424a | ||
|
|
74345046b1 | ||
|
|
516c80e38c | ||
|
|
17bbac8670 | ||
|
|
ccee3f505d | ||
|
|
48eb640838 | ||
|
|
90ebe3803d | ||
|
|
07ff4e2b0c | ||
|
|
7e011a184b | ||
|
|
324459df97 | ||
|
|
2db38835c5 | ||
|
|
804e43824b | ||
|
|
60c7cea724 | ||
|
|
b9fe6cab83 | ||
|
|
e3f41fdb4c | ||
|
|
9e5cb48101 | ||
|
|
259d8424a3 | ||
|
|
a6ae86abb8 | ||
|
|
a23abf626b | ||
|
|
849eac1c0f | ||
|
|
13dda2bb19 | ||
|
|
eea1782280 | ||
|
|
d729d0c5bd | ||
|
|
72cc0996e1 | ||
|
|
b1ad844bc6 | ||
|
|
4977ad3471 | ||
|
|
a3dcd2cfb2 | ||
|
|
c1701c8ee9 | ||
|
|
1e88148971 | ||
|
|
cef7ed15cb | ||
|
|
7c93537fef | ||
|
|
8b97544a2c | ||
|
|
a5f872a86c | ||
|
|
6e8233e4af | ||
|
|
d85d68b4a6 | ||
|
|
ed9cf4b87d | ||
|
|
39e86fa180 | ||
|
|
5d278a9d5a | ||
|
|
61040e3e7c | ||
|
|
c4005f10a3 | ||
|
|
7bed5add5d | ||
|
|
18e382f21f | ||
|
|
94865b632e | ||
|
|
f0461a7cdb | ||
|
|
4cd6013d64 | ||
|
|
b06dbb8d79 | ||
|
|
02fe2073c2 | ||
|
|
ec7ceafa84 | ||
|
|
276ac67d2e | ||
|
|
be116d5b35 | ||
|
|
9c8788225d | ||
|
|
df44b05792 | ||
|
|
8ee8eee6c4 | ||
|
|
28e13b73e6 | ||
|
|
088e5645c7 | ||
|
|
3e3d61912d | ||
|
|
b7854baa6d | ||
|
|
68bbfd6527 | ||
|
|
c1ca3d0c65 | ||
|
|
71cac46470 | ||
|
|
700f023292 | ||
|
|
ea43b2b632 | ||
|
|
c456e3fdf1 | ||
|
|
4947f0ec7f | ||
|
|
799c2f19d9 | ||
|
|
18dc188835 | ||
|
|
7db745829e | ||
|
|
81fedaaa6a | ||
|
|
71e0f13f0e | ||
|
|
f214af3595 | ||
|
|
fb9ae2f5f6 | ||
|
|
4c73f39214 | ||
|
|
1e7176af0b | ||
|
|
0d8c88b1fc | ||
|
|
d189d904fe | ||
|
|
3c86e824a2 | ||
|
|
061f6433d6 | ||
|
|
0d923e30d6 | ||
|
|
51f761d25e | ||
|
|
58fec70e7c | ||
|
|
dff55b4eee | ||
|
|
931f0d400b | ||
|
|
0178dc4184 | ||
|
|
be522b40f9 | ||
|
|
068c55e7bb | ||
|
|
8e88d7e11b | ||
|
|
e36acef1d4 | ||
|
|
07d5481a72 | ||
|
|
dbd6205cca | ||
|
|
35d47902c6 | ||
|
|
938f9f69d1 | ||
|
|
cd27472e2d | ||
|
|
64f8414217 | ||
|
|
a2c1250724 | ||
|
|
4b7160b502 | ||
|
|
cc50457404 | ||
|
|
cd48192a74 | ||
|
|
cd031c33aa | ||
|
|
6c59b15681 | ||
|
|
7c8593122b | ||
|
|
6d8fd4e083 | ||
|
|
79d674710f | ||
|
|
062068eacd | ||
|
|
98309ea532 | ||
|
|
0f75fa4a58 | ||
|
|
d08f75d9c3 | ||
|
|
dd4a43c831 | ||
|
|
1f5a04e606 | ||
|
|
4d6e63a171 | ||
|
|
0093410e05 | ||
|
|
ee63a606e8 | ||
|
|
d0ccd2d007 | ||
|
|
bb2f74d1ca | ||
|
|
dfef18fa09 | ||
|
|
485c21dc69 | ||
|
|
9ceb84bc9c | ||
|
|
24e68428c4 | ||
|
|
c2c5855e6a | ||
|
|
de19de2129 | ||
|
|
1719263de0 | ||
|
|
e70b872c98 | ||
|
|
b7d28238ab | ||
|
|
6c9a8b0692 | ||
|
|
9f3dba3aab | ||
|
|
e4e4ad4107 | ||
|
|
e8fb9570bb | ||
|
|
bc42099962 | ||
|
|
be71cbe609 | ||
|
|
0d6df03c94 | ||
|
|
d777040c0a | ||
|
|
a5636a60f8 | ||
|
|
6f817b2ed5 | ||
|
|
e4fec4f4c2 | ||
|
|
3a25964ec4 | ||
|
|
1227dff412 | ||
|
|
26ee2e6efc | ||
|
|
d6a8d31278 | ||
|
|
3f2b534baa | ||
|
|
70f413013c | ||
|
|
6edcd174bb | ||
|
|
3170ef6ce9 | ||
|
|
fb56f4d012 | ||
|
|
c5756f0cba | ||
|
|
95c9ecc8b2 | ||
|
|
bdee066c33 | ||
|
|
957039d0c0 | ||
|
|
dd23a0fa60 | ||
|
|
7777a0a059 | ||
|
|
e8fc6d48bf | ||
|
|
c98148c886 | ||
|
|
6ba2b4060e | ||
|
|
762c17ca8e | ||
|
|
fad6ada1e0 | ||
|
|
fb1d343ee3 | ||
|
|
1f3c32e80a | ||
|
|
43fbca7099 | ||
|
|
7a36082564 | ||
|
|
fb2cfdfe01 | ||
|
|
6c3dca9344 | ||
|
|
cce5d75fd7 | ||
|
|
8fd411c1d6 | ||
|
|
4b15ac74fc | ||
|
|
508b2e6c45 | ||
|
|
af630615db | ||
|
|
222a4f13e2 | ||
|
|
3bc6c75c5a | ||
|
|
dbb3eac709 | ||
|
|
1cee48eab4 | ||
|
|
c28752a00a | ||
|
|
365061df29 | ||
|
|
870617f780 | ||
|
|
4972b980ba | ||
|
|
51c70abda3 | ||
|
|
8d448533c7 | ||
|
|
43cb9a0000 | ||
|
|
d49b7eac09 | ||
|
|
8f057e687c | ||
|
|
5b4f680114 | ||
|
|
fabdfbadf4 | ||
|
|
afa47ea633 | ||
|
|
461d76e651 | ||
|
|
c40e20c8e9 | ||
|
|
4e97554514 | ||
|
|
28a9d6746b | ||
|
|
7ea4fe881c | ||
|
|
c4eaf8184b | ||
|
|
312972f77d | ||
|
|
27b9058af5 | ||
|
|
bc4d61098c | ||
|
|
b2de6472cf | ||
|
|
6c3ddc57b5 | ||
|
|
2ff7044c85 | ||
|
|
0145be851e | ||
|
|
6b0d540f39 | ||
|
|
2218ac4e8a | ||
|
|
33bd3da310 | ||
|
|
a239e1a63d | ||
|
|
8a809ec128 | ||
|
|
b48a0f13fe | ||
|
|
b07ed075f4 | ||
|
|
0927cab8e2 | ||
|
|
eed35b7bbc | ||
|
|
e34da5fd83 | ||
|
|
148fb14c93 | ||
|
|
000cfd8697 | ||
|
|
1ef5703971 | ||
|
|
cda3b80b35 | ||
|
|
c7b8090634 | ||
|
|
63a8d79b95 | ||
|
|
02ae3fc7f5 | ||
|
|
2dcc874592 | ||
|
|
d4d9d2224f | ||
|
|
902e43979b | ||
|
|
8e54f23367 | ||
|
|
ab7128c53a | ||
|
|
6563700df4 | ||
|
|
538de5ea99 | ||
|
|
042e2bcc85 | ||
|
|
b6f630b134 | ||
|
|
65a09dcecf | ||
|
|
775e5a0881 | ||
|
|
6c0d5fcc09 | ||
|
|
69d8fa9254 | ||
|
|
71d261bf34 | ||
|
|
9f4f5b4620 | ||
|
|
c38c305bab | ||
|
|
bfee2a1d64 | ||
|
|
ec7edae9a1 | ||
|
|
d8e265b7ac | ||
|
|
1987cddab7 | ||
|
|
e18be5f97c | ||
|
|
537597d6d1 | ||
|
|
a89013cec3 | ||
|
|
9c7a0cb7ff | ||
|
|
ade12199b9 | ||
|
|
92692c6eaf | ||
|
|
e4114c3e74 | ||
|
|
39b68aca51 | ||
|
|
feffbb53a3 | ||
|
|
8ac1e034b1 | ||
|
|
f446dff865 | ||
|
|
e1b2554af2 | ||
|
|
627a50ab50 | ||
|
|
a20d007b45 | ||
|
|
64840e13f0 | ||
|
|
34ebe9601a | ||
|
|
72f1d59338 | ||
|
|
07ed425320 | ||
|
|
2e75e1c4dc | ||
|
|
e6df68481f | ||
|
|
fa299198fc | ||
|
|
6d81b0a856 | ||
|
|
dd095da97b | ||
|
|
1b6ce203b7 | ||
|
|
2850be4e48 | ||
|
|
7eca31de84 | ||
|
|
a64f960cc7 | ||
|
|
ce3a47a7e6 | ||
|
|
8395e1dc77 | ||
|
|
39a4761415 | ||
|
|
dc25c147b9 | ||
|
|
867ab9d6c2 | ||
|
|
6a76144566 | ||
|
|
5e03e3d3c2 | ||
|
|
adb5050621 | ||
|
|
026cd25c8c | ||
|
|
06ec97b42a | ||
|
|
b420a0e6f4 | ||
|
|
7cd52d5689 | ||
|
|
ad78ff3082 | ||
|
|
fe7be81f1e | ||
|
|
7674fc2ad0 | ||
|
|
d50181c347 | ||
|
|
8ca771fa5a | ||
|
|
7d557b2679 | ||
|
|
2f0c912388 | ||
|
|
57e6d0fbe3 | ||
|
|
e7c25fafda | ||
|
|
2a4772fe25 | ||
|
|
f1f7408208 | ||
|
|
feb8e5007b | ||
|
|
c4af1ee74f | ||
|
|
992e1b6121 | ||
|
|
95d3008a66 | ||
|
|
04cd6ac387 | ||
|
|
584c7b1154 | ||
|
|
493c4b4337 | ||
|
|
488c969858 | ||
|
|
8b0d4185d3 | ||
|
|
9cc7529934 | ||
|
|
ef8715be6d | ||
|
|
e232b875fa | ||
|
|
f18171fecc | ||
|
|
a3c7a09211 | ||
|
|
a6f3bc3f71 | ||
|
|
44bcd386d1 | ||
|
|
01547f9a52 | ||
|
|
608470c5f7 | ||
|
|
940d38af5c | ||
|
|
4e451c51e1 | ||
|
|
43def1c311 | ||
|
|
2978116207 | ||
|
|
a055465ce0 | ||
|
|
68b3415a6c | ||
|
|
d8f3ae8b07 | ||
|
|
998b986604 | ||
|
|
7799431405 | ||
|
|
1a92cd1978 | ||
|
|
508c14a671 | ||
|
|
4a7ef87269 | ||
|
|
3a4fc707b0 | ||
|
|
5d2e320b07 | ||
|
|
d12613b91a | ||
|
|
e6a02f34ab | ||
|
|
0b2ffbfd77 | ||
|
|
cab6c54ed9 | ||
|
|
313024f273 | ||
|
|
91fc078c5e | ||
|
|
5b9d44a3e9 | ||
|
|
ed523bda24 | ||
|
|
e3a1a242d2 | ||
|
|
ddfade65d8 | ||
|
|
0ef8390df0 | ||
|
|
f43fe5f864 | ||
|
|
f9ddd7533a | ||
|
|
f9f18bc106 | ||
|
|
280dd8605b | ||
|
|
41324cf590 | ||
|
|
64132d5ce3 | ||
|
|
0e75732022 | ||
|
|
6975714922 | ||
|
|
7f3e0e6089 | ||
|
|
6ff5518738 | ||
|
|
be29daee77 | ||
|
|
a90ed40aee | ||
|
|
32ba6c31f0 | ||
|
|
caf00f99e3 | ||
|
|
aaa318e511 | ||
|
|
648cac0b06 | ||
|
|
a5d1a2c0ee | ||
|
|
55f1b4b129 | ||
|
|
b805363c60 | ||
|
|
846b166ae9 | ||
|
|
4e039c2cc9 | ||
|
|
e5556fe80b | ||
|
|
c5aa65a780 | ||
|
|
30cf1435da | ||
|
|
fca46a3f54 | ||
|
|
0dca85d67b | ||
|
|
d9a5a21fe0 | ||
|
|
68eaa7d39b | ||
|
|
3231d0747e | ||
|
|
2617956b38 | ||
|
|
07614226b3 | ||
|
|
cddb170f24 | ||
|
|
ba7915ca7c | ||
|
|
ee12db4f51 | ||
|
|
f01fbfca53 | ||
|
|
fab637cf60 | ||
|
|
b2e144efcf | ||
|
|
10308ce738 | ||
|
|
70f5b0f912 | ||
|
|
d724a90085 | ||
|
|
1ab529785a | ||
|
|
3a81e62bbe | ||
|
|
4882916b5c | ||
|
|
1f7e43256a | ||
|
|
a0d3632fd7 | ||
|
|
b25564a89f | ||
|
|
191d9fa562 | ||
|
|
e009b4e54e | ||
|
|
811625b706 | ||
|
|
15fa452c7c | ||
|
|
e725c01597 | ||
|
|
35b884713c | ||
|
|
d5fc9f6fc6 | ||
|
|
19c8396b1c | ||
|
|
f4622a068b | ||
|
|
9922862299 | ||
|
|
e7fc504975 | ||
|
|
6cdb943763 | ||
|
|
3e937a4e5d | ||
|
|
fcd3e3ca25 | ||
|
|
772004c0a2 | ||
|
|
c3e5ce344c | ||
|
|
b11b1d5e37 | ||
|
|
b5d34990df | ||
|
|
a287d310ac | ||
|
|
afe6190c46 | ||
|
|
2125945728 | ||
|
|
fb60127cf7 | ||
|
|
a07c55889f | ||
|
|
a675f56f9c | ||
|
|
0590ec375d | ||
|
|
48bd352619 | ||
|
|
40016f314e | ||
|
|
b9234f6f64 | ||
|
|
beafcd300b | ||
|
|
a92524eaf8 | ||
|
|
a60dd8a60a | ||
|
|
53296ccf42 | ||
|
|
42a627e32e | ||
|
|
c38034c69b | ||
|
|
0ec1a8ece3 | ||
|
|
45275c271e | ||
|
|
116761b46e | ||
|
|
a2c13fd0da | ||
|
|
b727f84c72 | ||
|
|
3706625760 | ||
|
|
0e1d2211ec | ||
|
|
785bec0269 | ||
|
|
2a4a199ae6 | ||
|
|
b6b9db5431 | ||
|
|
55bdd4437a | ||
|
|
3948fff184 | ||
|
|
c4b099b752 | ||
|
|
5cfcc015f4 | ||
|
|
724768afc4 | ||
|
|
efc20f1da9 | ||
|
|
b071344871 | ||
|
|
e0e98f0ec1 | ||
|
|
53d34852f1 | ||
|
|
c26073b2a3 | ||
|
|
b12a632618 | ||
|
|
420be1b943 | ||
|
|
142d280805 | ||
|
|
196b79e4c8 | ||
|
|
2ef1700cfe | ||
|
|
cbbb52d32a | ||
|
|
6bded12ec5 | ||
|
|
5ae56f265e | ||
|
|
705b3e34d1 | ||
|
|
fcb4ccb462 | ||
|
|
e0cd14e904 | ||
|
|
bb6e8838b4 | ||
|
|
5325f8f845 | ||
|
|
113b8bf820 | ||
|
|
7e41168606 | ||
|
|
0af2378d05 | ||
|
|
7f4498c062 | ||
|
|
6e9e988ff0 | ||
|
|
1f03013c98 | ||
|
|
6690e809fb | ||
|
|
b41dd862b6 | ||
|
|
04c269d982 | ||
|
|
f8a86058a1 | ||
|
|
47dda366e3 | ||
|
|
0700d22d43 | ||
|
|
bf633f20c4 | ||
|
|
297681bcff | ||
|
|
68906b54a6 | ||
|
|
0c1d666afd | ||
|
|
18a38e4104 | ||
|
|
ef0041caa6 | ||
|
|
1ce51f6c85 | ||
|
|
c23b2a477e | ||
|
|
0dd77dbaa8 | ||
|
|
29524c2123 | ||
|
|
e2fb5e2673 | ||
|
|
751a0edca7 | ||
|
|
a8e62e086c | ||
|
|
35eb69bebb | ||
|
|
5c7c0699b2 | ||
|
|
460482a6dc | ||
|
|
28db4873a0 | ||
|
|
98de734761 | ||
|
|
b742c8f3c6 | ||
|
|
4cfd274e52 | ||
|
|
4f7bd0436a | ||
|
|
7e31a60000 | ||
|
|
793bc877fc | ||
|
|
5ab6de21dc | ||
|
|
7c5a5bcf65 | ||
|
|
2e203d7713 | ||
|
|
db5e242ad8 | ||
|
|
5be921a342 | ||
|
|
ddd24b20aa | ||
|
|
7c1ee20e7b | ||
|
|
5f0adc0f10 | ||
|
|
244f78ad1a | ||
|
|
9066af8dc7 | ||
|
|
5cfb58c2e6 | ||
|
|
fb8d9e51a6 | ||
|
|
77ce5d8e90 | ||
|
|
8c69f9a738 | ||
|
|
dd87d70876 | ||
|
|
52992f09ee | ||
|
|
e8a56d5fc7 | ||
|
|
a72f02a779 | ||
|
|
f6d2bef285 | ||
|
|
c444a108a5 | ||
|
|
586c0cba25 | ||
|
|
18bc6753db | ||
|
|
b79e6112b1 | ||
|
|
2e4e4328f2 | ||
|
|
03089e92cb | ||
|
|
86939d4890 | ||
|
|
d7d25083dc | ||
|
|
92e8beadc0 |
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
custom: ["https://amsleser.no"]
|
||||
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -24,16 +24,20 @@ A clear description of what you expected to happen.
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Hardware information:**
|
||||
- Country: [e.g. Norway]
|
||||
- Meter: [e.g. Aidon]
|
||||
- Encryption enabled [yes/no]
|
||||
- AMS reader: [e.g. Pow-U, ESP32 etc]
|
||||
- M-bus adapter (if applicable):
|
||||
|
||||
**Relevant firmware information:**
|
||||
- Version: [e.g. 1.5.0]
|
||||
- Version: [e.g. 2.1.0]
|
||||
- MQTT: [yes/no]
|
||||
- MQTT payload type: [e.g. JSON]
|
||||
- HAN GPIO: [e.g. GPIO5]
|
||||
- HAN baud and parity: [e.g. 2400 8E1]
|
||||
- Temperature sensors [e.g. 3xDS18B20]
|
||||
- ENTSO-E API enabled: [yes/no]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,8 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Meter configuration
|
||||
url: https://github.com/gskjold/AmsToMqttBridge/wiki/Known-hardware-configurations
|
||||
url: https://github.com/UtilitechAS/amsreader-firmware/wiki/Known-hardware-configurations
|
||||
about: Please check your meter configuration here first.
|
||||
- name: Frequently asked questions
|
||||
url: https://github.com/gskjold/AmsToMqttBridge/wiki/FAQ
|
||||
url: https://github.com/UtilitechAS/amsreader-firmware/wiki/FAQ
|
||||
about: Please check frequently asked questions first.
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/support.md
vendored
@@ -11,12 +11,17 @@ assignees: ''
|
||||
A clear and concise description of what the problem is.
|
||||
|
||||
**Hardware information:**
|
||||
- Country: [e.g. Norway]
|
||||
- Meter: [e.g. Aidon]
|
||||
- Encryption enabled [yes/no]
|
||||
- AMS reader: [e.g. Pow-U, ESP32 etc]
|
||||
- M-bus adapter (if applicable):
|
||||
|
||||
**Relevant firmware information:**
|
||||
- Version: [e.g. 1.5.0]
|
||||
- Version: [e.g. 2.1.0]
|
||||
- MQTT: [yes/no]
|
||||
- MQTT payload type: [e.g. JSON]
|
||||
- HAN GPIO: [e.g. GPIO5]
|
||||
- HAN baud and parity: [e.g. 2400 8E1]
|
||||
- Temperature sensors [e.g. 3xDS18B20]
|
||||
- ENTSO-E API enabled: [yes/no]
|
||||
|
||||
35
.github/workflows/build.yml
vendored
@@ -8,6 +8,7 @@ on:
|
||||
- scripts/**
|
||||
- web/**
|
||||
- platformio.ini
|
||||
- .github/workflows/**
|
||||
branches:
|
||||
- '*'
|
||||
tags:
|
||||
@@ -21,28 +22,44 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out code from repo
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v4
|
||||
- name: Inject secrets into ini file
|
||||
run: |
|
||||
sed -i 's/NO_AMS2MQTT_PRICE_KEY/AMS2MQTT_PRICE_KEY="${{secrets.AMS2MQTT_PRICE_KEY}}"/g' platformio.ini
|
||||
sed -i 's/NO_AMS2MQTT_PRICE_AUTHENTICATION/AMS2MQTT_PRICE_AUTHENTICATION="${{secrets.AMS2MQTT_PRICE_AUTHENTICATION}}"/g' platformio.ini
|
||||
sed -i 's/NO_ENERGY_SPEEDOMETER_USER/ENERGY_SPEEDOMETER_USER=\\"${{secrets.ENERGY_SPEEDOMETER_USER}}\\"/g' platformio.ini
|
||||
sed -i 's/NO_ENERGY_SPEEDOMETER_PASS/ENERGY_SPEEDOMETER_PASS=\\"${{secrets.ENERGY_SPEEDOMETER_PASS}}\\"/g' platformio.ini
|
||||
- name: Cache Python dependencies
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('platformio.ini') }}
|
||||
- name: Cache PlatformIO dependencies
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.pio/libdeps
|
||||
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v1
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.7
|
||||
python-version: 3.9
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio css_html_js_minify
|
||||
- name: Configure build targets
|
||||
run: echo "[platformio]\ndefault_envs = esp8266, esp32" > platformio-user.ini
|
||||
- name: Set up node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '16.x'
|
||||
- name: Build with node
|
||||
run: |
|
||||
cd lib/SvelteUi/app
|
||||
npm ci
|
||||
npm run build
|
||||
cd -
|
||||
env:
|
||||
CI: true
|
||||
- name: PlatformIO lib install
|
||||
run: pio lib install
|
||||
run: pio pkg install
|
||||
- name: PlatformIO run
|
||||
run: pio run
|
||||
|
||||
147
.github/workflows/release.yml
vendored
@@ -23,6 +23,15 @@ jobs:
|
||||
env:
|
||||
GITHUB_REF: ${{ github.ref }}
|
||||
run: echo "GITHUB_TAG=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
|
||||
|
||||
- name: Inject secrets into ini file
|
||||
run: |
|
||||
sed -i 's/NO_AMS2MQTT_PRICE_KEY/AMS2MQTT_PRICE_KEY="${{secrets.AMS2MQTT_PRICE_KEY}}"/g' platformio.ini
|
||||
sed -i 's/NO_AMS2MQTT_PRICE_AUTHENTICATION/AMS2MQTT_PRICE_AUTHENTICATION="${{secrets.AMS2MQTT_PRICE_AUTHENTICATION}}"/g' platformio.ini
|
||||
sed -i 's/NO_AMS2MQTT_SC_KEY/AMS2MQTT_SC_KEY=\\"${{secrets.AMS2MQTT_SC_KEY}}\\"/g' platformio.ini
|
||||
sed -i 's/NO_ENERGY_SPEEDOMETER_USER/ENERGY_SPEEDOMETER_USER=\\"${{secrets.ENERGY_SPEEDOMETER_USER}}\\"/g' platformio.ini
|
||||
sed -i 's/NO_ENERGY_SPEEDOMETER_PASS/ENERGY_SPEEDOMETER_PASS=\\"${{secrets.ENERGY_SPEEDOMETER_PASS}}\\"/g' platformio.ini
|
||||
|
||||
- name: Cache Python dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
@@ -33,18 +42,31 @@ jobs:
|
||||
with:
|
||||
path: ~/.pio/libdeps
|
||||
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
|
||||
- name: Set up Python 3.7
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.7
|
||||
python-version: 3.9
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio css_html_js_minify
|
||||
|
||||
- name: Set up node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '16.x'
|
||||
- name: Build with node
|
||||
run: |
|
||||
cd lib/SvelteUi/app
|
||||
npm ci
|
||||
npm run build
|
||||
cd -
|
||||
env:
|
||||
CI: false
|
||||
|
||||
- name: PlatformIO lib install
|
||||
run: pio lib install
|
||||
- name: PlatformIO run
|
||||
run: pio run
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1.0.0
|
||||
@@ -55,6 +77,11 @@ jobs:
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Build esp8266 firmware
|
||||
run: pio run -e esp8266
|
||||
- name: Create esp8266 zip file
|
||||
run: /bin/sh scripts/esp8266/mkzip.sh
|
||||
- name: Upload esp8266 binary to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
@@ -64,6 +91,20 @@ jobs:
|
||||
asset_path: .pio/build/esp8266/firmware.bin
|
||||
asset_name: ams2mqtt-esp8266-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp8266 zip to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: esp8266.zip
|
||||
asset_name: ams2mqtt-esp8266-${{ steps.release_tag.outputs.tag }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Build esp32 firmware
|
||||
run: pio run -e esp32
|
||||
- name: Create esp32 zip file
|
||||
run: /bin/sh scripts/esp32/mkzip.sh
|
||||
- name: Upload esp32 binary to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
@@ -73,12 +114,104 @@ jobs:
|
||||
asset_path: .pio/build/esp32/firmware.bin
|
||||
asset_name: ams2mqtt-esp32-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp32 partitions to release
|
||||
- name: Upload esp32 zip to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: .pio/build/esp32/partitions.bin
|
||||
asset_name: ams2mqtt-esp32-partitions-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_path: esp32.zip
|
||||
asset_name: ams2mqtt-esp32-${{ steps.release_tag.outputs.tag }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Build esp32s2 firmware
|
||||
run: pio run -e esp32s2
|
||||
- name: Create esp32s2 zip file
|
||||
run: /bin/sh scripts/esp32s2/mkzip.sh
|
||||
- name: Upload esp32s2 binary to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: .pio/build/esp32s2/firmware.bin
|
||||
asset_name: ams2mqtt-esp32s2-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp32s2 zip to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: esp32s2.zip
|
||||
asset_name: ams2mqtt-esp32s2-${{ steps.release_tag.outputs.tag }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Build esp32s3 firmware
|
||||
run: pio run -e esp32s3
|
||||
- name: Create esp32s3 zip file
|
||||
run: /bin/sh scripts/esp32s3/mkzip.sh
|
||||
- name: Upload esp32s3 binary to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: .pio/build/esp32s3/firmware.bin
|
||||
asset_name: ams2mqtt-esp32s3-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp32s3 zip to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: esp32s3.zip
|
||||
asset_name: ams2mqtt-esp32s3-${{ steps.release_tag.outputs.tag }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Build esp32solo firmware
|
||||
run: pio run -e esp32solo
|
||||
- name: Create esp32solo zip file
|
||||
run: /bin/sh scripts/esp32solo/mkzip.sh
|
||||
- name: Upload esp32solo binary to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: .pio/build/esp32solo/firmware.bin
|
||||
asset_name: ams2mqtt-esp32solo-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp32solo zip to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: esp32solo.zip
|
||||
asset_name: ams2mqtt-esp32solo-${{ steps.release_tag.outputs.tag }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Build esp32c3 firmware
|
||||
run: pio run -e esp32c3
|
||||
- name: Create esp32c3 zip file
|
||||
run: /bin/sh scripts/esp32c3/mkzip.sh
|
||||
- name: Upload esp32c3 binary to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: .pio/build/esp32c3/firmware.bin
|
||||
asset_name: ams2mqtt-esp32c3-${{ steps.release_tag.outputs.tag }}.bin
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload esp32c3 zip to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: esp32c3.zip
|
||||
asset_name: ams2mqtt-esp32c3-${{ steps.release_tag.outputs.tag }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
63
.github/workflows/x-test-esp8266.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
name: Test ESP8266
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
esp8266:
|
||||
runs-on: esp8266
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Get commit hash
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
- name: Check outputs
|
||||
run: echo ${{ steps.vars.outputs.sha_short }}
|
||||
- name: Inject secrets into ini file
|
||||
run: |
|
||||
sed -i 's/NO_AMS2MQTT_PRICE_KEY/AMS2MQTT_PRICE_KEY="${{secrets.AMS2MQTT_PRICE_KEY}}"/g' platformio.ini
|
||||
sed -i 's/NO_AMS2MQTT_PRICE_AUTHENTICATION/AMS2MQTT_PRICE_AUTHENTICATION="${{secrets.AMS2MQTT_PRICE_AUTHENTICATION}}"/g' platformio.ini
|
||||
sed -i 's/NO_ENERGY_SPEEDOMETER_USER/ENERGY_SPEEDOMETER_USER=\\"${{secrets.ENERGY_SPEEDOMETER_USER}}\\"/g' platformio.ini
|
||||
sed -i 's/NO_ENERGY_SPEEDOMETER_PASS/ENERGY_SPEEDOMETER_PASS=\\"${{secrets.ENERGY_SPEEDOMETER_PASS}}\\"/g' platformio.ini
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio css_html_js_minify
|
||||
- name: Set up node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '16.x'
|
||||
- name: Configure PlatformIO environment
|
||||
run: |
|
||||
echo "[platformio]
|
||||
default_envs = dev8266
|
||||
|
||||
[env:dev8266]
|
||||
platform = espressif8266@4.2.0
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
board_build.ldscript = eagle.flash.4m2m.ld
|
||||
build_flags = \${common.build_flags}
|
||||
lib_ldf_mode = off
|
||||
lib_compat_mode = off
|
||||
lib_deps = ESP8266WiFi, ESP8266mDNS, ESP8266WebServer, ESP8266HTTPClient, ESP8266httpUpdate, ESP8266SSDP, \${common.lib_deps}
|
||||
lib_ignore = \${common.lib_ignore}
|
||||
extra_scripts = \${common.extra_scripts}" > platformio-user.ini
|
||||
- name: Build with node
|
||||
run: |
|
||||
cd lib/SvelteUi/app
|
||||
npm ci
|
||||
npm run build
|
||||
cd -
|
||||
env:
|
||||
CI: true
|
||||
- name: PlatformIO lib install
|
||||
run: pio pkg update
|
||||
- name: PlatformIO run
|
||||
run: pio run -t upload --upload-port /dev/ttyUSB0
|
||||
- name: Wait for device to come online
|
||||
run: waitforhost 10.42.0.11 80
|
||||
- name: Confirm version
|
||||
run: curl -s http://10.42.0.11/sysinfo.json|jq -r .version | grep "${{ steps.vars.outputs.sha_short }}" || exit 1
|
||||
- name: Running amsreader-test
|
||||
run: amsreader-test 10.42.0.11
|
||||
8
.gitignore
vendored
@@ -7,10 +7,16 @@
|
||||
.vscode
|
||||
.pio
|
||||
platformio-user.ini
|
||||
/src/version.h
|
||||
/lib/FirmwareVersion/src/generated_version.h
|
||||
/src/web/root
|
||||
/src/AmsToMqttBridge.ino.cpp
|
||||
/test
|
||||
/web/test.html
|
||||
/sdkconfig
|
||||
/.tmp
|
||||
/*.zip
|
||||
node_modules
|
||||
/gui/dist
|
||||
/scripts/*dev
|
||||
/src/KmpCommunicator.cpp
|
||||
/src/KmpCommunicatorDefs.h
|
||||
|
||||
44
LICENSE
Normal file
@@ -0,0 +1,44 @@
|
||||
Fair Source License, version 0.9
|
||||
|
||||
Copyright (C) 2023 Utilitech AS
|
||||
|
||||
Licensor: Utilitech AS
|
||||
|
||||
Software: AMS reader
|
||||
|
||||
Use Limitation: 5 users
|
||||
|
||||
License Grant. Licensor hereby grants to each recipient of the
|
||||
Software ("you") a non-exclusive, non-transferable, royalty-free and
|
||||
fully-paid-up license, under all of the Licensor's copyright and
|
||||
patent rights, to use, copy, distribute, prepare derivative works of,
|
||||
publicly perform and display the Software, subject to the Use
|
||||
Limitation and the conditions set forth below.
|
||||
|
||||
Use Limitation. The license granted above allows use by up to the
|
||||
number of users per entity set forth above (the "Use Limitation"). For
|
||||
determining the number of users, "you" includes all affiliates,
|
||||
meaning legal entities controlling, controlled by, or under common
|
||||
control with you. If you exceed the Use Limitation, your use is
|
||||
subject to payment of Licensor's then-current list price for licenses.
|
||||
|
||||
Conditions. Redistribution in source code or other forms must include
|
||||
a copy of this license document to be provided in a reasonable
|
||||
manner. Any redistribution of the Software is only allowed subject to
|
||||
this license.
|
||||
|
||||
Trademarks. This license does not grant you any right in the
|
||||
trademarks, service marks, brand names or logos of Licensor.
|
||||
|
||||
DISCLAIMER. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OR
|
||||
CONDITION, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. LICENSORS HEREBY DISCLAIM ALL LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE.
|
||||
|
||||
Termination. If you violate the terms of this license, your rights
|
||||
will terminate automatically and will not be reinstated without the
|
||||
prior written consent of Licensor. Any such termination will not
|
||||
affect the right of others who may have received copies of the
|
||||
Software from you.
|
||||
17
README.md
@@ -1,12 +1,12 @@
|
||||
# AMS MQTT Bridge
|
||||
# AMS Reader
|
||||
This code is designed to decode data from electric smart meters installed in many countries in Europe these days. The data is presented in a graphical web interface and can also send the data to a MQTT broker which makes it suitable for home automation project. Originally it was only designed to work with Norwegian meters, but has since been adapter to read any IEC-62056-7-5 or IEC-62056-21 compliant meters.
|
||||
|
||||
Later development have added Energy usage graph for both day and month, as well as future energy price (Prices only available for ESP32). The code can run on any ESP8266 or ESP32 hardware which you can read more about in the [WiKi](https://github.com/gskjold/AmsToMqttBridge/wiki). If you don't have the knowledge to set up a ESP device yourself, have a look at the shop at [amsleser.no](https://amsleser.no/).
|
||||
Later development have added Energy usage graph for both day and month, as well as future energy price. The code can run on any ESP8266 or ESP32 hardware which you can read more about in the [WiKi](https://github.com/UtilitechAS/amsreader-firmware/wiki). If you don't have the knowledge to set up a ESP device yourself, or you would like to support our work, please have a look at our shop at [amsleser.no](https://amsleser.no/).
|
||||
|
||||
|
||||
<img src="webui.png">
|
||||
<img src="images/dashboard.png">
|
||||
|
||||
Go to the [WiKi](https://github.com/gskjold/AmsToMqttBridge/wiki) for information on how to get your own device! And find the latest prebuilt firmware file at the [release section](https://github.com/gskjold/AmsToMqttBridge/releases).
|
||||
Go to the [WiKi](https://github.com/UtilitechAS/amsreader-firmware/wiki) for information on how to get your own device! And find the latest prebuilt firmware file at the [release section](https://github.com/UtilitechAS/amsreader-firmware/releases).
|
||||
|
||||
## Building this project with PlatformIO
|
||||
To build this project, you need [PlatformIO](https://platformio.org/) installed.
|
||||
@@ -18,3 +18,12 @@ It is recommended to use Visual Studio Code with the PlatformIO plugin for devel
|
||||
[PlatformIO vscode plugin](https://platformio.org/install/ide?install=vscode)
|
||||
|
||||
For development purposes, copy the ```platformio-user.ini-example``` to ```platformio-user.ini``` and customize to your preference. The code will adapt to the platform and board set in your profile.
|
||||
|
||||
## Licensing
|
||||
Initially, this project began as a hobby, consuming countless hours of our spare time. However, the time required to support this project has expanded beyond the scope of a hobby. As a result, we established ‘Utilitech’, a company dedicated to maintaining the software and hardware for this project as part of our regular work.
|
||||
|
||||
To ensure the sustainability of our venture, we have opted to license our software under the [Fair Source License] (https://fair.io). This approach allows the software to remain free for personal use, while also ensuring full transparency of our code’s inner workings. It also prevents competitors from exploiting our work without contributing to the maintenance of the code or providing technical support to end users.
|
||||
|
||||
For more information, please refer to our [LICENSE](/LICENSE) file.
|
||||
|
||||
If your usage falls outside the scope of this license and you require a separate license, please contact us at [post@utilitech.no](mailto:post@utilitech.no) for further details.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
1.1.2.8.0.255 - Active- Energy
|
||||
1.1.3.8.0.255 - Reactive+ Energy
|
||||
1.1.4.8.0.255 - Reactive- Energy
|
||||
1.1.0.0.1.255 - Electricity ID?
|
||||
1.1.0.0.1.255 - Meter number 1
|
||||
1.1.1.7.0.255 - Active+ Instantaneous value
|
||||
1.1.2.7.0.255 - Active- Instantaneous value
|
||||
1.1.3.7.0.255 - Reactive+ Instantaneous value
|
||||
|
||||
BIN
doc/Germany/Anleitung_M-Bus_Protokoll_V1.0.pdf
Normal file
BIN
doc/Kamstrup OMNIA® e-meter.pdf
Normal file
BIN
doc/M-Bus_DOC48.PDF
Normal file
BIN
doc/Switzerland/RWB_SmartMeter_Bedienungsanleitung.pdf
Normal file
BIN
doc/omnipower.technical.description.pdf
Normal file
51
frames/Kamstrup-1p.raw
Normal file
@@ -0,0 +1,51 @@
|
||||
7E A0 BA 2B 21 13 ED AA E6 E7 00 0F 00 00 00 00
|
||||
0C 07 E6 02 05 06 0D 00 0A FF 80 00 00
|
||||
02 19
|
||||
0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 32 37 31 35 33 33 32 30 37
|
||||
09 06 01 01 60 01 01 FF 0A 12 36 38 36 31 31 31 31 42 4E 32 34 32 31 30 31 30 34 30
|
||||
09 06 01 01 01 07 00 FF 06 00 00 02 68
|
||||
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 03 07 00 FF 06 00 00 00 53
|
||||
09 06 01 01 04 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 1F 07 00 FF 06 00 00 01 22
|
||||
00 00 00 00
|
||||
09 06 01 01 20 07 00 FF 12 00 E2
|
||||
00 00 00 00
|
||||
05 D8 7E
|
||||
|
||||
7E A0 BA 2B 21 13 ED AA E6 E7 00 0F 00 00 00 00
|
||||
0C 07 E6 02 05 06 0D 00 14 FF 80 00 00
|
||||
02 19
|
||||
0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 32 37 31 35 33 33 32 30 37
|
||||
09 06 01 01 60 01 01 FF 0A 12 36 38 36 31 31 31 31 42 4E 32 34 32 31 30 31 30 34 30
|
||||
09 06 01 01 01 07 00 FF 06 00 00 02 68
|
||||
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 03 07 00 FF 06 00 00 00 53
|
||||
09 06 01 01 04 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 1F 07 00 FF 06 00 00 01 23
|
||||
00 00 00 00
|
||||
09 06 01 01 20 07 00 FF 12 00 E1
|
||||
00 00 00 00
|
||||
8E 5E 7E
|
||||
|
||||
7E A1 04 2B 21 13 77 6E E6 E7 00 0F 00 00 00 00
|
||||
0C 07 E6 02 05 06 0D 00 19 FF 80 00 00
|
||||
02 23 0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 32 37 31 35 33 33 32 30 37
|
||||
09 06 01 01 60 01 01 FF 0A 12 36 38 36 31 31 31 31 42 4E 32 34 32 31 30 31 30 34 30
|
||||
09 06 01 01 01 07 00 FF 06 00 00 02 6B
|
||||
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 03 07 00 FF 06 00 00 00 54
|
||||
09 06 01 01 04 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 1F 07 00 FF 06 00 00 01 25
|
||||
00 00 00 00
|
||||
09 06 01 01 20 07 00 FF 12 00 E1
|
||||
00 00 00 00
|
||||
09 06 00 01 01 00 00 FF 09 0C 07 E6 02 05 06 0D 00 19 FF 80 00 00
|
||||
09 06 01 01 01 08 00 FF 06 00 12 CF 93
|
||||
09 06 01 01 02 08 00 FF 06 00 00 00 00
|
||||
09 06 01 01 03 08 00 FF 06 00 00 8C CE
|
||||
09 06 01 01 04 08 00 FF 06 00 05 E5 04
|
||||
7F E9 7E
|
||||
23
frames/Kamstrup-Sweden.raw
Normal file
@@ -0,0 +1,23 @@
|
||||
7E A1 2C 2B 21 13 FC 04 E6 E7 00 0F 00 00 00 00
|
||||
0C 07 E6 02 12 05 16 00 23 FF 80 00 00
|
||||
02 23
|
||||
0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 33 33 31 33 32 33 35 32 36
|
||||
09 06 01 01 60 01 01 FF 0A 12 36 38 34 31 31 33 31 42 4E 32 34 35 31 30 31 30 39 32
|
||||
09 06 01 01 01 07 00 FF 06 00 00 08 DD
|
||||
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 03 07 00 FF 06 00 00 00 00
|
||||
09 06 01 01 04 07 00 FF 06 00 00 01 90
|
||||
09 06 01 01 1F 07 00 FF 06 00 00 01 1F
|
||||
09 06 01 01 33 07 00 FF 06 00 00 02 57
|
||||
09 06 01 01 47 07 00 FF 06 00 00 00 6A
|
||||
09 06 01 01 20 07 00 FF 12 00 F1
|
||||
09 06 01 01 34 07 00 FF 12 00 F0
|
||||
09 06 01 01 48 07 00 FF 12 00 F3
|
||||
09 06 00 01 01 00 00 FF 09 0C 07 E6 02 12 05 16 00 23 FF 80 00 00
|
||||
09 06 01 01 01 08 00 FF 06 01 E8 7F 4E
|
||||
09 06 01 01 02 08 00 FF 06 00 00 00 00
|
||||
09 06 01 01 03 08 00 FF 06 00 58 71 8B
|
||||
09 06 01 01 04 08 00 FF 06 00 10 60 23
|
||||
B8 1C
|
||||
7E
|
||||
@@ -6,7 +6,7 @@ DB // Encrypted
|
||||
08 4B 41 4D 45 01 AC 4D 6E // System title
|
||||
82 // Prefix for 2-byte length
|
||||
01 D0 // Length 464
|
||||
30 // Security tag 0011 0000, 0=Compression off, 0=Unicast, 1=Encryption, 0=Authentication, 0000= Security Suite ID
|
||||
30 // Security tag 0011 0000, 0=Compression off, 0=Unicast, 1=Encryption, 1=Authentication, 0000= Security Suite ID
|
||||
00 00 A3 2F // Frame counter
|
||||
|
||||
// Decrypted frame below
|
||||
|
||||
@@ -42,4 +42,4 @@ DB
|
||||
09 06 01 00 47 07 00 FF 12 00 54 02 02 0F FE 16 21
|
||||
09 06 01 00 0D 07 00 FF 10 03 CF 02 02 0F FD 16 FF // Power factor
|
||||
09 0C 31 37 38 32 31 30 30 31 35 31 36 35 // Meter ID
|
||||
01 67
|
||||
01 67
|
||||
|
||||
79
frames/lng.raw
Normal file
@@ -0,0 +1,79 @@
|
||||
7E // Flag
|
||||
A08B
|
||||
CEFF03
|
||||
13
|
||||
EEE1
|
||||
E6E700
|
||||
E0 // GBT (Green book 9.4.6.13)
|
||||
40 // Block control 0100 0000, last block=no, streaming=yes, remainig=window
|
||||
0001 // Block sequence
|
||||
0000 // Block sequence ack
|
||||
77 // How many bytes in this block
|
||||
|
||||
0F 00000DB7 // APDU tag, Invoke ID and priority
|
||||
|
||||
0C07E604020607220FFF800000 // Date and time
|
||||
0205 // Structure with 5 items
|
||||
0105 // Array with 5 items
|
||||
020412002809060008190900FF0F02120000 // Structure with 4 items, uint16, OBIS, int8, uint16 (0-8:25.9.0;2)
|
||||
020412002809060008190900FF0F01120000 // Structure with 4 items, uint16, OBIS, int8, uint16 (0-8:25.9.0;1)
|
||||
020412000109060000600101FF0F02120000 // Structure with 4 items, uint16, OBIS, int8, uint16 (96.1.1 - Meter model)
|
||||
020412000309060100010700FF0F02120000 // Structure with 4 items, uint16, OBIS, int8, uint16 (1.7.0 Active import)
|
||||
020412000309060100020700FF0F02120000 // Structure with 4 items, uint16, OBIS, int8, uint16 (2.7.0 Active export)
|
||||
09060008190900 // OBIS 0-8:25.9.0 Object list push settings consumer information 1
|
||||
ABA6
|
||||
7E
|
||||
|
||||
|
||||
|
||||
7E
|
||||
A024
|
||||
CEFF03
|
||||
13
|
||||
D661
|
||||
E0 // GBT
|
||||
C0 // Block control 0100 0000, last block=yes, streaming=yes, remainig=window
|
||||
0002 // Block sequence
|
||||
0000 // Block sequence ack
|
||||
13 // How many bytes in this block
|
||||
|
||||
FF // Last byte of OBIS in previous block
|
||||
0906363031313039 // Device ID
|
||||
0600000028 // Accumulated import
|
||||
0600000000 // Accumulated export
|
||||
8BA4
|
||||
7E
|
||||
|
||||
|
||||
|
||||
|
||||
7E A1 23 CE FF 03 13 21 55 E6 E7 00
|
||||
|
||||
0F 00 00 08 E2
|
||||
0C 07 E5 07 13 01 0C 1A 0A FF 80 00 00
|
||||
|
||||
02 0B // 11
|
||||
01 0B // 11
|
||||
02 04 12 00 28 09 06 00 08 19 09 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 28 09 06 00 08 19 09 00 FF 0F 01 12 00 00
|
||||
02 04 12 00 01 09 06 00 00 60 01 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 00 01 07 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 00 02 07 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 01 01 08 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 01 02 08 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 01 05 08 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 01 06 08 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 01 07 08 00 FF 0F 02 12 00 00
|
||||
02 04 12 00 03 09 06 01 01 08 08 00 FF 0F 02 12 00 00
|
||||
09 06 00 08 19 09 00 FF
|
||||
09 08 34 33 30 39 34 33 35 31
|
||||
06 00 00 00 0B
|
||||
06 00 00 00 00
|
||||
06 00 00 00 10
|
||||
06 00 00 00 04
|
||||
06 00 00 00 00
|
||||
06 00 00 00 08
|
||||
06 00 00 00 00
|
||||
06 00 00 00 01
|
||||
7C 8B
|
||||
7E
|
||||
33
frames/lng2.raw
Normal file
@@ -0,0 +1,33 @@
|
||||
7E
|
||||
A0 76 CE FF 03 13 3C 02 E6 E7 00
|
||||
|
||||
DB
|
||||
08 4C 47 5A 67 72 A9 A1 11
|
||||
5E 30 00 21 80 F7 FE B8 07 C6
|
||||
72 B1 90 AE AC 15 D0 AD 95 7B AC 13 7E 67 D8 A2
|
||||
F0 43 51 3C 63 B6 A1 89 10 AE 9A 7E 55 4A 12 49
|
||||
B9 6D EB A5 7B 57 03 69 9A BF 16 5E AD 2A 54 41
|
||||
65 5E 79 C6 95 71 92 46 A2 3F 5B 63 0D 53 96 7D
|
||||
42 52 1F A3 80 1C 00 E8 E3
|
||||
A4 B3 9B 86 CB E5 2D 2C CA B0 E2 B7
|
||||
AE 4D
|
||||
7E
|
||||
|
||||
|
||||
0f00057e41 // UI Frame header
|
||||
0c07e60c0c010c232dff800000 // Date & time
|
||||
020e // Structure with 14 items
|
||||
1200ec // U1 = 236 V
|
||||
1200ec // U2 = 236 V
|
||||
1200ec // U3 = 236 V
|
||||
120000 // I1 = 0.00 A
|
||||
12002e // I2 = 0.46 A
|
||||
12001a // I3 = 0.26 A
|
||||
060000007d // Active import = 125 W
|
||||
0600000000 // Active export = 0 W
|
||||
0601a96ebd // Accumulated import = 27881.149 kWh
|
||||
0600001dc3 // Accumulated export = 7.619 kWh
|
||||
120190 // 400 ?
|
||||
120003 // 3 ?
|
||||
120120 // 288 ?
|
||||
09083330313337313831 // Meter ID = 30137181
|
||||
34
frames/slovenia-iskra.raw
Normal file
@@ -0,0 +1,34 @@
|
||||
02 12
|
||||
09 10 49 53 4B 31 30 33 30 37 38 39 33 37 35 36 30 36 // str: ISK1030789375606 (device name)
|
||||
09 08 31 36 38 32 30 30 30 35 // str: 16820005 (device id)
|
||||
06 00 00 05 71 // active import
|
||||
06 00 00 00 00 // active export
|
||||
06 00 00 00 00 // reactive import
|
||||
06 00 00 02 E2 // reactive export
|
||||
12 09 4B // U1
|
||||
12 09 4B // U2
|
||||
12 08 F8 // U3
|
||||
12 00 67 // I1
|
||||
12 00 7D // I2
|
||||
12 02 55 // I3
|
||||
06 00 00 00 10 // L1 a+
|
||||
06 00 00 00 33 // L2 a+
|
||||
06 00 00 05 2D // L3 a+
|
||||
06 00 00 00 00 // L1 a-
|
||||
06 00 00 00 00 // L2 a-
|
||||
06 00 00 00 00 // L3 a-
|
||||
|
||||
|
||||
02 0C
|
||||
09 10 49 53 4B 31 30 33 30 37 38 39 33 37 35 36 30 36
|
||||
09 08 31 36 38 32 30 30 30 36
|
||||
16 01 // Disconnect control
|
||||
09 02 00 01 // Currently active energy tariff
|
||||
06 00 00 CE 65 // 1.8.0 a+
|
||||
06 00 00 35 19 // 1.8.1
|
||||
06 00 00 99 4C // 1.8.2
|
||||
06 00 02 B7 07 // 2.8.0 a-
|
||||
06 00 01 33 17 // 2.8.1
|
||||
06 00 01 83 F0 // 2.8.2
|
||||
06 00 01 A5 6A // q+
|
||||
06 00 00 A8 F5 // q-
|
||||
@@ -1 +1 @@
|
||||
[See Hardware page in Wiki](https://github.com/gskjold/AmsToMqttBridge/wiki)
|
||||
[See Hardware page in Wiki](https://github.com/UtilitechAS/amsreader-firmware/wiki)
|
||||
|
||||
76
hardware/v1/kicad/HAN_ESP_TSS721.kicad_prl
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"board": {
|
||||
"active_layer": 0,
|
||||
"active_layer_preset": "",
|
||||
"auto_track_width": true,
|
||||
"hidden_nets": [],
|
||||
"high_contrast_mode": 0,
|
||||
"net_color_mode": 1,
|
||||
"opacity": {
|
||||
"pads": 1.0,
|
||||
"tracks": 1.0,
|
||||
"vias": 1.0,
|
||||
"zones": 0.6
|
||||
},
|
||||
"ratsnest_display_mode": 0,
|
||||
"selection_filter": {
|
||||
"dimensions": true,
|
||||
"footprints": true,
|
||||
"graphics": true,
|
||||
"keepouts": true,
|
||||
"lockedItems": true,
|
||||
"otherItems": true,
|
||||
"pads": true,
|
||||
"text": true,
|
||||
"tracks": true,
|
||||
"vias": true,
|
||||
"zones": true
|
||||
},
|
||||
"visible_items": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36
|
||||
],
|
||||
"visible_layers": "fffffff_ffffffff",
|
||||
"zone_display_mode": 0
|
||||
},
|
||||
"meta": {
|
||||
"filename": "HAN_ESP_TSS721.kicad_prl",
|
||||
"version": 3
|
||||
},
|
||||
"project": {
|
||||
"files": []
|
||||
}
|
||||
}
|
||||
440
hardware/v1/kicad/HAN_ESP_TSS721.kicad_pro
Normal file
@@ -0,0 +1,440 @@
|
||||
{
|
||||
"board": {
|
||||
"design_settings": {
|
||||
"defaults": {
|
||||
"board_outline_line_width": 0.15,
|
||||
"copper_line_width": 0.19999999999999998,
|
||||
"copper_text_italic": false,
|
||||
"copper_text_size_h": 1.5,
|
||||
"copper_text_size_v": 1.5,
|
||||
"copper_text_thickness": 0.3,
|
||||
"copper_text_upright": false,
|
||||
"courtyard_line_width": 0.049999999999999996,
|
||||
"dimension_precision": 4,
|
||||
"dimension_units": 3,
|
||||
"dimensions": {
|
||||
"arrow_length": 1270000,
|
||||
"extension_offset": 500000,
|
||||
"keep_text_aligned": true,
|
||||
"suppress_zeroes": false,
|
||||
"text_position": 0,
|
||||
"units_format": 1
|
||||
},
|
||||
"fab_line_width": 0.09999999999999999,
|
||||
"fab_text_italic": false,
|
||||
"fab_text_size_h": 1.0,
|
||||
"fab_text_size_v": 1.0,
|
||||
"fab_text_thickness": 0.15,
|
||||
"fab_text_upright": false,
|
||||
"other_line_width": 0.09999999999999999,
|
||||
"other_text_italic": false,
|
||||
"other_text_size_h": 1.0,
|
||||
"other_text_size_v": 1.0,
|
||||
"other_text_thickness": 0.15,
|
||||
"other_text_upright": false,
|
||||
"pads": {
|
||||
"drill": 0.762,
|
||||
"height": 1.524,
|
||||
"width": 1.524
|
||||
},
|
||||
"silk_line_width": 0.15,
|
||||
"silk_text_italic": false,
|
||||
"silk_text_size_h": 1.0,
|
||||
"silk_text_size_v": 1.0,
|
||||
"silk_text_thickness": 0.15,
|
||||
"silk_text_upright": false,
|
||||
"zones": {
|
||||
"45_degree_only": true,
|
||||
"min_clearance": 0.508
|
||||
}
|
||||
},
|
||||
"diff_pair_dimensions": [],
|
||||
"drc_exclusions": [],
|
||||
"meta": {
|
||||
"filename": "board_design_settings.json",
|
||||
"version": 2
|
||||
},
|
||||
"rule_severities": {
|
||||
"annular_width": "error",
|
||||
"clearance": "error",
|
||||
"copper_edge_clearance": "error",
|
||||
"courtyards_overlap": "error",
|
||||
"diff_pair_gap_out_of_range": "error",
|
||||
"diff_pair_uncoupled_length_too_long": "error",
|
||||
"drill_out_of_range": "error",
|
||||
"duplicate_footprints": "warning",
|
||||
"extra_footprint": "warning",
|
||||
"footprint_type_mismatch": "error",
|
||||
"hole_clearance": "error",
|
||||
"hole_near_hole": "error",
|
||||
"invalid_outline": "error",
|
||||
"item_on_disabled_layer": "error",
|
||||
"items_not_allowed": "error",
|
||||
"length_out_of_range": "error",
|
||||
"malformed_courtyard": "error",
|
||||
"microvia_drill_out_of_range": "error",
|
||||
"missing_courtyard": "ignore",
|
||||
"missing_footprint": "warning",
|
||||
"net_conflict": "warning",
|
||||
"npth_inside_courtyard": "ignore",
|
||||
"padstack": "error",
|
||||
"pth_inside_courtyard": "ignore",
|
||||
"shorting_items": "error",
|
||||
"silk_over_copper": "warning",
|
||||
"silk_overlap": "warning",
|
||||
"skew_out_of_range": "error",
|
||||
"through_hole_pad_without_hole": "error",
|
||||
"too_many_vias": "error",
|
||||
"track_dangling": "warning",
|
||||
"track_width": "error",
|
||||
"tracks_crossing": "error",
|
||||
"unconnected_items": "error",
|
||||
"unresolved_variable": "error",
|
||||
"via_dangling": "warning",
|
||||
"zone_has_empty_net": "error",
|
||||
"zones_intersect": "error"
|
||||
},
|
||||
"rules": {
|
||||
"allow_blind_buried_vias": false,
|
||||
"allow_microvias": false,
|
||||
"max_error": 0.005,
|
||||
"min_clearance": 0.0,
|
||||
"min_copper_edge_clearance": 0.075,
|
||||
"min_hole_clearance": 0.25,
|
||||
"min_hole_to_hole": 0.25,
|
||||
"min_microvia_diameter": 0.19999999999999998,
|
||||
"min_microvia_drill": 0.09999999999999999,
|
||||
"min_silk_clearance": 0.0,
|
||||
"min_through_hole_diameter": 0.3,
|
||||
"min_track_width": 0.19999999999999998,
|
||||
"min_via_annular_width": 0.049999999999999996,
|
||||
"min_via_diameter": 0.39999999999999997,
|
||||
"use_height_for_length_calcs": true
|
||||
},
|
||||
"track_widths": [
|
||||
0.0,
|
||||
0.2,
|
||||
0.4,
|
||||
0.6,
|
||||
1.0
|
||||
],
|
||||
"via_dimensions": [],
|
||||
"zones_allow_external_fillets": false,
|
||||
"zones_use_no_outline": true
|
||||
},
|
||||
"layer_presets": []
|
||||
},
|
||||
"boards": [],
|
||||
"cvpcb": {
|
||||
"equivalence_files": []
|
||||
},
|
||||
"erc": {
|
||||
"erc_exclusions": [],
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"pin_map": [
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
]
|
||||
],
|
||||
"rule_severities": {
|
||||
"bus_definition_conflict": "error",
|
||||
"bus_entry_needed": "error",
|
||||
"bus_label_syntax": "error",
|
||||
"bus_to_bus_conflict": "error",
|
||||
"bus_to_net_conflict": "error",
|
||||
"different_unit_footprint": "error",
|
||||
"different_unit_net": "error",
|
||||
"duplicate_reference": "error",
|
||||
"duplicate_sheet_names": "error",
|
||||
"extra_units": "error",
|
||||
"global_label_dangling": "warning",
|
||||
"hier_label_mismatch": "error",
|
||||
"label_dangling": "error",
|
||||
"lib_symbol_issues": "warning",
|
||||
"multiple_net_names": "warning",
|
||||
"net_not_bus_member": "warning",
|
||||
"no_connect_connected": "warning",
|
||||
"no_connect_dangling": "warning",
|
||||
"pin_not_connected": "error",
|
||||
"pin_not_driven": "error",
|
||||
"pin_to_pin": "warning",
|
||||
"power_pin_not_driven": "error",
|
||||
"similar_labels": "warning",
|
||||
"unannotated": "error",
|
||||
"unit_value_mismatch": "error",
|
||||
"unresolved_variable": "error",
|
||||
"wire_dangling": "error"
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"pinned_footprint_libs": [],
|
||||
"pinned_symbol_libs": []
|
||||
},
|
||||
"meta": {
|
||||
"filename": "HAN_ESP_TSS721.kicad_pro",
|
||||
"version": 1
|
||||
},
|
||||
"net_settings": {
|
||||
"classes": [
|
||||
{
|
||||
"bus_width": 12.0,
|
||||
"clearance": 0.2,
|
||||
"diff_pair_gap": 0.25,
|
||||
"diff_pair_via_gap": 0.25,
|
||||
"diff_pair_width": 0.2,
|
||||
"line_style": 0,
|
||||
"microvia_diameter": 0.3,
|
||||
"microvia_drill": 0.1,
|
||||
"name": "Default",
|
||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||
"track_width": 0.25,
|
||||
"via_diameter": 0.6,
|
||||
"via_drill": 0.4,
|
||||
"wire_width": 6.0
|
||||
},
|
||||
{
|
||||
"bus_width": 12.0,
|
||||
"clearance": 0.5,
|
||||
"diff_pair_gap": 0.25,
|
||||
"diff_pair_via_gap": 0.25,
|
||||
"diff_pair_width": 0.2,
|
||||
"line_style": 0,
|
||||
"microvia_diameter": 0.5,
|
||||
"microvia_drill": 0.2,
|
||||
"name": "PWR",
|
||||
"nets": [
|
||||
"+3V3"
|
||||
],
|
||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||
"track_width": 0.5,
|
||||
"via_diameter": 0.8,
|
||||
"via_drill": 0.6,
|
||||
"wire_width": 6.0
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"version": 2
|
||||
},
|
||||
"net_colors": null
|
||||
},
|
||||
"pcbnew": {
|
||||
"last_paths": {
|
||||
"gencad": "",
|
||||
"idf": "",
|
||||
"netlist": "",
|
||||
"specctra_dsn": "",
|
||||
"step": "",
|
||||
"vrml": ""
|
||||
},
|
||||
"page_layout_descr_file": ""
|
||||
},
|
||||
"schematic": {
|
||||
"annotate_start_num": 0,
|
||||
"drawing": {
|
||||
"default_line_thickness": 6.0,
|
||||
"default_text_size": 50.0,
|
||||
"field_names": [],
|
||||
"intersheets_ref_own_page": false,
|
||||
"intersheets_ref_prefix": "",
|
||||
"intersheets_ref_short": false,
|
||||
"intersheets_ref_show": false,
|
||||
"intersheets_ref_suffix": "",
|
||||
"junction_size_choice": 3,
|
||||
"label_size_ratio": 0.25,
|
||||
"pin_symbol_size": 0.0,
|
||||
"text_offset_ratio": 0.08
|
||||
},
|
||||
"legacy_lib_dir": "",
|
||||
"legacy_lib_list": [],
|
||||
"meta": {
|
||||
"version": 1
|
||||
},
|
||||
"net_format_name": "",
|
||||
"ngspice": {
|
||||
"fix_include_paths": true,
|
||||
"fix_passive_vals": false,
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"model_mode": 0,
|
||||
"workbook_filename": ""
|
||||
},
|
||||
"page_layout_descr_file": "",
|
||||
"plot_directory": "",
|
||||
"spice_adjust_passive_values": false,
|
||||
"spice_external_command": "spice \"%I\"",
|
||||
"subpart_first_id": 65,
|
||||
"subpart_id_separator": 0
|
||||
},
|
||||
"sheets": [],
|
||||
"text_variables": {}
|
||||
}
|
||||
1
hardware/v1/kicad/fp-info-cache
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
34
hardware/wemos_mbus_shield/README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
## Wemos shield
|
||||
|
||||
Fits D1 mini and S2 mini.
|
||||
|
||||
<img src="img1.jpg"/>
|
||||
<img src="img2.jpg"/>
|
||||
|
||||
**WARNING** Not properly tested
|
||||
|
||||
**Resistors**
|
||||
- R1: 470 (for U1)
|
||||
- R2: 220 (for U1)
|
||||
- R3: 82k (for U1)
|
||||
- R4: 220 (for U1)
|
||||
- R5: 100k (for U1)
|
||||
- R6: 10k (for AP button)
|
||||
- R7: 4.7k (for DS18B20)
|
||||
- R8-R10: 1k (for RGB LED)
|
||||
|
||||
**Capacitors**
|
||||
- C1: 100n (for U1)
|
||||
- C2: 1u (for U1)
|
||||
- C3: 100n (for U1)
|
||||
|
||||
**Other components**
|
||||
- U1: TSS521 or TSS721
|
||||
- U2: DS18B20 (Digital temperature sensor)
|
||||
- D1: RGB LED
|
||||
- J1: RJ45
|
||||
- SW1: AP button (to D3 GPIO0)
|
||||
|
||||
**Jumper**
|
||||
- JP1 & JP4: Jump these to receive power (5V) via RJ45 on pin 7 (GND) and 8 (+5)
|
||||
- JP2 & JP3: Jump these to attach DS18B20 sensors via RJ45 on pin 4 (Data) and pin 5 (GND)
|
||||
BIN
hardware/wemos_mbus_shield/img1.jpg
Normal file
|
After Width: | Height: | Size: 237 KiB |
BIN
hardware/wemos_mbus_shield/img2.jpg
Normal file
|
After Width: | Height: | Size: 296 KiB |
3
hardware/wemos_mbus_shield/kicad/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
gerber
|
||||
rescue-backup
|
||||
*-bak
|
||||
326
hardware/wemos_mbus_shield/kicad/d1_mini_shield-cache.lib
Normal file
@@ -0,0 +1,326 @@
|
||||
EESchema-LIBRARY Version 2.4
|
||||
#encoding utf-8
|
||||
#
|
||||
# Connector_RJ45
|
||||
#
|
||||
DEF Connector_RJ45 J 0 40 Y Y 1 F N
|
||||
F0 "J" -200 550 50 H V R CNN
|
||||
F1 "Connector_RJ45" 100 550 50 H V L CNN
|
||||
F2 "" 0 25 50 V I C CNN
|
||||
F3 "" 0 25 50 V I C CNN
|
||||
ALIAS RJ31 RJ32 RJ33 RJ34 RJ35 RJ41 RJ45 RJ49 RJ61
|
||||
$FPLIST
|
||||
8P8C*
|
||||
RJ31*
|
||||
RJ32*
|
||||
RJ33*
|
||||
RJ34*
|
||||
RJ35*
|
||||
RJ41*
|
||||
RJ45*
|
||||
RJ49*
|
||||
RJ61*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S 300 500 -300 -400 0 1 10 f
|
||||
P 2 0 1 0 -200 175 -250 175 N
|
||||
P 2 0 1 0 -200 225 -250 225 N
|
||||
P 3 0 1 0 -250 -125 -200 -125 -200 -125 N
|
||||
P 3 0 1 0 -250 -75 -200 -75 -200 -75 N
|
||||
P 3 0 1 0 -250 -25 -200 -25 -200 -25 N
|
||||
P 3 0 1 0 -250 25 -200 25 -200 25 N
|
||||
P 3 0 1 0 -250 75 -200 75 -200 75 N
|
||||
P 3 0 1 0 -200 125 -250 125 -250 125 N
|
||||
P 14 0 1 0 -250 -175 -250 275 150 275 150 175 200 175 200 125 250 125 250 -25 200 -25 200 -75 150 -75 150 -175 -250 -175 -250 -175 N
|
||||
X ~ 1 400 -300 100 L 50 50 1 1 P
|
||||
X ~ 2 400 -200 100 L 50 50 1 1 P
|
||||
X ~ 3 400 -100 100 L 50 50 1 1 P
|
||||
X ~ 4 400 0 100 L 50 50 1 1 P
|
||||
X ~ 5 400 100 100 L 50 50 1 1 P
|
||||
X ~ 6 400 200 100 L 50 50 1 1 P
|
||||
X ~ 7 400 300 100 L 50 50 1 1 P
|
||||
X ~ 8 400 400 100 L 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_C
|
||||
#
|
||||
DEF Device_C C 0 10 N Y 1 F N
|
||||
F0 "C" 25 100 50 H V L CNN
|
||||
F1 "Device_C" 25 -100 50 H V L CNN
|
||||
F2 "" 38 -150 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
C_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 20 -80 -30 80 -30 N
|
||||
P 2 0 1 20 -80 30 80 30 N
|
||||
X ~ 1 0 150 110 D 50 50 1 1 P
|
||||
X ~ 2 0 -150 110 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_Jumper
|
||||
#
|
||||
DEF Device_Jumper JP 0 30 Y N 1 F N
|
||||
F0 "JP" 0 150 50 H V C CNN
|
||||
F1 "Device_Jumper" 0 -80 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
SolderJumper*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
A 0 -26 125 1426 373 0 1 0 N -98 50 99 50
|
||||
C -100 0 35 0 1 0 N
|
||||
C 100 0 35 0 1 0 N
|
||||
X 1 1 -300 0 165 R 50 50 0 1 P
|
||||
X 2 2 300 0 165 L 50 50 0 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_LED_RGB
|
||||
#
|
||||
DEF Device_LED_RGB D 0 0 Y N 1 F N
|
||||
F0 "D" 0 370 50 H V C CNN
|
||||
F1 "Device_LED_RGB" 0 -350 50 H V C CNN
|
||||
F2 "" 0 -50 50 H I C CNN
|
||||
F3 "" 0 -50 50 H I C CNN
|
||||
$FPLIST
|
||||
LED*
|
||||
LED_SMD:*
|
||||
LED_THT:*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
T 0 -75 -250 50 0 0 0 B Normal 0 C C
|
||||
T 0 -75 -50 50 0 0 0 G Normal 0 C C
|
||||
T 0 -75 150 50 0 0 0 R Normal 0 C C
|
||||
S 50 -50 50 50 0 1 0 N
|
||||
S 50 50 50 50 0 1 0 N
|
||||
S 50 150 50 250 0 1 0 N
|
||||
S 50 250 50 250 0 1 0 N
|
||||
S 110 330 -110 -300 0 1 10 f
|
||||
P 2 0 1 0 -50 -200 -100 -200 N
|
||||
P 2 0 1 0 -50 -200 50 -200 N
|
||||
P 2 0 1 0 -50 -150 -50 -250 N
|
||||
P 2 0 1 8 -50 -150 -50 -250 N
|
||||
P 2 0 1 0 -50 0 -100 0 N
|
||||
P 2 0 1 8 -50 50 -50 -50 N
|
||||
P 2 0 1 0 -50 200 -100 200 N
|
||||
P 2 0 1 0 -50 200 50 200 N
|
||||
P 2 0 1 8 -50 250 -50 150 N
|
||||
P 2 0 1 0 50 -200 100 -200 N
|
||||
P 2 0 1 0 50 0 -50 0 N
|
||||
P 2 0 1 0 50 0 100 0 N
|
||||
P 2 0 1 0 50 200 100 200 N
|
||||
P 3 0 1 0 -50 50 -50 -50 -50 -50 N
|
||||
P 3 0 1 0 -50 250 -50 150 -50 150 N
|
||||
P 4 0 1 8 50 -150 50 -250 -50 -200 50 -150 N
|
||||
P 4 0 1 8 50 50 50 -50 -50 0 50 50 N
|
||||
P 4 0 1 8 50 250 50 150 -50 200 50 250 N
|
||||
P 5 0 1 0 -40 -150 20 -90 -10 -90 20 -90 20 -120 N
|
||||
P 5 0 1 0 -40 50 20 110 -10 110 20 110 20 80 N
|
||||
P 5 0 1 0 -40 250 20 310 -10 310 20 310 20 280 N
|
||||
P 5 0 1 0 0 -150 60 -90 30 -90 60 -90 60 -120 N
|
||||
P 5 0 1 0 0 50 60 110 30 110 60 110 60 80 N
|
||||
P 5 0 1 0 0 250 60 310 30 310 60 310 60 280 N
|
||||
X RK 1 -200 200 100 R 50 50 1 1 P
|
||||
X GK 2 -200 0 100 R 50 50 1 1 P
|
||||
X BK 3 -200 -200 100 R 50 50 1 1 P
|
||||
X BA 4 200 -200 100 L 50 50 1 1 P
|
||||
X GA 5 200 0 100 L 50 50 1 1 P
|
||||
X RA 6 200 200 100 L 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_R
|
||||
#
|
||||
DEF Device_R R 0 0 N Y 1 F N
|
||||
F0 "R" 80 0 50 V V C CNN
|
||||
F1 "Device_R" 0 0 50 V V C CNN
|
||||
F2 "" -70 0 50 V I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
R_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -40 -100 40 100 0 1 10 N
|
||||
X ~ 1 0 150 50 D 50 50 1 1 P
|
||||
X ~ 2 0 -150 50 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Sensor_Temperature_DS18B20
|
||||
#
|
||||
DEF Sensor_Temperature_DS18B20 U 0 40 Y Y 1 F N
|
||||
F0 "U" -150 250 50 H V C CNN
|
||||
F1 "Sensor_Temperature_DS18B20" 250 250 50 H V C CNN
|
||||
F2 "Package_TO_SOT_THT:TO-92_Inline" -1000 -250 50 H I C CNN
|
||||
F3 "" -150 250 50 H I C CNN
|
||||
ALIAS DS1822 DS18B20 DS18S20 DS1821C
|
||||
$FPLIST
|
||||
TO*92*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
A -130 125 25 1 1799 0 1 10 N -105 125 -155 125
|
||||
C -130 -100 50 0 1 10 F
|
||||
S -200 200 200 -200 0 1 10 f
|
||||
S -105 -75 -155 0 0 1 10 F
|
||||
P 2 0 1 10 -155 25 -130 25 N
|
||||
P 2 0 1 10 -155 50 -130 50 N
|
||||
P 2 0 1 10 -155 75 -130 75 N
|
||||
P 2 0 1 10 -155 100 -130 100 N
|
||||
P 2 0 1 10 -155 125 -155 0 N
|
||||
P 2 0 1 10 -155 125 -130 125 N
|
||||
P 2 0 1 10 -105 125 -105 0 N
|
||||
X GND 1 0 -300 100 U 50 50 1 1 W
|
||||
X DQ 2 300 0 100 L 50 50 1 1 B
|
||||
X VDD 3 0 300 100 D 50 50 1 1 W
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Switch_SW_Push
|
||||
#
|
||||
DEF Switch_SW_Push SW 0 40 N N 1 F N
|
||||
F0 "SW" 50 100 50 H V L CNN
|
||||
F1 "Switch_SW_Push" 0 -60 50 H V C CNN
|
||||
F2 "" 0 200 50 H I C CNN
|
||||
F3 "" 0 200 50 H I C CNN
|
||||
DRAW
|
||||
C -80 0 20 0 1 0 N
|
||||
C 80 0 20 0 1 0 N
|
||||
P 2 0 1 0 0 50 0 120 N
|
||||
P 2 0 1 0 100 50 -100 50 N
|
||||
X 1 1 -200 0 100 R 50 50 0 1 P
|
||||
X 2 2 200 0 100 L 50 50 0 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# d1_mini_shield-rescue_CONN_01X08
|
||||
#
|
||||
DEF d1_mini_shield-rescue_CONN_01X08 P 0 40 Y N 1 F N
|
||||
F0 "P" 0 450 50 H V C CNN
|
||||
F1 "d1_mini_shield-rescue_CONN_01X08" 100 0 50 V V C CNN
|
||||
F2 "" 0 0 60 H V C CNN
|
||||
F3 "" 0 0 60 H V C CNN
|
||||
$FPLIST
|
||||
Pin_Header_Straight_1X08
|
||||
Pin_Header_Angled_1X08
|
||||
Socket_Strip_Straight_1X08
|
||||
Socket_Strip_Angled_1X08
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -50 -400 50 400 0 1 0 N
|
||||
S -50 -345 10 -355 0 1 0 N
|
||||
S -50 -245 10 -255 0 1 0 N
|
||||
S -50 -145 10 -155 0 1 0 N
|
||||
S -50 -45 10 -55 0 1 0 N
|
||||
S -50 55 10 45 0 1 0 N
|
||||
S -50 155 10 145 0 1 0 N
|
||||
S -50 255 10 245 0 1 0 N
|
||||
S -50 355 10 345 0 1 0 N
|
||||
X P1 1 -200 350 150 R 50 50 1 1 P
|
||||
X P2 2 -200 250 150 R 50 50 1 1 P
|
||||
X P3 3 -200 150 150 R 50 50 1 1 P
|
||||
X P4 4 -200 50 150 R 50 50 1 1 P
|
||||
X P5 5 -200 -50 150 R 50 50 1 1 P
|
||||
X P6 6 -200 -150 150 R 50 50 1 1 P
|
||||
X P7 7 -200 -250 150 R 50 50 1 1 P
|
||||
X P8 8 -200 -350 150 R 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_+3.3V
|
||||
#
|
||||
DEF power_+3.3V #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -150 50 H I C CNN
|
||||
F1 "power_+3.3V" 0 140 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
ALIAS +3.3V
|
||||
DRAW
|
||||
P 2 0 1 0 -30 50 0 100 N
|
||||
P 2 0 1 0 0 0 0 100 N
|
||||
P 2 0 1 0 0 100 30 50 N
|
||||
X +3V3 1 0 0 0 U 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_+3V3
|
||||
#
|
||||
DEF power_+3V3 #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -150 50 H I C CNN
|
||||
F1 "power_+3V3" 0 140 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
DRAW
|
||||
P 2 0 1 0 -30 50 0 100 N
|
||||
P 2 0 1 0 0 0 0 100 N
|
||||
P 2 0 1 0 0 100 30 50 N
|
||||
X +3V3 1 0 0 0 U 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_+5V
|
||||
#
|
||||
DEF power_+5V #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -150 50 H I C CNN
|
||||
F1 "power_+5V" 0 140 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
DRAW
|
||||
P 2 0 1 0 -30 50 0 100 N
|
||||
P 2 0 1 0 0 0 0 100 N
|
||||
P 2 0 1 0 0 100 30 50 N
|
||||
X +5V 1 0 0 0 U 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_GND
|
||||
#
|
||||
DEF power_GND #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -250 50 H I C CNN
|
||||
F1 "power_GND" 0 -150 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
DRAW
|
||||
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
|
||||
X GND 1 0 0 0 D 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# tss721_TSS721
|
||||
#
|
||||
DEF tss721_TSS721 U 0 40 Y Y 1 F N
|
||||
F0 "U" 200 850 50 H V L CNN
|
||||
F1 "tss721_TSS721" 200 750 50 H V L CNN
|
||||
F2 "" 0 -850 50 H V C CIN
|
||||
F3 "" -200 -800 50 H V C CNN
|
||||
ALIAS TSS721A
|
||||
$FPLIST
|
||||
SOIC*3.9x9.9mm*Pitch1.27mm*
|
||||
TSSOP*4.4x5mm*Pitch0.65mm*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -500 -700 500 700 0 1 10 f
|
||||
X BUSL2 1 -600 400 100 R 50 50 1 1 I
|
||||
X VS 10 -600 0 100 R 50 50 1 1 P
|
||||
X VDD 11 0 800 100 D 50 50 1 1 W
|
||||
X RX 12 600 500 100 L 50 50 1 1 I
|
||||
X RXI 13 600 400 100 L 50 50 1 1 I I
|
||||
X RIS 14 300 -800 100 U 50 50 1 1 I
|
||||
X GND 15 0 -800 100 U 50 50 1 1 W
|
||||
X BUSL1 16 -600 500 100 R 50 50 1 1 I
|
||||
X VB 2 -600 -150 100 R 50 50 1 1 P
|
||||
X STC 3 -600 -500 100 R 50 50 1 1 P
|
||||
X RIDD 4 200 -800 100 U 50 50 1 1 O
|
||||
X PF 5 -600 100 100 R 50 50 1 1 I
|
||||
X SC 6 400 -800 100 U 50 50 1 1 P
|
||||
X TXI 7 600 100 100 L 50 50 1 1 O I
|
||||
X TX 8 600 200 100 L 50 50 1 1 O
|
||||
X BAT 9 -100 800 100 D 50 50 1 1 I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
#End Library
|
||||
@@ -0,0 +1,3 @@
|
||||
EESchema-DOCLIB Version 2.0
|
||||
#
|
||||
#End Doc Library
|
||||
72
hardware/wemos_mbus_shield/kicad/d1_mini_shield-rescue.lib
Normal file
@@ -0,0 +1,72 @@
|
||||
EESchema-LIBRARY Version 2.4
|
||||
#encoding utf-8
|
||||
#
|
||||
# +3.3V-power
|
||||
#
|
||||
DEF +3.3V-power #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -150 50 H I C CNN
|
||||
F1 "+3.3V-power" 0 140 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
DRAW
|
||||
P 2 0 1 0 -30 50 0 100 N
|
||||
P 2 0 1 0 0 0 0 100 N
|
||||
P 2 0 1 0 0 100 30 50 N
|
||||
X +3V3 1 0 0 0 U 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CONN_01X08
|
||||
#
|
||||
DEF CONN_01X08 P 0 40 Y N 1 F N
|
||||
F0 "P" 0 450 50 H V C CNN
|
||||
F1 "CONN_01X08" 100 0 50 V V C CNN
|
||||
F2 "" 0 0 60 H V C CNN
|
||||
F3 "" 0 0 60 H V C CNN
|
||||
$FPLIST
|
||||
Pin_Header_Straight_1X08
|
||||
Pin_Header_Angled_1X08
|
||||
Socket_Strip_Straight_1X08
|
||||
Socket_Strip_Angled_1X08
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -50 -400 50 400 0 1 0 N
|
||||
S -50 -345 10 -355 0 1 0 N
|
||||
S -50 -245 10 -255 0 1 0 N
|
||||
S -50 -145 10 -155 0 1 0 N
|
||||
S -50 -45 10 -55 0 1 0 N
|
||||
S -50 55 10 45 0 1 0 N
|
||||
S -50 155 10 145 0 1 0 N
|
||||
S -50 255 10 245 0 1 0 N
|
||||
S -50 355 10 345 0 1 0 N
|
||||
X P1 1 -200 350 150 R 50 50 1 1 P
|
||||
X P2 2 -200 250 150 R 50 50 1 1 P
|
||||
X P3 3 -200 150 150 R 50 50 1 1 P
|
||||
X P4 4 -200 50 150 R 50 50 1 1 P
|
||||
X P5 5 -200 -50 150 R 50 50 1 1 P
|
||||
X P6 6 -200 -150 150 R 50 50 1 1 P
|
||||
X P7 7 -200 -250 150 R 50 50 1 1 P
|
||||
X P8 8 -200 -350 150 R 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Jumper-Device
|
||||
#
|
||||
DEF Jumper-Device JP 0 30 Y N 1 F N
|
||||
F0 "JP" 0 150 50 H V C CNN
|
||||
F1 "Jumper-Device" 0 -80 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
SolderJumper*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
C -100 0 35 0 1 0 N
|
||||
A 0 -26 125 375 1422 0 1 0 N 99 50 -98 50
|
||||
C 100 0 35 0 1 0 N
|
||||
X 1 1 -300 0 165 R 50 50 0 1 P
|
||||
X 2 2 300 0 165 L 50 50 0 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
#End Library
|
||||
1852
hardware/wemos_mbus_shield/kicad/d1_mini_shield.kicad_pcb
Normal file
75
hardware/wemos_mbus_shield/kicad/d1_mini_shield.kicad_prl
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"board": {
|
||||
"active_layer": 0,
|
||||
"active_layer_preset": "",
|
||||
"auto_track_width": true,
|
||||
"hidden_nets": [],
|
||||
"high_contrast_mode": 0,
|
||||
"net_color_mode": 1,
|
||||
"opacity": {
|
||||
"pads": 1.0,
|
||||
"tracks": 1.0,
|
||||
"vias": 1.0,
|
||||
"zones": 0.6
|
||||
},
|
||||
"ratsnest_display_mode": 0,
|
||||
"selection_filter": {
|
||||
"dimensions": true,
|
||||
"footprints": true,
|
||||
"graphics": true,
|
||||
"keepouts": true,
|
||||
"lockedItems": true,
|
||||
"otherItems": true,
|
||||
"pads": true,
|
||||
"text": true,
|
||||
"tracks": true,
|
||||
"vias": true,
|
||||
"zones": true
|
||||
},
|
||||
"visible_items": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36
|
||||
],
|
||||
"visible_layers": "fffffff_ffffffff",
|
||||
"zone_display_mode": 0
|
||||
},
|
||||
"meta": {
|
||||
"filename": "d1_mini_shield.kicad_prl",
|
||||
"version": 3
|
||||
},
|
||||
"project": {
|
||||
"files": []
|
||||
}
|
||||
}
|
||||
356
hardware/wemos_mbus_shield/kicad/d1_mini_shield.kicad_pro
Normal file
@@ -0,0 +1,356 @@
|
||||
{
|
||||
"board": {
|
||||
"design_settings": {
|
||||
"defaults": {
|
||||
"board_outline_line_width": 0.15,
|
||||
"copper_line_width": 0.2,
|
||||
"copper_text_italic": false,
|
||||
"copper_text_size_h": 1.5,
|
||||
"copper_text_size_v": 1.5,
|
||||
"copper_text_thickness": 0.3,
|
||||
"copper_text_upright": true,
|
||||
"courtyard_line_width": 0.05,
|
||||
"other_line_width": 0.15,
|
||||
"other_text_italic": false,
|
||||
"other_text_size_h": 1.0,
|
||||
"other_text_size_v": 1.0,
|
||||
"other_text_thickness": 0.15,
|
||||
"other_text_upright": true,
|
||||
"silk_line_width": 0.15,
|
||||
"silk_text_italic": false,
|
||||
"silk_text_size_h": 1.0,
|
||||
"silk_text_size_v": 1.0,
|
||||
"silk_text_thickness": 0.15,
|
||||
"silk_text_upright": true
|
||||
},
|
||||
"diff_pair_dimensions": [
|
||||
{
|
||||
"gap": 0.25,
|
||||
"via_gap": 0.25,
|
||||
"width": 0.2
|
||||
}
|
||||
],
|
||||
"drc_exclusions": [],
|
||||
"rule_severitieslegacy_courtyards_overlap": true,
|
||||
"rule_severitieslegacy_no_courtyard_defined": false,
|
||||
"rules": {
|
||||
"allow_blind_buried_vias": false,
|
||||
"allow_microvias": false,
|
||||
"min_hole_to_hole": 0.25,
|
||||
"min_microvia_diameter": 0.2,
|
||||
"min_microvia_drill": 0.09999999999999999,
|
||||
"min_through_hole_diameter": 0.3,
|
||||
"min_track_width": 0.2,
|
||||
"min_via_diameter": 0.4,
|
||||
"solder_mask_clearance": 0.2,
|
||||
"solder_mask_min_width": 0.0,
|
||||
"solder_paste_clearance": 0.0,
|
||||
"solder_paste_margin_ratio": -0.0
|
||||
},
|
||||
"track_widths": [
|
||||
0.25,
|
||||
0.5
|
||||
],
|
||||
"via_dimensions": [
|
||||
{
|
||||
"diameter": 0.6,
|
||||
"drill": 0.4
|
||||
}
|
||||
]
|
||||
},
|
||||
"layer_presets": []
|
||||
},
|
||||
"boards": [],
|
||||
"cvpcb": {
|
||||
"equivalence_files": []
|
||||
},
|
||||
"erc": {
|
||||
"erc_exclusions": [],
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"pin_map": [
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
]
|
||||
],
|
||||
"rule_severities": {
|
||||
"bus_definition_conflict": "error",
|
||||
"bus_entry_needed": "error",
|
||||
"bus_label_syntax": "error",
|
||||
"bus_to_bus_conflict": "error",
|
||||
"bus_to_net_conflict": "error",
|
||||
"different_unit_footprint": "error",
|
||||
"different_unit_net": "error",
|
||||
"duplicate_reference": "error",
|
||||
"duplicate_sheet_names": "error",
|
||||
"extra_units": "error",
|
||||
"global_label_dangling": "warning",
|
||||
"hier_label_mismatch": "error",
|
||||
"label_dangling": "error",
|
||||
"lib_symbol_issues": "warning",
|
||||
"multiple_net_names": "warning",
|
||||
"net_not_bus_member": "warning",
|
||||
"no_connect_connected": "warning",
|
||||
"no_connect_dangling": "warning",
|
||||
"pin_not_connected": "error",
|
||||
"pin_not_driven": "error",
|
||||
"pin_to_pin": "warning",
|
||||
"power_pin_not_driven": "error",
|
||||
"similar_labels": "warning",
|
||||
"unannotated": "error",
|
||||
"unit_value_mismatch": "error",
|
||||
"unresolved_variable": "error",
|
||||
"wire_dangling": "error"
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"pinned_footprint_libs": [],
|
||||
"pinned_symbol_libs": []
|
||||
},
|
||||
"meta": {
|
||||
"filename": "d1_mini_shield.kicad_pro",
|
||||
"version": 1
|
||||
},
|
||||
"net_settings": {
|
||||
"classes": [
|
||||
{
|
||||
"bus_width": 12.0,
|
||||
"clearance": 0.2,
|
||||
"diff_pair_gap": 0.25,
|
||||
"diff_pair_via_gap": 0.25,
|
||||
"diff_pair_width": 0.2,
|
||||
"line_style": 0,
|
||||
"microvia_diameter": 0.3,
|
||||
"microvia_drill": 0.1,
|
||||
"name": "Default",
|
||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||
"track_width": 0.25,
|
||||
"via_diameter": 0.8,
|
||||
"via_drill": 0.4,
|
||||
"wire_width": 6.0
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"version": 2
|
||||
},
|
||||
"net_colors": null
|
||||
},
|
||||
"pcbnew": {
|
||||
"last_paths": {
|
||||
"gencad": "",
|
||||
"idf": "",
|
||||
"netlist": "d1_mini_shield.net",
|
||||
"specctra_dsn": "",
|
||||
"step": "",
|
||||
"vrml": ""
|
||||
},
|
||||
"page_layout_descr_file": ""
|
||||
},
|
||||
"schematic": {
|
||||
"annotate_start_num": 0,
|
||||
"drawing": {
|
||||
"default_line_thickness": 6.0,
|
||||
"default_text_size": 50.0,
|
||||
"field_names": [],
|
||||
"intersheets_ref_own_page": false,
|
||||
"intersheets_ref_prefix": "",
|
||||
"intersheets_ref_short": false,
|
||||
"intersheets_ref_show": false,
|
||||
"intersheets_ref_suffix": "",
|
||||
"junction_size_choice": 3,
|
||||
"label_size_ratio": 0.25,
|
||||
"pin_symbol_size": 0.0,
|
||||
"text_offset_ratio": 0.08
|
||||
},
|
||||
"legacy_lib_dir": "",
|
||||
"legacy_lib_list": [],
|
||||
"meta": {
|
||||
"version": 1
|
||||
},
|
||||
"net_format_name": "Pcbnew",
|
||||
"ngspice": {
|
||||
"fix_include_paths": true,
|
||||
"fix_passive_vals": false,
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"model_mode": 0,
|
||||
"workbook_filename": ""
|
||||
},
|
||||
"page_layout_descr_file": "",
|
||||
"plot_directory": "",
|
||||
"spice_adjust_passive_values": false,
|
||||
"spice_external_command": "spice \"%I\"",
|
||||
"subpart_first_id": 65,
|
||||
"subpart_id_separator": 0
|
||||
},
|
||||
"sheets": [],
|
||||
"text_variables": {}
|
||||
}
|
||||
482
hardware/wemos_mbus_shield/kicad/d1_mini_shield.net
Normal file
@@ -0,0 +1,482 @@
|
||||
(export (version D)
|
||||
(design
|
||||
(source /home/gunnar/src/AmsToMqttBridge/hardware/wemos_mbus_shield/kicad/d1_mini_shield.sch)
|
||||
(date "sø. 26. juni 2022 kl. 12.19 +0200")
|
||||
(tool "Eeschema 5.1.5+dfsg1-2build2")
|
||||
(sheet (number 1) (name /) (tstamps /)
|
||||
(title_block
|
||||
(title)
|
||||
(company)
|
||||
(rev)
|
||||
(date)
|
||||
(source d1_mini_shield.sch)
|
||||
(comment (number 1) (value ""))
|
||||
(comment (number 2) (value ""))
|
||||
(comment (number 3) (value ""))
|
||||
(comment (number 4) (value "")))))
|
||||
(components
|
||||
(comp (ref P1)
|
||||
(value CONN_01X08)
|
||||
(footprint D1_mini:D1_mini_Pin_Header)
|
||||
(libsource (lib d1_mini_shield-rescue) (part CONN_01X08) (description ""))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 5763EB78))
|
||||
(comp (ref P2)
|
||||
(value CONN_01X08)
|
||||
(footprint D1_mini:D1_mini_Pin_Header)
|
||||
(libsource (lib d1_mini_shield-rescue) (part CONN_01X08) (description ""))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 5763EBF2))
|
||||
(comp (ref U1)
|
||||
(value TSS721)
|
||||
(footprint Package_SO:SOIC-16_3.9x9.9mm_P1.27mm)
|
||||
(datasheet http://www.ti.com/lit/ds/symlink/tss721a.pdf)
|
||||
(libsource (lib tss721) (part TSS721) (description "TSS721A Meter Bus Transceiver, SOIC-16/TSSOP-16"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62B826D2))
|
||||
(comp (ref J1)
|
||||
(value RJ45)
|
||||
(footprint Connector_RJ:RJ45_Amphenol_54602-x08_Horizontal)
|
||||
(datasheet ~)
|
||||
(libsource (lib Connector) (part RJ45) (description "RJ connector, 8P8C (8 positions 8 connected)"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62B8AC34))
|
||||
(comp (ref R4)
|
||||
(value 220)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62B8CAA8))
|
||||
(comp (ref R2)
|
||||
(value 220)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62B8DB92))
|
||||
(comp (ref R3)
|
||||
(value 82k)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62B9F861))
|
||||
(comp (ref R1)
|
||||
(value 470)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62B9FC37))
|
||||
(comp (ref C2)
|
||||
(value 1u)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62BA06BE))
|
||||
(comp (ref C1)
|
||||
(value 100n)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62BA09E7))
|
||||
(comp (ref R5)
|
||||
(value 100k)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62BED413))
|
||||
(comp (ref C3)
|
||||
(value 100n)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62BED9ED))
|
||||
(comp (ref JP1)
|
||||
(value Jumper)
|
||||
(footprint Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part Jumper) (description "Jumper, normally closed"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C331C0))
|
||||
(comp (ref JP2)
|
||||
(value Jumper)
|
||||
(footprint Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part Jumper) (description "Jumper, normally closed"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C365CA))
|
||||
(comp (ref JP3)
|
||||
(value Jumper)
|
||||
(footprint Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part Jumper) (description "Jumper, normally closed"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C36C70))
|
||||
(comp (ref D1)
|
||||
(value LED_RGB)
|
||||
(footprint LED_SMD:LED_RGB_PLCC-6)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part LED_RGB) (description "RGB LED, 6 pin package"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C43A7B))
|
||||
(comp (ref R9)
|
||||
(value 1k)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C495F7))
|
||||
(comp (ref R8)
|
||||
(value 1k)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C4BDE9))
|
||||
(comp (ref R10)
|
||||
(value 1k)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C4C336))
|
||||
(comp (ref U2)
|
||||
(value DS18B20)
|
||||
(footprint Package_TO_SOT_THT:TO-92_Inline)
|
||||
(datasheet http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf)
|
||||
(libsource (lib Sensor_Temperature) (part DS18B20) (description "Programmable Resolution 1-Wire Digital Thermometer TO-92"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C6296F))
|
||||
(comp (ref R7)
|
||||
(value 4k7)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C6405D))
|
||||
(comp (ref SW1)
|
||||
(value SW_Push)
|
||||
(footprint Button_Switch_SMD:SW_SPST_B3U-3000P)
|
||||
(datasheet ~)
|
||||
(libsource (lib Switch) (part SW_Push) (description "Push button switch, generic, two pins"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C73229))
|
||||
(comp (ref R6)
|
||||
(value 10k)
|
||||
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part R) (description Resistor))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62C73CE8))
|
||||
(comp (ref JP4)
|
||||
(value Jumper)
|
||||
(footprint Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm)
|
||||
(datasheet ~)
|
||||
(libsource (lib Device) (part Jumper) (description "Jumper, normally closed"))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 62D1E97A)))
|
||||
(libparts
|
||||
(libpart (lib Connector) (part 8P8C)
|
||||
(aliases
|
||||
(alias RJ31)
|
||||
(alias RJ32)
|
||||
(alias RJ33)
|
||||
(alias RJ34)
|
||||
(alias RJ35)
|
||||
(alias RJ41)
|
||||
(alias RJ45)
|
||||
(alias RJ49)
|
||||
(alias RJ61))
|
||||
(description "RJ connector, 8P8C (8 positions 8 connected), RJ31/RJ32/RJ33/RJ34/RJ35/RJ41/RJ45/RJ49/RJ61")
|
||||
(docs ~)
|
||||
(footprints
|
||||
(fp 8P8C*)
|
||||
(fp RJ31*)
|
||||
(fp RJ32*)
|
||||
(fp RJ33*)
|
||||
(fp RJ34*)
|
||||
(fp RJ35*)
|
||||
(fp RJ41*)
|
||||
(fp RJ45*)
|
||||
(fp RJ49*)
|
||||
(fp RJ61*))
|
||||
(fields
|
||||
(field (name Reference) J)
|
||||
(field (name Value) 8P8C))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))
|
||||
(pin (num 3) (name ~) (type passive))
|
||||
(pin (num 4) (name ~) (type passive))
|
||||
(pin (num 5) (name ~) (type passive))
|
||||
(pin (num 6) (name ~) (type passive))
|
||||
(pin (num 7) (name ~) (type passive))
|
||||
(pin (num 8) (name ~) (type passive))))
|
||||
(libpart (lib Device) (part C)
|
||||
(description "Unpolarized capacitor")
|
||||
(docs ~)
|
||||
(footprints
|
||||
(fp C_*))
|
||||
(fields
|
||||
(field (name Reference) C)
|
||||
(field (name Value) C))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))))
|
||||
(libpart (lib Device) (part Jumper)
|
||||
(description "Jumper, normally closed")
|
||||
(docs ~)
|
||||
(footprints
|
||||
(fp SolderJumper*))
|
||||
(fields
|
||||
(field (name Reference) JP)
|
||||
(field (name Value) Jumper))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type passive))
|
||||
(pin (num 2) (name 2) (type passive))))
|
||||
(libpart (lib Device) (part LED_RGB)
|
||||
(description "RGB LED, 6 pin package")
|
||||
(docs ~)
|
||||
(footprints
|
||||
(fp LED*)
|
||||
(fp LED_SMD:*)
|
||||
(fp LED_THT:*))
|
||||
(fields
|
||||
(field (name Reference) D)
|
||||
(field (name Value) LED_RGB))
|
||||
(pins
|
||||
(pin (num 1) (name RK) (type passive))
|
||||
(pin (num 2) (name GK) (type passive))
|
||||
(pin (num 3) (name BK) (type passive))
|
||||
(pin (num 4) (name BA) (type passive))
|
||||
(pin (num 5) (name GA) (type passive))
|
||||
(pin (num 6) (name RA) (type passive))))
|
||||
(libpart (lib Device) (part R)
|
||||
(description Resistor)
|
||||
(docs ~)
|
||||
(footprints
|
||||
(fp R_*))
|
||||
(fields
|
||||
(field (name Reference) R)
|
||||
(field (name Value) R))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))))
|
||||
(libpart (lib Sensor_Temperature) (part MAX31820)
|
||||
(aliases
|
||||
(alias DS1822)
|
||||
(alias DS18B20)
|
||||
(alias DS18S20)
|
||||
(alias DS1821C))
|
||||
(description "1-Wire Ambient Temperature Sensor TO-92")
|
||||
(docs http://datasheets.maximintegrated.com/en/ds/MAX31820.pdf)
|
||||
(footprints
|
||||
(fp TO*92*))
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) MAX31820)
|
||||
(field (name Footprint) Package_TO_SOT_THT:TO-92_Inline))
|
||||
(pins
|
||||
(pin (num 1) (name GND) (type power_in))
|
||||
(pin (num 2) (name DQ) (type BiDi))
|
||||
(pin (num 3) (name VDD) (type power_in))))
|
||||
(libpart (lib Switch) (part SW_Push)
|
||||
(description "Push button switch, generic, two pins")
|
||||
(docs ~)
|
||||
(fields
|
||||
(field (name Reference) SW)
|
||||
(field (name Value) SW_Push))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type passive))
|
||||
(pin (num 2) (name 2) (type passive))))
|
||||
(libpart (lib d1_mini_shield-rescue) (part CONN_01X08)
|
||||
(footprints
|
||||
(fp Pin_Header_Straight_1X08)
|
||||
(fp Pin_Header_Angled_1X08)
|
||||
(fp Socket_Strip_Straight_1X08)
|
||||
(fp Socket_Strip_Angled_1X08))
|
||||
(fields
|
||||
(field (name Reference) P)
|
||||
(field (name Value) CONN_01X08))
|
||||
(pins
|
||||
(pin (num 1) (name P1) (type passive))
|
||||
(pin (num 2) (name P2) (type passive))
|
||||
(pin (num 3) (name P3) (type passive))
|
||||
(pin (num 4) (name P4) (type passive))
|
||||
(pin (num 5) (name P5) (type passive))
|
||||
(pin (num 6) (name P6) (type passive))
|
||||
(pin (num 7) (name P7) (type passive))
|
||||
(pin (num 8) (name P8) (type passive))))
|
||||
(libpart (lib tss721) (part TSS721)
|
||||
(aliases
|
||||
(alias TSS721A))
|
||||
(description "TSS721A Meter Bus Transceiver, SOIC-16/TSSOP-16")
|
||||
(docs http://www.ti.com/lit/ds/symlink/tss721a.pdf)
|
||||
(footprints
|
||||
(fp SOIC*3.9x9.9mm*Pitch1.27mm*)
|
||||
(fp TSSOP*4.4x5mm*Pitch0.65mm*))
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) TSS721))
|
||||
(pins
|
||||
(pin (num 1) (name BUSL2) (type input))
|
||||
(pin (num 2) (name VB) (type passive))
|
||||
(pin (num 3) (name STC) (type passive))
|
||||
(pin (num 4) (name RIDD) (type output))
|
||||
(pin (num 5) (name PF) (type input))
|
||||
(pin (num 6) (name SC) (type passive))
|
||||
(pin (num 7) (name TXI) (type output))
|
||||
(pin (num 8) (name TX) (type output))
|
||||
(pin (num 9) (name BAT) (type input))
|
||||
(pin (num 10) (name VS) (type passive))
|
||||
(pin (num 11) (name VDD) (type power_in))
|
||||
(pin (num 12) (name RX) (type input))
|
||||
(pin (num 13) (name RXI) (type input))
|
||||
(pin (num 14) (name RIS) (type input))
|
||||
(pin (num 15) (name GND) (type power_in))
|
||||
(pin (num 16) (name BUSL1) (type input)))))
|
||||
(libraries
|
||||
(library (logical Connector)
|
||||
(uri /usr/share/kicad/library/Connector.lib))
|
||||
(library (logical Device)
|
||||
(uri /usr/share/kicad/library/Device.lib))
|
||||
(library (logical Sensor_Temperature)
|
||||
(uri /usr/share/kicad/library/Sensor_Temperature.lib))
|
||||
(library (logical Switch)
|
||||
(uri /usr/share/kicad/library/Switch.lib))
|
||||
(library (logical d1_mini_shield-rescue)
|
||||
(uri /home/gunnar/src/AmsToMqttBridge/hardware/wemos_mbus_shield/kicad/d1_mini_shield-rescue.lib))
|
||||
(library (logical tss721)
|
||||
(uri /home/gunnar/src/AmsToMqttBridge/hardware/wemos_mbus_shield/kicad/tss721.lib)))
|
||||
(nets
|
||||
(net (code 1) (name TEMP)
|
||||
(node (ref R7) (pin 2))
|
||||
(node (ref U2) (pin 2))
|
||||
(node (ref P1) (pin 5))
|
||||
(node (ref JP3) (pin 2)))
|
||||
(net (code 2) (name +3V3)
|
||||
(node (ref R7) (pin 1))
|
||||
(node (ref U1) (pin 9))
|
||||
(node (ref P2) (pin 1))
|
||||
(node (ref R6) (pin 2))
|
||||
(node (ref D1) (pin 4))
|
||||
(node (ref D1) (pin 5))
|
||||
(node (ref D1) (pin 6))
|
||||
(node (ref U2) (pin 3)))
|
||||
(net (code 3) (name "Net-(D1-Pad1)")
|
||||
(node (ref R9) (pin 2))
|
||||
(node (ref D1) (pin 1)))
|
||||
(net (code 4) (name "Net-(D1-Pad2)")
|
||||
(node (ref D1) (pin 2))
|
||||
(node (ref R8) (pin 2)))
|
||||
(net (code 5) (name "Net-(D1-Pad3)")
|
||||
(node (ref D1) (pin 3))
|
||||
(node (ref R10) (pin 2)))
|
||||
(net (code 6) (name MBUS2)
|
||||
(node (ref J1) (pin 2))
|
||||
(node (ref R4) (pin 1)))
|
||||
(net (code 7) (name BTN_AP)
|
||||
(node (ref P1) (pin 4))
|
||||
(node (ref SW1) (pin 1))
|
||||
(node (ref R6) (pin 1)))
|
||||
(net (code 8) (name "Net-(R4-Pad2)")
|
||||
(node (ref U1) (pin 1))
|
||||
(node (ref R4) (pin 2)))
|
||||
(net (code 9) (name "Net-(R2-Pad2)")
|
||||
(node (ref R2) (pin 2))
|
||||
(node (ref U1) (pin 16)))
|
||||
(net (code 10) (name MBUS1)
|
||||
(node (ref J1) (pin 1))
|
||||
(node (ref R2) (pin 1)))
|
||||
(net (code 11) (name LED_R)
|
||||
(node (ref R9) (pin 1))
|
||||
(node (ref P2) (pin 4)))
|
||||
(net (code 12) (name "Net-(J1-Pad8)")
|
||||
(node (ref J1) (pin 8))
|
||||
(node (ref JP1) (pin 1)))
|
||||
(net (code 13) (name "Net-(J1-Pad5)")
|
||||
(node (ref J1) (pin 5))
|
||||
(node (ref JP2) (pin 1)))
|
||||
(net (code 14) (name "Net-(J1-Pad4)")
|
||||
(node (ref J1) (pin 4))
|
||||
(node (ref JP3) (pin 1)))
|
||||
(net (code 15) (name +5V)
|
||||
(node (ref P1) (pin 1))
|
||||
(node (ref JP1) (pin 2)))
|
||||
(net (code 16) (name "Net-(J1-Pad7)")
|
||||
(node (ref J1) (pin 7))
|
||||
(node (ref JP4) (pin 1)))
|
||||
(net (code 17) (name GND)
|
||||
(node (ref P1) (pin 2))
|
||||
(node (ref C3) (pin 2))
|
||||
(node (ref R3) (pin 1))
|
||||
(node (ref R1) (pin 1))
|
||||
(node (ref C2) (pin 1))
|
||||
(node (ref C1) (pin 1))
|
||||
(node (ref R5) (pin 2))
|
||||
(node (ref U1) (pin 15))
|
||||
(node (ref U2) (pin 1))
|
||||
(node (ref SW1) (pin 2))
|
||||
(node (ref JP4) (pin 2))
|
||||
(node (ref JP2) (pin 2)))
|
||||
(net (code 18) (name LED_G)
|
||||
(node (ref R8) (pin 1))
|
||||
(node (ref P2) (pin 5)))
|
||||
(net (code 19) (name "Net-(U1-Pad10)")
|
||||
(node (ref U1) (pin 10)))
|
||||
(net (code 20) (name "Net-(U1-Pad12)")
|
||||
(node (ref U1) (pin 12)))
|
||||
(net (code 21) (name "Net-(U1-Pad13)")
|
||||
(node (ref U1) (pin 13)))
|
||||
(net (code 22) (name "Net-(U1-Pad2)")
|
||||
(node (ref U1) (pin 2)))
|
||||
(net (code 23) (name "Net-(U1-Pad5)")
|
||||
(node (ref U1) (pin 5)))
|
||||
(net (code 24) (name "Net-(U1-Pad7)")
|
||||
(node (ref U1) (pin 7)))
|
||||
(net (code 25) (name "Net-(J1-Pad3)")
|
||||
(node (ref J1) (pin 3)))
|
||||
(net (code 26) (name "Net-(J1-Pad6)")
|
||||
(node (ref J1) (pin 6)))
|
||||
(net (code 27) (name /RST)
|
||||
(node (ref P2) (pin 8)))
|
||||
(net (code 28) (name /D4)
|
||||
(node (ref P1) (pin 3)))
|
||||
(net (code 29) (name /D1)
|
||||
(node (ref P1) (pin 6)))
|
||||
(net (code 30) (name /RX)
|
||||
(node (ref P1) (pin 7)))
|
||||
(net (code 31) (name /TX)
|
||||
(node (ref P1) (pin 8)))
|
||||
(net (code 32) (name /D8)
|
||||
(node (ref P2) (pin 2)))
|
||||
(net (code 33) (name /D0)
|
||||
(node (ref P2) (pin 6)))
|
||||
(net (code 34) (name /A0)
|
||||
(node (ref P2) (pin 7)))
|
||||
(net (code 35) (name "Net-(R3-Pad2)")
|
||||
(node (ref R3) (pin 2))
|
||||
(node (ref U1) (pin 4)))
|
||||
(net (code 36) (name HAN_TX)
|
||||
(node (ref R10) (pin 1))
|
||||
(node (ref U1) (pin 8))
|
||||
(node (ref P2) (pin 3)))
|
||||
(net (code 37) (name "Net-(C3-Pad1)")
|
||||
(node (ref U1) (pin 11))
|
||||
(node (ref C3) (pin 1))
|
||||
(node (ref R5) (pin 1)))
|
||||
(net (code 38) (name "Net-(R1-Pad2)")
|
||||
(node (ref R1) (pin 2))
|
||||
(node (ref U1) (pin 14)))
|
||||
(net (code 39) (name "Net-(C2-Pad2)")
|
||||
(node (ref C2) (pin 2))
|
||||
(node (ref U1) (pin 3)))
|
||||
(net (code 40) (name "Net-(C1-Pad2)")
|
||||
(node (ref U1) (pin 6))
|
||||
(node (ref C1) (pin 2)))))
|
||||
246
hardware/wemos_mbus_shield/kicad/d1_mini_shield.pro
Normal file
@@ -0,0 +1,246 @@
|
||||
update=sø. 26. juni 2022 kl. 11.55 +0200
|
||||
version=1
|
||||
last_client=kicad
|
||||
[general]
|
||||
version=1
|
||||
[cvpcb]
|
||||
version=1
|
||||
NetIExt=net
|
||||
[eeschema]
|
||||
version=1
|
||||
LibDir=
|
||||
[schematic_editor]
|
||||
version=1
|
||||
PageLayoutDescrFile=
|
||||
PlotDirectoryName=
|
||||
SubpartIdSeparator=0
|
||||
SubpartFirstId=65
|
||||
NetFmtName=Pcbnew
|
||||
SpiceAjustPassiveValues=0
|
||||
LabSize=50
|
||||
ERC_TestSimilarLabels=1
|
||||
[pcbnew]
|
||||
version=1
|
||||
PageLayoutDescrFile=
|
||||
LastNetListRead=d1_mini_shield.net
|
||||
CopperLayerCount=2
|
||||
BoardThickness=1.6
|
||||
AllowMicroVias=0
|
||||
AllowBlindVias=0
|
||||
RequireCourtyardDefinitions=0
|
||||
ProhibitOverlappingCourtyards=1
|
||||
MinTrackWidth=0.2
|
||||
MinViaDiameter=0.4
|
||||
MinViaDrill=0.3
|
||||
MinMicroViaDiameter=0.2
|
||||
MinMicroViaDrill=0.09999999999999999
|
||||
MinHoleToHole=0.25
|
||||
TrackWidth1=0.25
|
||||
TrackWidth2=0.5
|
||||
ViaDiameter1=0.6
|
||||
ViaDrill1=0.4
|
||||
dPairWidth1=0.2
|
||||
dPairGap1=0.25
|
||||
dPairViaGap1=0.25
|
||||
SilkLineWidth=0.15
|
||||
SilkTextSizeV=1
|
||||
SilkTextSizeH=1
|
||||
SilkTextSizeThickness=0.15
|
||||
SilkTextItalic=0
|
||||
SilkTextUpright=1
|
||||
CopperLineWidth=0.2
|
||||
CopperTextSizeV=1.5
|
||||
CopperTextSizeH=1.5
|
||||
CopperTextThickness=0.3
|
||||
CopperTextItalic=0
|
||||
CopperTextUpright=1
|
||||
EdgeCutLineWidth=0.15
|
||||
CourtyardLineWidth=0.05
|
||||
OthersLineWidth=0.15
|
||||
OthersTextSizeV=1
|
||||
OthersTextSizeH=1
|
||||
OthersTextSizeThickness=0.15
|
||||
OthersTextItalic=0
|
||||
OthersTextUpright=1
|
||||
SolderMaskClearance=0.2
|
||||
SolderMaskMinWidth=0
|
||||
SolderPasteClearance=0
|
||||
SolderPasteRatio=-0
|
||||
[pcbnew/Layer.F.Cu]
|
||||
Name=F.Cu
|
||||
Type=0
|
||||
Enabled=1
|
||||
[pcbnew/Layer.In1.Cu]
|
||||
Name=In1.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In2.Cu]
|
||||
Name=In2.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In3.Cu]
|
||||
Name=In3.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In4.Cu]
|
||||
Name=In4.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In5.Cu]
|
||||
Name=In5.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In6.Cu]
|
||||
Name=In6.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In7.Cu]
|
||||
Name=In7.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In8.Cu]
|
||||
Name=In8.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In9.Cu]
|
||||
Name=In9.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In10.Cu]
|
||||
Name=In10.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In11.Cu]
|
||||
Name=In11.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In12.Cu]
|
||||
Name=In12.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In13.Cu]
|
||||
Name=In13.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In14.Cu]
|
||||
Name=In14.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In15.Cu]
|
||||
Name=In15.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In16.Cu]
|
||||
Name=In16.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In17.Cu]
|
||||
Name=In17.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In18.Cu]
|
||||
Name=In18.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In19.Cu]
|
||||
Name=In19.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In20.Cu]
|
||||
Name=In20.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In21.Cu]
|
||||
Name=In21.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In22.Cu]
|
||||
Name=In22.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In23.Cu]
|
||||
Name=In23.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In24.Cu]
|
||||
Name=In24.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In25.Cu]
|
||||
Name=In25.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In26.Cu]
|
||||
Name=In26.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In27.Cu]
|
||||
Name=In27.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In28.Cu]
|
||||
Name=In28.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In29.Cu]
|
||||
Name=In29.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.In30.Cu]
|
||||
Name=In30.Cu
|
||||
Type=0
|
||||
Enabled=0
|
||||
[pcbnew/Layer.B.Cu]
|
||||
Name=B.Cu
|
||||
Type=0
|
||||
Enabled=1
|
||||
[pcbnew/Layer.B.Adhes]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.F.Adhes]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.B.Paste]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.F.Paste]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.B.SilkS]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.F.SilkS]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.B.Mask]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.F.Mask]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Dwgs.User]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Cmts.User]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Eco1.User]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Eco2.User]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Edge.Cuts]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Margin]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.B.CrtYd]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.F.CrtYd]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.B.Fab]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.F.Fab]
|
||||
Enabled=1
|
||||
[pcbnew/Layer.Rescue]
|
||||
Enabled=0
|
||||
[pcbnew/Netclasses]
|
||||
[pcbnew/Netclasses/Default]
|
||||
Name=Default
|
||||
Clearance=0.2
|
||||
TrackWidth=0.25
|
||||
ViaDiameter=0.6
|
||||
ViaDrill=0.4
|
||||
uViaDiameter=0.3
|
||||
uViaDrill=0.1
|
||||
dPairWidth=0.2
|
||||
dPairGap=0.25
|
||||
dPairViaGap=0.25
|
||||
725
hardware/wemos_mbus_shield/kicad/d1_mini_shield.sch
Normal file
@@ -0,0 +1,725 @@
|
||||
EESchema Schematic File Version 4
|
||||
EELAYER 30 0
|
||||
EELAYER END
|
||||
$Descr A4 11693 8268
|
||||
encoding utf-8
|
||||
Sheet 1 1
|
||||
Title ""
|
||||
Date ""
|
||||
Rev ""
|
||||
Comp ""
|
||||
Comment1 ""
|
||||
Comment2 ""
|
||||
Comment3 ""
|
||||
Comment4 ""
|
||||
$EndDescr
|
||||
$Comp
|
||||
L d1_mini_shield-rescue:CONN_01X08 P1
|
||||
U 1 1 5763EB78
|
||||
P 8300 1850
|
||||
F 0 "P1" H 8300 2300 50 0000 C CNN
|
||||
F 1 "CONN_01X08" V 8400 1850 50 0000 C CNN
|
||||
F 2 "D1_mini:D1_mini_Pin_Header" H 8300 1850 50 0001 C CNN
|
||||
F 3 "" H 8300 1850 50 0000 C CNN
|
||||
1 8300 1850
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L d1_mini_shield-rescue:CONN_01X08 P2
|
||||
U 1 1 5763EBF2
|
||||
P 9400 1850
|
||||
F 0 "P2" H 9400 2300 50 0000 C CNN
|
||||
F 1 "CONN_01X08" V 9500 1850 50 0000 C CNN
|
||||
F 2 "D1_mini:D1_mini_Pin_Header" H 9400 1850 50 0001 C CNN
|
||||
F 3 "" H 9400 1850 50 0000 C CNN
|
||||
1 9400 1850
|
||||
-1 0 0 -1
|
||||
$EndComp
|
||||
Text Label 8100 1500 2 60 ~ 0
|
||||
+5V
|
||||
Text Label 8100 1600 2 60 ~ 0
|
||||
GND
|
||||
Text Label 8100 1700 2 60 ~ 0
|
||||
D4
|
||||
Text Label 8100 1800 2 60 ~ 0
|
||||
D3
|
||||
Text Label 8100 1900 2 60 ~ 0
|
||||
D2
|
||||
Text Label 8100 2000 2 60 ~ 0
|
||||
D1
|
||||
Text Label 8100 2100 2 60 ~ 0
|
||||
RX
|
||||
Text Label 8100 2200 2 60 ~ 0
|
||||
TX
|
||||
Text Label 9600 1500 0 60 ~ 0
|
||||
+3.3V
|
||||
Text Label 9600 1600 0 60 ~ 0
|
||||
D8
|
||||
Text Label 9600 1700 0 60 ~ 0
|
||||
D7
|
||||
Text Label 9600 1800 0 60 ~ 0
|
||||
D6
|
||||
Text Label 9600 1900 0 60 ~ 0
|
||||
D5
|
||||
Text Label 9600 2000 0 60 ~ 0
|
||||
D0
|
||||
Text Label 9600 2100 0 60 ~ 0
|
||||
A0
|
||||
Text Label 9600 2200 0 60 ~ 0
|
||||
RST
|
||||
Text Notes 8750 1750 2 60 ~ 0
|
||||
GPIO2
|
||||
Text Notes 8750 1850 2 60 ~ 0
|
||||
GPIO0
|
||||
Text Notes 8750 1950 2 60 ~ 0
|
||||
GPIO4
|
||||
Text Notes 8750 2050 2 60 ~ 0
|
||||
GPIO5
|
||||
Text Notes 8900 1650 0 60 ~ 0
|
||||
GPIO15
|
||||
Text Notes 8900 1750 0 60 ~ 0
|
||||
GPIO13
|
||||
Text Notes 8900 1850 0 60 ~ 0
|
||||
GPIO12
|
||||
Text Notes 8900 1950 0 60 ~ 0
|
||||
GPIO14
|
||||
Text Notes 8900 2050 0 60 ~ 0
|
||||
GPIO16
|
||||
Text Notes 7550 1050 0 60 ~ 0
|
||||
D1 Mini Shield
|
||||
$Comp
|
||||
L tss721:TSS721 U1
|
||||
U 1 1 62B826D2
|
||||
P 3650 5550
|
||||
F 0 "U1" H 3650 6621 50 0000 C CNN
|
||||
F 1 "TSS721" H 3650 6530 50 0000 C CNN
|
||||
F 2 "Package_SO:SOIC-16_3.9x9.9mm_P1.27mm" H 3650 4700 50 0001 C CIN
|
||||
F 3 "http://www.ti.com/lit/ds/symlink/tss721a.pdf" H 3650 6439 50 0000 C CNN
|
||||
1 3650 5550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:+3.3V #PWR0101
|
||||
U 1 1 62B89C7B
|
||||
P 2850 4750
|
||||
F 0 "#PWR0101" H 2850 4600 50 0001 C CNN
|
||||
F 1 "+3.3V" V 2865 4878 50 0000 L CNN
|
||||
F 2 "" H 2850 4750 50 0001 C CNN
|
||||
F 3 "" H 2850 4750 50 0001 C CNN
|
||||
1 2850 4750
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Connector:RJ45 J1
|
||||
U 1 1 62B8AC34
|
||||
P 1950 1850
|
||||
F 0 "J1" H 2007 2517 50 0000 C CNN
|
||||
F 1 "RJ45" H 2007 2426 50 0000 C CNN
|
||||
F 2 "Connector_RJ:RJ45_Amphenol_54602-x08_Horizontal" V 1950 1875 50 0001 C CNN
|
||||
F 3 "~" V 1950 1875 50 0001 C CNN
|
||||
1 1950 1850
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R4
|
||||
U 1 1 62B8CAA8
|
||||
P 2750 5150
|
||||
F 0 "R4" V 2957 5150 50 0000 C CNN
|
||||
F 1 "220" V 2866 5150 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 2680 5150 50 0001 C CNN
|
||||
F 3 "~" H 2750 5150 50 0001 C CNN
|
||||
1 2750 5150
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R2
|
||||
U 1 1 62B8DB92
|
||||
P 2500 5050
|
||||
F 0 "R2" V 2707 5050 50 0000 C CNN
|
||||
F 1 "220" V 2616 5050 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 2430 5050 50 0001 C CNN
|
||||
F 3 "~" H 2500 5050 50 0001 C CNN
|
||||
1 2500 5050
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:GND #PWR0102
|
||||
U 1 1 62B9F029
|
||||
P 1850 6050
|
||||
F 0 "#PWR0102" H 1850 5800 50 0001 C CNN
|
||||
F 1 "GND" H 1855 5877 50 0000 C CNN
|
||||
F 2 "" H 1850 6050 50 0001 C CNN
|
||||
F 3 "" H 1850 6050 50 0001 C CNN
|
||||
1 1850 6050
|
||||
-1 0 0 1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R3
|
||||
U 1 1 62B9F861
|
||||
P 2500 6300
|
||||
F 0 "R3" H 2570 6346 50 0000 L CNN
|
||||
F 1 "82k" H 2570 6255 50 0000 L CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 2430 6300 50 0001 C CNN
|
||||
F 3 "~" H 2500 6300 50 0001 C CNN
|
||||
1 2500 6300
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R1
|
||||
U 1 1 62B9FC37
|
||||
P 2250 6300
|
||||
F 0 "R1" H 2320 6346 50 0000 L CNN
|
||||
F 1 "470" H 2320 6255 50 0000 L CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 2180 6300 50 0001 C CNN
|
||||
F 3 "~" H 2250 6300 50 0001 C CNN
|
||||
1 2250 6300
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C2
|
||||
U 1 1 62BA06BE
|
||||
P 2850 6050
|
||||
F 0 "C2" V 3102 6050 50 0000 C CNN
|
||||
F 1 "1u" V 3011 6050 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 2888 5900 50 0001 C CNN
|
||||
F 3 "~" H 2850 6050 50 0001 C CNN
|
||||
1 2850 6050
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C1
|
||||
U 1 1 62BA09E7
|
||||
P 1850 6300
|
||||
F 0 "C1" H 1965 6346 50 0000 L CNN
|
||||
F 1 "100n" H 1965 6255 50 0000 L CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 1888 6150 50 0001 C CNN
|
||||
F 3 "~" H 1850 6300 50 0001 C CNN
|
||||
1 1850 6300
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
1850 6050 1850 6150
|
||||
Wire Wire Line
|
||||
2250 6050 2250 6150
|
||||
Wire Wire Line
|
||||
2500 6050 2500 6150
|
||||
Connection ~ 1850 6050
|
||||
Connection ~ 2250 6050
|
||||
Wire Wire Line
|
||||
2250 6050 2500 6050
|
||||
Wire Wire Line
|
||||
1850 6050 2250 6050
|
||||
Connection ~ 2500 6050
|
||||
Wire Wire Line
|
||||
3850 6450 3850 6350
|
||||
Wire Wire Line
|
||||
2250 6450 2250 6550
|
||||
Wire Wire Line
|
||||
3950 6550 3950 6350
|
||||
Wire Wire Line
|
||||
1850 6450 1850 6650
|
||||
Wire Wire Line
|
||||
4050 6650 4050 6350
|
||||
Wire Wire Line
|
||||
3050 6050 3000 6050
|
||||
Wire Wire Line
|
||||
2500 6050 2700 6050
|
||||
Wire Wire Line
|
||||
2700 6050 2700 6350
|
||||
Wire Wire Line
|
||||
2700 6350 3650 6350
|
||||
Connection ~ 2700 6050
|
||||
Wire Wire Line
|
||||
3850 6450 2500 6450
|
||||
Wire Wire Line
|
||||
2250 6550 3950 6550
|
||||
Wire Wire Line
|
||||
4050 6650 1850 6650
|
||||
Text GLabel 4350 5350 2 50 Output ~ 0
|
||||
HAN_TX
|
||||
Wire Wire Line
|
||||
4350 5350 4300 5350
|
||||
Wire Wire Line
|
||||
2850 4750 3550 4750
|
||||
$Comp
|
||||
L Device:R R5
|
||||
U 1 1 62BED413
|
||||
P 4650 4550
|
||||
F 0 "R5" V 4857 4550 50 0000 C CNN
|
||||
F 1 "100k" V 4766 4550 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 4580 4550 50 0001 C CNN
|
||||
F 3 "~" H 4650 4550 50 0001 C CNN
|
||||
1 4650 4550
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C3
|
||||
U 1 1 62BED9ED
|
||||
P 4650 4900
|
||||
F 0 "C3" V 4902 4900 50 0000 C CNN
|
||||
F 1 "100n" V 4811 4900 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4688 4750 50 0001 C CNN
|
||||
F 3 "~" H 4650 4900 50 0001 C CNN
|
||||
1 4650 4900
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:GND #PWR0103
|
||||
U 1 1 62BF4151
|
||||
P 4800 5050
|
||||
F 0 "#PWR0103" H 4800 4800 50 0001 C CNN
|
||||
F 1 "GND" H 4805 4877 50 0000 C CNN
|
||||
F 2 "" H 4800 5050 50 0001 C CNN
|
||||
F 3 "" H 4800 5050 50 0001 C CNN
|
||||
1 4800 5050
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
4800 4550 4800 4900
|
||||
Wire Wire Line
|
||||
4800 4900 4800 5050
|
||||
Connection ~ 4800 4900
|
||||
Wire Wire Line
|
||||
4500 4900 4500 4550
|
||||
Wire Wire Line
|
||||
4500 4550 3650 4550
|
||||
Wire Wire Line
|
||||
3650 4550 3650 4750
|
||||
Connection ~ 4500 4550
|
||||
Wire Notes Line
|
||||
1500 4050 5050 4050
|
||||
Wire Notes Line
|
||||
5050 4050 5050 6850
|
||||
Wire Notes Line
|
||||
5050 6850 1500 6850
|
||||
Wire Notes Line
|
||||
1500 6850 1500 4050
|
||||
Wire Notes Line
|
||||
7550 950 10200 950
|
||||
Wire Notes Line
|
||||
10200 950 10200 2750
|
||||
Wire Notes Line
|
||||
10200 2750 7550 2750
|
||||
Wire Notes Line
|
||||
7550 2750 7550 950
|
||||
Text GLabel 9800 1700 2 50 Input ~ 0
|
||||
HAN_TX
|
||||
Wire Wire Line
|
||||
9800 1700 9600 1700
|
||||
$Comp
|
||||
L power:+3V3 #PWR0104
|
||||
U 1 1 62C0EBC2
|
||||
P 9850 1500
|
||||
F 0 "#PWR0104" H 9850 1350 50 0001 C CNN
|
||||
F 1 "+3V3" V 9865 1628 50 0000 L CNN
|
||||
F 2 "" H 9850 1500 50 0001 C CNN
|
||||
F 3 "" H 9850 1500 50 0001 C CNN
|
||||
1 9850 1500
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
9850 1500 9600 1500
|
||||
Text GLabel 9800 1800 2 50 Output ~ 0
|
||||
LED_R
|
||||
Text GLabel 9800 1900 2 50 Output ~ 0
|
||||
LED_G
|
||||
Wire Wire Line
|
||||
9800 1800 9600 1800
|
||||
Wire Wire Line
|
||||
9800 1900 9600 1900
|
||||
$Comp
|
||||
L power:GND #PWR0105
|
||||
U 1 1 62C13452
|
||||
P 7850 1600
|
||||
F 0 "#PWR0105" H 7850 1350 50 0001 C CNN
|
||||
F 1 "GND" V 7855 1472 50 0000 R CNN
|
||||
F 2 "" H 7850 1600 50 0001 C CNN
|
||||
F 3 "" H 7850 1600 50 0001 C CNN
|
||||
1 7850 1600
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
8100 1600 7850 1600
|
||||
Text GLabel 7950 1800 0 50 Input ~ 0
|
||||
BTN_AP
|
||||
Wire Wire Line
|
||||
8100 1800 7950 1800
|
||||
Text GLabel 7950 1900 0 50 Input ~ 0
|
||||
TEMP
|
||||
Wire Wire Line
|
||||
8100 1900 7950 1900
|
||||
Wire Wire Line
|
||||
3050 5150 2900 5150
|
||||
Wire Wire Line
|
||||
3050 5050 2650 5050
|
||||
Text GLabel 2200 5050 0 50 Input ~ 0
|
||||
MBUS1
|
||||
Text GLabel 2200 5150 0 50 Input ~ 0
|
||||
MBUS2
|
||||
Wire Wire Line
|
||||
2350 5050 2200 5050
|
||||
Wire Wire Line
|
||||
2600 5150 2200 5150
|
||||
Text GLabel 2500 2150 2 50 Output ~ 0
|
||||
MBUS1
|
||||
Text GLabel 2500 2050 2 50 Output ~ 0
|
||||
MBUS2
|
||||
Wire Wire Line
|
||||
2500 2050 2350 2050
|
||||
Wire Wire Line
|
||||
2350 2150 2500 2150
|
||||
$Comp
|
||||
L Device:Jumper JP1
|
||||
U 1 1 62C331C0
|
||||
P 3300 1250
|
||||
F 0 "JP1" H 3300 1514 50 0000 C CNN
|
||||
F 1 "Jumper" H 3300 1423 50 0000 C CNN
|
||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm" H 3300 1250 50 0001 C CNN
|
||||
F 3 "~" H 3300 1250 50 0001 C CNN
|
||||
1 3300 1250
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:Jumper JP2
|
||||
U 1 1 62C365CA
|
||||
P 3300 1850
|
||||
F 0 "JP2" H 3300 2114 50 0000 C CNN
|
||||
F 1 "Jumper" H 3300 2023 50 0000 C CNN
|
||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm" H 3300 1850 50 0001 C CNN
|
||||
F 3 "~" H 3300 1850 50 0001 C CNN
|
||||
1 3300 1850
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:Jumper JP3
|
||||
U 1 1 62C36C70
|
||||
P 3300 2200
|
||||
F 0 "JP3" H 3300 2464 50 0000 C CNN
|
||||
F 1 "Jumper" H 3300 2373 50 0000 C CNN
|
||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm" H 3300 2200 50 0001 C CNN
|
||||
F 3 "~" H 3300 2200 50 0001 C CNN
|
||||
1 3300 2200
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
3000 1850 2900 1850
|
||||
Wire Wire Line
|
||||
2900 1850 2900 1750
|
||||
Wire Wire Line
|
||||
2350 1750 2900 1750
|
||||
Wire Wire Line
|
||||
2350 1850 2850 1850
|
||||
Wire Wire Line
|
||||
2850 1850 2850 2200
|
||||
Wire Wire Line
|
||||
2850 2200 3000 2200
|
||||
$Comp
|
||||
L power:GND #PWR0107
|
||||
U 1 1 62C3D94F
|
||||
P 3750 1850
|
||||
F 0 "#PWR0107" H 3750 1600 50 0001 C CNN
|
||||
F 1 "GND" V 3755 1722 50 0000 R CNN
|
||||
F 2 "" H 3750 1850 50 0001 C CNN
|
||||
F 3 "" H 3750 1850 50 0001 C CNN
|
||||
1 3750 1850
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
Text GLabel 3750 2200 2 50 Output ~ 0
|
||||
TEMP
|
||||
Wire Wire Line
|
||||
3750 1850 3600 1850
|
||||
Wire Wire Line
|
||||
3750 2200 3600 2200
|
||||
Wire Notes Line
|
||||
1450 950 4350 950
|
||||
Wire Notes Line
|
||||
4350 950 4350 2450
|
||||
Wire Notes Line
|
||||
4350 2450 1450 2450
|
||||
Wire Notes Line
|
||||
1450 2450 1450 950
|
||||
$Comp
|
||||
L Device:LED_RGB D1
|
||||
U 1 1 62C43A7B
|
||||
P 9550 4800
|
||||
F 0 "D1" H 9550 5297 50 0000 C CNN
|
||||
F 1 "LED_RGB" H 9550 5206 50 0000 C CNN
|
||||
F 2 "LED_SMD:LED_RGB_PLCC-6" H 9550 4750 50 0001 C CNN
|
||||
F 3 "~" H 9550 4750 50 0001 C CNN
|
||||
1 9550 4800
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:+3.3V #PWR0108
|
||||
U 1 1 62C44A94
|
||||
P 10000 4800
|
||||
F 0 "#PWR0108" H 10000 4650 50 0001 C CNN
|
||||
F 1 "+3.3V" V 10015 4928 50 0000 L CNN
|
||||
F 2 "" H 10000 4800 50 0001 C CNN
|
||||
F 3 "" H 10000 4800 50 0001 C CNN
|
||||
1 10000 4800
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
9750 4800 9900 4800
|
||||
Wire Wire Line
|
||||
9750 4600 9900 4600
|
||||
Wire Wire Line
|
||||
9900 4600 9900 4800
|
||||
Connection ~ 9900 4800
|
||||
Wire Wire Line
|
||||
9900 4800 10000 4800
|
||||
Wire Wire Line
|
||||
9900 4800 9900 5000
|
||||
Wire Wire Line
|
||||
9900 5000 9750 5000
|
||||
$Comp
|
||||
L Device:R R9
|
||||
U 1 1 62C495F7
|
||||
P 9100 4600
|
||||
F 0 "R9" V 9307 4600 50 0000 C CNN
|
||||
F 1 "1k" V 9216 4600 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 9030 4600 50 0001 C CNN
|
||||
F 3 "~" H 9100 4600 50 0001 C CNN
|
||||
1 9100 4600
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R8
|
||||
U 1 1 62C4BDE9
|
||||
P 8850 4800
|
||||
F 0 "R8" V 9057 4800 50 0000 C CNN
|
||||
F 1 "1k" V 8966 4800 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 8780 4800 50 0001 C CNN
|
||||
F 3 "~" H 8850 4800 50 0001 C CNN
|
||||
1 8850 4800
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R10
|
||||
U 1 1 62C4C336
|
||||
P 9100 5000
|
||||
F 0 "R10" V 9307 5000 50 0000 C CNN
|
||||
F 1 "1k" V 9216 5000 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 9030 5000 50 0001 C CNN
|
||||
F 3 "~" H 9100 5000 50 0001 C CNN
|
||||
1 9100 5000
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
9350 4600 9250 4600
|
||||
Wire Wire Line
|
||||
9350 4800 9000 4800
|
||||
Wire Wire Line
|
||||
9350 5000 9250 5000
|
||||
Text GLabel 8650 4600 0 50 Input ~ 0
|
||||
LED_R
|
||||
Text GLabel 8650 4800 0 50 Input ~ 0
|
||||
LED_G
|
||||
Text GLabel 8650 5000 0 50 Input ~ 0
|
||||
LED_B
|
||||
Wire Wire Line
|
||||
8700 4800 8650 4800
|
||||
Wire Wire Line
|
||||
8950 4600 8650 4600
|
||||
Wire Wire Line
|
||||
8950 5000 8650 5000
|
||||
Wire Notes Line
|
||||
8200 4050 10550 4050
|
||||
Wire Notes Line
|
||||
10550 4050 10550 5400
|
||||
Wire Notes Line
|
||||
10550 5400 8200 5400
|
||||
Wire Notes Line
|
||||
8200 5400 8200 4050
|
||||
$Comp
|
||||
L Sensor_Temperature:DS18B20 U2
|
||||
U 1 1 62C6296F
|
||||
P 6600 4900
|
||||
F 0 "U2" H 6370 4946 50 0000 R CNN
|
||||
F 1 "DS18B20" H 6370 4855 50 0000 R CNN
|
||||
F 2 "Package_TO_SOT_THT:TO-92_Inline" H 5600 4650 50 0001 C CNN
|
||||
F 3 "http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf" H 6450 5150 50 0001 C CNN
|
||||
1 6600 4900
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:GND #PWR0109
|
||||
U 1 1 62C6373E
|
||||
P 6600 5350
|
||||
F 0 "#PWR0109" H 6600 5100 50 0001 C CNN
|
||||
F 1 "GND" H 6605 5177 50 0000 C CNN
|
||||
F 2 "" H 6600 5350 50 0001 C CNN
|
||||
F 3 "" H 6600 5350 50 0001 C CNN
|
||||
1 6600 5350
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:+3.3V #PWR0110
|
||||
U 1 1 62C63C02
|
||||
P 6600 4450
|
||||
F 0 "#PWR0110" H 6600 4300 50 0001 C CNN
|
||||
F 1 "+3.3V" H 6615 4623 50 0000 C CNN
|
||||
F 2 "" H 6600 4450 50 0001 C CNN
|
||||
F 3 "" H 6600 4450 50 0001 C CNN
|
||||
1 6600 4450
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R7
|
||||
U 1 1 62C6405D
|
||||
P 6900 4600
|
||||
F 0 "R7" H 6970 4646 50 0000 L CNN
|
||||
F 1 "4k7" H 6970 4555 50 0000 L CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 6830 4600 50 0001 C CNN
|
||||
F 3 "~" H 6900 4600 50 0001 C CNN
|
||||
1 6900 4600
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
6600 5200 6600 5350
|
||||
Wire Wire Line
|
||||
6600 4600 6600 4450
|
||||
Wire Wire Line
|
||||
6900 4900 6900 4750
|
||||
Wire Wire Line
|
||||
6900 4450 6600 4450
|
||||
Connection ~ 6600 4450
|
||||
Text GLabel 7050 4900 2 50 Output ~ 0
|
||||
TEMP
|
||||
Wire Wire Line
|
||||
7050 4900 6900 4900
|
||||
Connection ~ 6900 4900
|
||||
Wire Notes Line
|
||||
5750 4050 7500 4050
|
||||
Wire Notes Line
|
||||
7500 4050 7500 5750
|
||||
Wire Notes Line
|
||||
7500 5750 5750 5750
|
||||
Wire Notes Line
|
||||
5750 5750 5750 4050
|
||||
$Comp
|
||||
L Switch:SW_Push SW1
|
||||
U 1 1 62C73229
|
||||
P 5950 1400
|
||||
F 0 "SW1" H 5950 1685 50 0000 C CNN
|
||||
F 1 "SW_Push" H 5950 1594 50 0000 C CNN
|
||||
F 2 "Button_Switch_SMD:SW_SPST_B3U-3000P" H 5950 1600 50 0001 C CNN
|
||||
F 3 "~" H 5950 1600 50 0001 C CNN
|
||||
1 5950 1400
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R6
|
||||
U 1 1 62C73CE8
|
||||
P 5950 1700
|
||||
F 0 "R6" V 6157 1700 50 0000 C CNN
|
||||
F 1 "10k" V 6066 1700 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 5880 1700 50 0001 C CNN
|
||||
F 3 "~" H 5950 1700 50 0001 C CNN
|
||||
1 5950 1700
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:GND #PWR0111
|
||||
U 1 1 62C76961
|
||||
P 6350 1400
|
||||
F 0 "#PWR0111" H 6350 1150 50 0001 C CNN
|
||||
F 1 "GND" V 6355 1272 50 0000 R CNN
|
||||
F 2 "" H 6350 1400 50 0001 C CNN
|
||||
F 3 "" H 6350 1400 50 0001 C CNN
|
||||
1 6350 1400
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L power:+3.3V #PWR0112
|
||||
U 1 1 62C776AD
|
||||
P 6350 1700
|
||||
F 0 "#PWR0112" H 6350 1550 50 0001 C CNN
|
||||
F 1 "+3.3V" V 6365 1828 50 0000 L CNN
|
||||
F 2 "" H 6350 1700 50 0001 C CNN
|
||||
F 3 "" H 6350 1700 50 0001 C CNN
|
||||
1 6350 1700
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
6350 1400 6150 1400
|
||||
Wire Wire Line
|
||||
6350 1700 6100 1700
|
||||
Wire Wire Line
|
||||
5750 1400 5550 1400
|
||||
Wire Wire Line
|
||||
5550 1400 5550 1550
|
||||
Wire Wire Line
|
||||
5550 1700 5800 1700
|
||||
Text GLabel 5450 1550 0 50 Output ~ 0
|
||||
BTN_AP
|
||||
Wire Wire Line
|
||||
5450 1550 5550 1550
|
||||
Connection ~ 5550 1550
|
||||
Wire Wire Line
|
||||
5550 1550 5550 1700
|
||||
Wire Notes Line
|
||||
5000 950 6850 950
|
||||
Wire Notes Line
|
||||
6850 950 6850 1950
|
||||
Wire Notes Line
|
||||
6850 1950 5000 1950
|
||||
Wire Notes Line
|
||||
5000 1950 5000 950
|
||||
Text GLabel 4350 5450 2 50 Output ~ 0
|
||||
LED_B
|
||||
Wire Wire Line
|
||||
4350 5450 4300 5450
|
||||
Wire Wire Line
|
||||
4300 5450 4300 5350
|
||||
Connection ~ 4300 5350
|
||||
Wire Wire Line
|
||||
4300 5350 4250 5350
|
||||
$Comp
|
||||
L power:+5V #PWR0106
|
||||
U 1 1 62D05402
|
||||
P 7850 1500
|
||||
F 0 "#PWR0106" H 7850 1350 50 0001 C CNN
|
||||
F 1 "+5V" V 7865 1628 50 0000 L CNN
|
||||
F 2 "" H 7850 1500 50 0001 C CNN
|
||||
F 3 "" H 7850 1500 50 0001 C CNN
|
||||
1 7850 1500
|
||||
0 -1 -1 0
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
8100 1500 7850 1500
|
||||
$Comp
|
||||
L power:+5V #PWR0113
|
||||
U 1 1 62D0B1E1
|
||||
P 3750 1250
|
||||
F 0 "#PWR0113" H 3750 1100 50 0001 C CNN
|
||||
F 1 "+5V" V 3765 1378 50 0000 L CNN
|
||||
F 2 "" H 3750 1250 50 0001 C CNN
|
||||
F 3 "" H 3750 1250 50 0001 C CNN
|
||||
1 3750 1250
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:Jumper JP4
|
||||
U 1 1 62D1E97A
|
||||
P 3300 1550
|
||||
F 0 "JP4" H 3300 1814 50 0000 C CNN
|
||||
F 1 "Jumper" H 3300 1723 50 0000 C CNN
|
||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm" H 3300 1550 50 0001 C CNN
|
||||
F 3 "~" H 3300 1550 50 0001 C CNN
|
||||
1 3300 1550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Wire Wire Line
|
||||
3000 1250 2350 1250
|
||||
Wire Wire Line
|
||||
2350 1250 2350 1450
|
||||
Wire Wire Line
|
||||
3600 1250 3750 1250
|
||||
Wire Wire Line
|
||||
3600 1550 3600 1850
|
||||
Connection ~ 3600 1850
|
||||
Wire Wire Line
|
||||
2350 1550 3000 1550
|
||||
$EndSCHEMATC
|
||||
75272
hardware/wemos_mbus_shield/kicad/fp-info-cache
Normal file
3
hardware/wemos_mbus_shield/kicad/fp-lib-table
Normal file
@@ -0,0 +1,3 @@
|
||||
(fp_lib_table
|
||||
(lib (name D1_mini)(type KiCad)(uri "$(KIPRJMOD)/lib/D1_mini.pretty")(options "")(descr ""))
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
(module Pin_Headers:Pin_Header_Straight_1x08 (layer F.Cu) (tedit 5766A5B6)
|
||||
(descr "Through hole pin header")
|
||||
(tags "pin header")
|
||||
(fp_text reference P1 (at 0.11176 -2.43586) (layer F.SilkS)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value CONN_01X08 (at 0 -3.1) (layer F.Fab) hide
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_line (start -1.75 -1.75) (end -1.75 19.55) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 1.75 -1.75) (end 1.75 19.55) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -1.75 -1.75) (end 1.75 -1.75) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -1.75 19.55) (end 1.75 19.55) (layer F.CrtYd) (width 0.05))
|
||||
(pad 1 thru_hole rect (at 0 0) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 2 thru_hole oval (at 0 2.54) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 3 thru_hole oval (at 0 5.08) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 4 thru_hole oval (at 0 7.62) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 5 thru_hole oval (at 0 10.16) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 6 thru_hole oval (at 0 12.7) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 7 thru_hole oval (at 0 15.24) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(pad 8 thru_hole oval (at 0 17.78) (size 1.8 1.8) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
|
||||
(model Pin_Headers.3dshapes/Pin_Header_Straight_1x08.wrl
|
||||
(at (xyz 0 -0.35 0))
|
||||
(scale (xyz 1 1 1))
|
||||
(rotate (xyz 0 0 90))
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
(module OSHW (layer F.Cu) (tedit 5766B04E)
|
||||
(descr OSHW)
|
||||
(tags "Symbol, OSHW-Logo, Silk Screen,")
|
||||
(fp_text reference "" (at 0.09906 -4.38912) (layer F.SilkS) hide
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value OSHW (at 0 5) (layer F.Fab) hide
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_line (start -1.78054 0.92964) (end -2.03962 1.49098) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -2.03962 1.49098) (end -1.50114 2.00914) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -1.50114 2.00914) (end -0.98044 1.7399) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.98044 1.7399) (end -0.70104 1.89992) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.73914 1.8796) (end 1.06934 1.6891) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.06934 1.6891) (end 1.50876 2.0193) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.50876 2.0193) (end 1.9812 1.52908) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.9812 1.52908) (end 1.69926 1.04902) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.69926 1.04902) (end 1.88976 0.57912) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.88976 0.57912) (end 2.49936 0.39116) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 2.49936 0.39116) (end 2.49936 -0.28956) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 2.49936 -0.28956) (end 1.94056 -0.42926) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.94056 -0.42926) (end 1.7399 -1.00076) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.7399 -1.00076) (end 2.00914 -1.47066) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 2.00914 -1.47066) (end 1.53924 -1.9812) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.53924 -1.9812) (end 1.02108 -1.71958) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.02108 -1.71958) (end 0.55118 -1.92024) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.55118 -1.92024) (end 0.381 -2.46126) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.381 -2.46126) (end -0.30988 -2.47904) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.30988 -2.47904) (end -0.5207 -1.9304) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.5207 -1.9304) (end -0.9398 -1.76022) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.9398 -1.76022) (end -1.49098 -2.02946) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -1.49098 -2.02946) (end -2.00914 -1.50114) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -2.00914 -1.50114) (end -1.76022 -0.96012) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -1.76022 -0.96012) (end -1.9304 -0.48006) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -1.9304 -0.48006) (end -2.47904 -0.381) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -2.47904 -0.381) (end -2.4892 0.32004) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -2.4892 0.32004) (end -1.9304 0.5207) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -1.9304 0.5207) (end -1.7907 0.91948) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.35052 0.89916) (end 0.65024 0.7493) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.65024 0.7493) (end 0.8509 0.55118) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.8509 0.55118) (end 1.00076 0.14986) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.00076 0.14986) (end 1.00076 -0.24892) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 1.00076 -0.24892) (end 0.8509 -0.59944) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.8509 -0.59944) (end 0.39878 -0.94996) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.39878 -0.94996) (end -0.0508 -1.00076) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.0508 -1.00076) (end -0.44958 -0.89916) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.44958 -0.89916) (end -0.8509 -0.55118) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.8509 -0.55118) (end -1.00076 -0.09906) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -1.00076 -0.09906) (end -0.94996 0.39878) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.94996 0.39878) (end -0.70104 0.70104) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.70104 0.70104) (end -0.35052 0.89916) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start -0.35052 0.89916) (end -0.70104 1.89992) (layer F.SilkS) (width 0.15))
|
||||
(fp_line (start 0.35052 0.89916) (end 0.7493 1.89992) (layer F.SilkS) (width 0.15))
|
||||
)
|
||||
BIN
hardware/wemos_mbus_shield/kicad/meta/brd.png
Normal file
|
After Width: | Height: | Size: 198 KiB |
BIN
hardware/wemos_mbus_shield/kicad/meta/icon.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
21
hardware/wemos_mbus_shield/kicad/meta/info.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<title>D1Shield</title>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<P>This project template is the basis of an expansion board for the
|
||||
<A HREF="https://www.wemos.cc/en/latest/d1/d1_mini.html" TARGET="blank">D1 mini board</A>.
|
||||
<BR><BR>This base project includes a PCB edge defined
|
||||
as the same size as the D1 mini PCB with the connectors placed
|
||||
correctly to align the two boards. All IO present on the D1 mini
|
||||
board is connected to the project through the expansion
|
||||
headers. <BR><BR>The board looks like the following:
|
||||
</P>
|
||||
<P><IMG SRC="brd.png">
|
||||
</P>
|
||||
<p><i>Dwgs.User</i> layer show mechanical components of the D1mini board.</p>
|
||||
<P>©2016 Jérôme Labidurie<br/>
|
||||
Licence: <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC:BY-SA 3.0</a><br/>
|
||||
<a href="http://dinask.eu">dinask.eu</a></P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
4
hardware/wemos_mbus_shield/kicad/sym-lib-table
Normal file
@@ -0,0 +1,4 @@
|
||||
(sym_lib_table
|
||||
(lib (name d1_mini_shield-rescue)(type Legacy)(uri ${KIPRJMOD}/d1_mini_shield-rescue.lib)(options "")(descr ""))
|
||||
(lib (name tss721)(type Legacy)(uri ${KIPRJMOD}/tss721.lib)(options "")(descr ""))
|
||||
)
|
||||
9
hardware/wemos_mbus_shield/kicad/tss721.dcm
Normal file
@@ -0,0 +1,9 @@
|
||||
EESchema-DOCLIB Version 2.0
|
||||
#
|
||||
$CMP TSS721
|
||||
D TSS721A Meter Bus Transceiver, SOIC-16/TSSOP-16
|
||||
K MBUS Tranciever
|
||||
F http://www.ti.com/lit/ds/symlink/tss721a.pdf
|
||||
$ENDCMP
|
||||
#
|
||||
#End Doc Library
|
||||
37
hardware/wemos_mbus_shield/kicad/tss721.lib
Normal file
@@ -0,0 +1,37 @@
|
||||
EESchema-LIBRARY Version 2.4
|
||||
#encoding utf-8
|
||||
#
|
||||
# TSS721
|
||||
#
|
||||
DEF TSS721 U 0 40 Y Y 1 F N
|
||||
F0 "U" 200 850 50 H V L CNN
|
||||
F1 "TSS721" 200 750 50 H V L CNN
|
||||
F2 "" 0 -850 50 H V C CIN
|
||||
F3 "" -200 -800 50 H V C CNN
|
||||
ALIAS TSS721A
|
||||
$FPLIST
|
||||
SOIC*3.9x9.9mm*Pitch1.27mm*
|
||||
TSSOP*4.4x5mm*Pitch0.65mm*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -500 -700 500 700 0 1 10 f
|
||||
X BUSL2 1 -600 400 100 R 50 50 1 1 I
|
||||
X VS 10 -600 0 100 R 50 50 1 1 P
|
||||
X VDD 11 0 800 100 D 50 50 1 1 W
|
||||
X RX 12 600 500 100 L 50 50 1 1 I
|
||||
X RXI 13 600 400 100 L 50 50 1 1 I I
|
||||
X RIS 14 300 -800 100 U 50 50 1 1 I
|
||||
X GND 15 0 -800 100 U 50 50 1 1 W
|
||||
X BUSL1 16 -600 500 100 R 50 50 1 1 I
|
||||
X VB 2 -600 -150 100 R 50 50 1 1 P
|
||||
X STC 3 -600 -500 100 R 50 50 1 1 P
|
||||
X RIDD 4 200 -800 100 U 50 50 1 1 O
|
||||
X PF 5 -600 100 100 R 50 50 1 1 I
|
||||
X SC 6 400 -800 100 U 50 50 1 1 P
|
||||
X TXI 7 600 100 100 L 50 50 1 1 O I
|
||||
X TX 8 600 200 100 L 50 50 1 1 O
|
||||
X BAT 9 -100 800 100 D 50 50 1 1 I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
#End Library
|
||||
BIN
images/dashboard.png
Normal file
|
After Width: | Height: | Size: 173 KiB |
BIN
images/dayplot.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
images/future-energy-price.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
images/main-header.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
images/monthplot.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
images/real-time-calculation.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
images/sensor-displays.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
images/tempsensors.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
363
lib/AmsConfiguration/include/AmsConfiguration.h
Normal file
@@ -0,0 +1,363 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AMSCONFIGURATION_h
|
||||
#define _AMSCONFIGURATION_h
|
||||
#include <EEPROM.h>
|
||||
#include "Arduino.h"
|
||||
|
||||
#define EEPROM_SIZE 1024*3
|
||||
#define EEPROM_CHECK_SUM 104 // Used to check if config is stored. Change if structure changes
|
||||
#define EEPROM_CLEARED_INDICATOR 0xFC
|
||||
#define EEPROM_CONFIG_ADDRESS 0
|
||||
#define EEPROM_TEMP_CONFIG_ADDRESS 2048
|
||||
|
||||
#define CONFIG_SYSTEM_START 8
|
||||
#define CONFIG_UPGRADE_INFO_START 16
|
||||
#define CONFIG_NETWORK_START 40
|
||||
#define CONFIG_METER_START 296
|
||||
#define CONFIG_GPIO_START 368
|
||||
#define CONFIG_PRICE_START 400
|
||||
#define CONFIG_ENERGYACCOUNTING_START 472
|
||||
#define CONFIG_WEB_START 496
|
||||
#define CONFIG_DEBUG_START 632
|
||||
#define CONFIG_NTP_START 640
|
||||
#define CONFIG_MQTT_START 768
|
||||
#define CONFIG_DOMOTICZ_START 1536
|
||||
#define CONFIG_HA_START 1552
|
||||
#define CONFIG_UI_START 1720
|
||||
#define CONFIG_CLOUD_START 1742
|
||||
|
||||
#define CONFIG_METER_START_103 32
|
||||
#define CONFIG_UPGRADE_INFO_START_103 216
|
||||
#define CONFIG_UI_START_103 248
|
||||
#define CONFIG_GPIO_START_103 266
|
||||
#define CONFIG_ENTSOE_START_103 290
|
||||
#define CONFIG_WIFI_START_103 360
|
||||
#define CONFIG_ENERGYACCOUNTING_START_103 576
|
||||
#define CONFIG_WEB_START_103 648
|
||||
#define CONFIG_DEBUG_START_103 824
|
||||
#define CONFIG_DOMOTICZ_START_103 856
|
||||
#define CONFIG_NTP_START_103 872
|
||||
#define CONFIG_MQTT_START_103 1004
|
||||
#define CONFIG_HA_START_103 1680
|
||||
|
||||
#define LED_BEHAVIOUR_DEFAULT 0
|
||||
#define LED_BEHAVIOUR_BOOT 1
|
||||
#define LED_BEHAVIOUR_ERROR_ONLY 3
|
||||
#define LED_BEHAVIOUR_OFF 9
|
||||
|
||||
struct ResetDataContainer {
|
||||
uint8_t cause;
|
||||
uint8_t last_cause;
|
||||
uint8_t magic;
|
||||
};
|
||||
|
||||
struct SystemConfig {
|
||||
uint8_t boardType;
|
||||
bool vendorConfigured;
|
||||
bool userConfigured;
|
||||
uint8_t dataCollectionConsent; // 0 = unknown, 1 = accepted, 2 = declined
|
||||
char country[3];
|
||||
uint8_t energyspeedometer;
|
||||
}; // 9
|
||||
|
||||
struct NetworkConfig {
|
||||
char ssid[32];
|
||||
char psk[64];
|
||||
char ip[16];
|
||||
char gateway[16];
|
||||
char subnet[16];
|
||||
char dns1[16];
|
||||
char dns2[16];
|
||||
char hostname[32];
|
||||
bool mdns;
|
||||
uint8_t power;
|
||||
uint8_t sleep;
|
||||
uint8_t use11b;
|
||||
bool ipv6;
|
||||
uint8_t mode;
|
||||
}; // 214
|
||||
|
||||
struct MqttConfig {
|
||||
char host[128];
|
||||
uint16_t port;
|
||||
char clientId[32];
|
||||
char publishTopic[64];
|
||||
char subscribeTopic[64];
|
||||
char username[128];
|
||||
char password[256];
|
||||
uint8_t payloadFormat;
|
||||
bool ssl;
|
||||
}; // 676
|
||||
|
||||
struct WebConfig {
|
||||
uint8_t security;
|
||||
char username[37];
|
||||
char password[37];
|
||||
char context[37];
|
||||
}; // 112
|
||||
|
||||
struct WebConfig103 {
|
||||
uint8_t security;
|
||||
char username[64];
|
||||
char password[64];
|
||||
}; // 129
|
||||
|
||||
struct MeterConfig {
|
||||
uint32_t baud;
|
||||
uint8_t parity;
|
||||
bool invert;
|
||||
uint8_t distributionSystem;
|
||||
uint16_t mainFuse;
|
||||
uint16_t productionCapacity;
|
||||
uint8_t encryptionKey[16];
|
||||
uint8_t authenticationKey[16];
|
||||
uint32_t wattageMultiplier;
|
||||
uint32_t voltageMultiplier;
|
||||
uint32_t amperageMultiplier;
|
||||
uint32_t accumulatedMultiplier;
|
||||
uint8_t source;
|
||||
uint8_t parser;
|
||||
uint8_t bufferSize;
|
||||
uint8_t rxPin;
|
||||
bool rxPinPullup;
|
||||
uint8_t txPin;
|
||||
}; // 65
|
||||
|
||||
struct DebugConfig {
|
||||
bool telnet;
|
||||
bool serial;
|
||||
uint8_t level;
|
||||
}; // 3
|
||||
|
||||
struct GpioConfig {
|
||||
uint8_t apPin;
|
||||
uint8_t ledPin;
|
||||
bool ledInverted;
|
||||
uint8_t ledPinRed;
|
||||
uint8_t ledPinGreen;
|
||||
uint8_t ledPinBlue;
|
||||
bool ledRgbInverted;
|
||||
uint8_t tempSensorPin;
|
||||
uint8_t tempAnalogSensorPin;
|
||||
uint8_t vccPin;
|
||||
int16_t vccOffset;
|
||||
uint16_t vccMultiplier;
|
||||
uint8_t vccBootLimit;
|
||||
uint16_t vccResistorGnd;
|
||||
uint16_t vccResistorVcc;
|
||||
uint8_t ledDisablePin;
|
||||
uint8_t ledBehaviour;
|
||||
}; // 21
|
||||
|
||||
struct GpioConfig103 {
|
||||
uint8_t hanPin;
|
||||
uint8_t apPin;
|
||||
uint8_t ledPin;
|
||||
bool ledInverted;
|
||||
uint8_t ledPinRed;
|
||||
uint8_t ledPinGreen;
|
||||
uint8_t ledPinBlue;
|
||||
bool ledRgbInverted;
|
||||
uint8_t tempSensorPin;
|
||||
uint8_t tempAnalogSensorPin;
|
||||
uint8_t vccPin;
|
||||
int16_t vccOffset;
|
||||
uint16_t vccMultiplier;
|
||||
uint8_t vccBootLimit;
|
||||
uint16_t vccResistorGnd;
|
||||
uint16_t vccResistorVcc;
|
||||
bool hanPinPullup;
|
||||
uint8_t ledDisablePin;
|
||||
uint8_t ledBehaviour;
|
||||
}; // 23
|
||||
|
||||
struct DomoticzConfig {
|
||||
uint16_t elidx;
|
||||
uint16_t vl1idx;
|
||||
uint16_t vl2idx;
|
||||
uint16_t vl3idx;
|
||||
uint16_t cl1idx;
|
||||
}; // 10
|
||||
|
||||
struct HomeAssistantConfig {
|
||||
char discoveryPrefix[64];
|
||||
char discoveryHostname[64];
|
||||
char discoveryNameTag[16];
|
||||
}; // 145
|
||||
|
||||
struct NtpConfig {
|
||||
bool enable;
|
||||
bool dhcp;
|
||||
char server[64];
|
||||
char timezone[32];
|
||||
}; // 98
|
||||
|
||||
struct PriceServiceConfig {
|
||||
char entsoeToken[37];
|
||||
char area[17];
|
||||
char currency[4];
|
||||
uint32_t unused1;
|
||||
bool enabled;
|
||||
uint16_t unused2;
|
||||
}; // 64
|
||||
|
||||
struct EnergyAccountingConfig {
|
||||
uint16_t thresholds[10];
|
||||
uint8_t hours;
|
||||
}; // 21
|
||||
|
||||
struct EnergyAccountingConfig101 {
|
||||
uint8_t thresholds[10];
|
||||
uint8_t hours;
|
||||
}; // 11
|
||||
|
||||
struct UiConfig {
|
||||
uint8_t showImport;
|
||||
uint8_t showExport;
|
||||
uint8_t showVoltage;
|
||||
uint8_t showAmperage;
|
||||
uint8_t showReactive;
|
||||
uint8_t showRealtime;
|
||||
uint8_t showPeaks;
|
||||
uint8_t showPricePlot;
|
||||
uint8_t showDayPlot;
|
||||
uint8_t showMonthPlot;
|
||||
uint8_t showTemperaturePlot;
|
||||
uint8_t showRealtimePlot;
|
||||
uint8_t showPerPhasePower;
|
||||
uint8_t showPowerFactor;
|
||||
uint8_t darkMode;
|
||||
char language[3];
|
||||
}; // 15
|
||||
|
||||
struct UpgradeInformation {
|
||||
char fromVersion[8];
|
||||
char toVersion[8];
|
||||
int16_t exitCode;
|
||||
int16_t errorCode;
|
||||
}; // 20
|
||||
|
||||
struct CloudConfig {
|
||||
bool enabled;
|
||||
uint8_t interval;
|
||||
char hostname[64];
|
||||
uint16_t port;
|
||||
uint8_t clientId[16];
|
||||
}; // 69
|
||||
|
||||
class AmsConfiguration {
|
||||
public:
|
||||
bool hasConfig();
|
||||
int getConfigVersion();
|
||||
|
||||
bool save();
|
||||
|
||||
bool getSystemConfig(SystemConfig&);
|
||||
bool setSystemConfig(SystemConfig&);
|
||||
bool isSystemConfigChanged();
|
||||
void ackSystemConfigChanged();
|
||||
|
||||
bool getNetworkConfig(NetworkConfig&);
|
||||
bool setNetworkConfig(NetworkConfig&);
|
||||
void clearNetworkConfig(NetworkConfig&);
|
||||
void clearNetworkConfigIp(NetworkConfig&);
|
||||
bool isNetworkConfigChanged();
|
||||
void ackNetworkConfigChange();
|
||||
|
||||
bool getMqttConfig(MqttConfig&);
|
||||
bool setMqttConfig(MqttConfig&);
|
||||
void clearMqtt(MqttConfig&);
|
||||
void setMqttChanged();
|
||||
bool isMqttChanged();
|
||||
void ackMqttChange();
|
||||
|
||||
bool getWebConfig(WebConfig&);
|
||||
bool setWebConfig(WebConfig&);
|
||||
void clearWebConfig(WebConfig&);
|
||||
|
||||
bool getMeterConfig(MeterConfig&);
|
||||
bool setMeterConfig(MeterConfig&);
|
||||
void clearMeter(MeterConfig&);
|
||||
void setMeterChanged();
|
||||
bool isMeterChanged();
|
||||
void ackMeterChanged();
|
||||
|
||||
bool getDebugConfig(DebugConfig&);
|
||||
bool setDebugConfig(DebugConfig&);
|
||||
void clearDebug(DebugConfig&);
|
||||
|
||||
bool pinUsed(uint8_t, GpioConfig&);
|
||||
|
||||
bool getGpioConfig(GpioConfig&);
|
||||
bool setGpioConfig(GpioConfig&);
|
||||
void clearGpio(GpioConfig&);
|
||||
|
||||
void print(Print* debugger);
|
||||
|
||||
bool getDomoticzConfig(DomoticzConfig&);
|
||||
bool setDomoticzConfig(DomoticzConfig&);
|
||||
void clearDomo(DomoticzConfig&);
|
||||
|
||||
bool getHomeAssistantConfig(HomeAssistantConfig&);
|
||||
bool setHomeAssistantConfig(HomeAssistantConfig&);
|
||||
void clearHomeAssistantConfig(HomeAssistantConfig&);
|
||||
|
||||
bool getNtpConfig(NtpConfig&);
|
||||
bool setNtpConfig(NtpConfig&);
|
||||
void clearNtp(NtpConfig&);
|
||||
bool isNtpChanged();
|
||||
void ackNtpChange();
|
||||
|
||||
bool getPriceServiceConfig(PriceServiceConfig&);
|
||||
bool setPriceServiceConfig(PriceServiceConfig&);
|
||||
void clearPriceServiceConfig(PriceServiceConfig&);
|
||||
bool isPriceServiceChanged();
|
||||
void ackPriceServiceChange();
|
||||
|
||||
bool getEnergyAccountingConfig(EnergyAccountingConfig&);
|
||||
bool setEnergyAccountingConfig(EnergyAccountingConfig&);
|
||||
void clearEnergyAccountingConfig(EnergyAccountingConfig&);
|
||||
bool isEnergyAccountingChanged();
|
||||
void ackEnergyAccountingChange();
|
||||
|
||||
bool getUiConfig(UiConfig&);
|
||||
bool setUiConfig(UiConfig&);
|
||||
void clearUiConfig(UiConfig&);
|
||||
void setUiLanguageChanged();
|
||||
bool isUiLanguageChanged();
|
||||
void ackUiLanguageChange();
|
||||
|
||||
bool getUpgradeInformation(UpgradeInformation&);
|
||||
bool setUpgradeInformation(int16_t exitCode, int16_t errorCode, const char* currentVersion, const char* nextVersion);
|
||||
void clearUpgradeInformation(UpgradeInformation&);
|
||||
|
||||
bool getCloudConfig(CloudConfig&);
|
||||
bool setCloudConfig(CloudConfig&);
|
||||
void clearCloudConfig(CloudConfig&);
|
||||
bool isCloudChanged();
|
||||
void ackCloudConfig();
|
||||
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
uint8_t configVersion = 0;
|
||||
|
||||
bool sysChanged = false, networkChanged, mqttChanged, meterChanged = true, ntpChanged = true, priceChanged = false, energyAccountingChanged = true, cloudChanged = true, uiLanguageChanged = false;
|
||||
|
||||
bool relocateConfig101(); // 2.2.0 through 2.2.8
|
||||
bool relocateConfig102(); // 2.2.9 through 2.2.11
|
||||
bool relocateConfig103(); // 2.2.12, until, but not including 2.3
|
||||
|
||||
void saveToFs();
|
||||
bool loadFromFs(uint8_t version);
|
||||
void deleteFromFs(uint8_t version);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AMSSTORAGE_H
|
||||
#define _AMSSTORAGE_H
|
||||
|
||||
@@ -9,5 +15,9 @@
|
||||
|
||||
#define FILE_DAYPLOT "/dayplot.bin"
|
||||
#define FILE_MONTHPLOT "/monthplot.bin"
|
||||
#define FILE_ENERGYACCOUNTING "/energyaccounting.bin"
|
||||
|
||||
#define FILE_CFG "/configfile.cfg"
|
||||
#define FILE_PRICE_CONF "/priceconf.bin"
|
||||
|
||||
#endif
|
||||
92
lib/AmsConfiguration/include/Timezones.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Timezone.h>
|
||||
|
||||
#define JULY1970 15634800
|
||||
|
||||
TimeChangeRule TC_GMT = {"GMT", Last, Sun, Jan, 0, 0};
|
||||
TimeChangeRule TC_WET = {"WET", Last, Sun, Oct, 2, 0};
|
||||
TimeChangeRule TC_WEST = {"WEST", Last, Sun, Mar, 1, 60};
|
||||
TimeChangeRule TC_CET = {"CET", Last, Sun, Oct, 3, 60};
|
||||
TimeChangeRule TC_CEST = {"CEST", Last, Sun, Mar, 2, 120};
|
||||
TimeChangeRule TC_EET = {"EET", Last, Sun, Oct, 4, 120};
|
||||
TimeChangeRule TC_EEST = {"EEST", Last, Sun, Mar, 3, 180};
|
||||
|
||||
Timezone GMT = Timezone(TC_GMT);
|
||||
Timezone WesterEuropean = Timezone(TC_WET, TC_WEST);
|
||||
Timezone CentralEuropean = Timezone(TC_CET, TC_CEST);
|
||||
Timezone EasternEuropean = Timezone(TC_EET, TC_EEST);
|
||||
|
||||
Timezone* resolveTimezone(char* name) {
|
||||
if(strncmp_P(name, PSTR("Europe/"), 7) == 0) {
|
||||
if(strncmp_P(name+7, PSTR("Amsterdam"), 9) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Athens"), 6) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Belfast"), 7) == 0)
|
||||
return &WesterEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Berlin"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Bratislava"), 10) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Brussels"), 8) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Bucharest"), 9) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Budapest"), 8) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Copenhagen"), 10) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Dublin"), 6) == 0)
|
||||
return &WesterEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Helsinki"), 8) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Lisbon"), 6) == 0)
|
||||
return &WesterEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Ljubljana"), 9) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("London"), 6) == 0)
|
||||
return &WesterEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Luxembourg"), 10) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Madrid"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Malta"), 5) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Nicosia"), 7) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Oslo"), 4) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Paris"), 5) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Podgorica"), 9) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Prague"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Riga"), 4) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Rome"), 4) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Sofia"), 5) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Stockholm"), 9) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Tallinn"), 7) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Vienna"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Vilnius"), 7) == 0)
|
||||
return &EasternEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Warsaw"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Zagreb"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
if(strncmp_P(name+7, PSTR("Zurich"), 6) == 0)
|
||||
return &CentralEuropean;
|
||||
}
|
||||
return &GMT;
|
||||
}
|
||||
18
lib/AmsConfiguration/include/hexutils.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HEXUTILS_H
|
||||
#define _HEXUTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "Arduino.h"
|
||||
|
||||
String toHex(uint8_t* in);
|
||||
String toHex(uint8_t* in, uint16_t size);
|
||||
void fromHex(uint8_t *out, String in, uint16_t size);
|
||||
bool stripNonAscii(uint8_t* in, uint16_t size, bool extended = false);
|
||||
|
||||
#endif
|
||||
1324
lib/AmsConfiguration/src/AmsConfiguration.cpp
Normal file
48
lib/AmsConfiguration/src/hexutils.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hexutils.h"
|
||||
|
||||
String toHex(uint8_t* in) {
|
||||
return toHex(in, sizeof(in)*2);
|
||||
}
|
||||
|
||||
String toHex(uint8_t* in, uint16_t size) {
|
||||
String hex;
|
||||
for(int i = 0; i < size; i++) {
|
||||
if(in[i] < 0x10) {
|
||||
hex += '0';
|
||||
}
|
||||
hex += String(in[i], HEX);
|
||||
}
|
||||
hex.toUpperCase();
|
||||
return hex;
|
||||
}
|
||||
|
||||
void fromHex(uint8_t *out, String in, uint16_t size) {
|
||||
for(int i = 0; i < size*2; i += 2) {
|
||||
out[i/2] = strtol(in.substring(i, i+2).c_str(), 0, 16);
|
||||
}
|
||||
}
|
||||
|
||||
bool stripNonAscii(uint8_t* in, uint16_t size, bool extended) {
|
||||
bool ret = false;
|
||||
for(uint16_t i = 0; i < size; i++) {
|
||||
if(in[i] == 0) { // Clear the rest with null-terminator
|
||||
memset(in+i, 0, size-i);
|
||||
break;
|
||||
}
|
||||
if(extended && (in[i] < 32 || in[i] == 127 || in[i] == 129 || in[i] == 141 || in[i] == 143 || in[i] == 144 || in[i] == 157)) {
|
||||
memset(in+i, ' ', 1);
|
||||
ret = true;
|
||||
} else if(!extended && (in[i] < 32 || in[i] > 126)) {
|
||||
memset(in+i, ' ', 1);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
memset(in+size-1, 0, 1); // Make sure the last character is null-terminator
|
||||
return ret;
|
||||
}
|
||||
114
lib/AmsData/include/AmsData.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AMSDATA_H
|
||||
#define _AMSDATA_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Timezone.h>
|
||||
#include "OBIScodes.h"
|
||||
|
||||
enum AmsType {
|
||||
AmsTypeAutodetect = 0x00,
|
||||
AmsTypeAidon = 0x01,
|
||||
AmsTypeKaifa = 0x02,
|
||||
AmsTypeKamstrup = 0x03,
|
||||
AmsTypeIskra = 0x08,
|
||||
AmsTypeLandisGyr = 0x09,
|
||||
AmsTypeSagemcom = 0x0A,
|
||||
AmsTypeCustom = 0x88,
|
||||
AmsTypeUnknown = 0xFF
|
||||
};
|
||||
|
||||
class AmsData {
|
||||
public:
|
||||
AmsData();
|
||||
|
||||
void apply(AmsData& other);
|
||||
void apply(const OBIS_code_t obis, double value);
|
||||
|
||||
uint64_t getLastUpdateMillis();
|
||||
|
||||
time_t getPackageTimestamp();
|
||||
|
||||
uint8_t getListType();
|
||||
|
||||
String getListId();
|
||||
String getMeterId();
|
||||
uint8_t getMeterType();
|
||||
String getMeterModel();
|
||||
|
||||
time_t getMeterTimestamp();
|
||||
|
||||
uint32_t getActiveImportPower();
|
||||
uint32_t getReactiveImportPower();
|
||||
uint32_t getActiveExportPower();
|
||||
uint32_t getReactiveExportPower();
|
||||
|
||||
float getL1Voltage();
|
||||
float getL2Voltage();
|
||||
float getL3Voltage();
|
||||
|
||||
float getL1Current();
|
||||
float getL2Current();
|
||||
float getL3Current();
|
||||
|
||||
float getPowerFactor();
|
||||
float getL1PowerFactor();
|
||||
float getL2PowerFactor();
|
||||
float getL3PowerFactor();
|
||||
|
||||
uint32_t getL1ActiveImportPower();
|
||||
uint32_t getL2ActiveImportPower();
|
||||
uint32_t getL3ActiveImportPower();
|
||||
|
||||
uint32_t getL1ActiveExportPower();
|
||||
uint32_t getL2ActiveExportPower();
|
||||
uint32_t getL3ActiveExportPower();
|
||||
|
||||
double getL1ActiveImportCounter();
|
||||
double getL2ActiveImportCounter();
|
||||
double getL3ActiveImportCounter();
|
||||
|
||||
double getL1ActiveExportCounter();
|
||||
double getL2ActiveExportCounter();
|
||||
double getL3ActiveExportCounter();
|
||||
|
||||
double getActiveImportCounter();
|
||||
double getReactiveImportCounter();
|
||||
double getActiveExportCounter();
|
||||
double getReactiveExportCounter();
|
||||
|
||||
bool isThreePhase();
|
||||
bool isTwoPhase();
|
||||
bool isCounterEstimated();
|
||||
bool isL2currentMissing();
|
||||
|
||||
int8_t getLastError();
|
||||
void setLastError(int8_t);
|
||||
|
||||
protected:
|
||||
uint64_t lastUpdateMillis = 0;
|
||||
uint64_t lastList2 = 0;
|
||||
uint8_t listType = 0, meterType = AmsTypeUnknown;
|
||||
time_t packageTimestamp = 0;
|
||||
String listId = "", meterId = "", meterModel = "";
|
||||
time_t meterTimestamp = 0;
|
||||
uint32_t activeImportPower = 0, reactiveImportPower = 0, activeExportPower = 0, reactiveExportPower = 0;
|
||||
float l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0;
|
||||
uint32_t l1activeImportPower = 0, l2activeImportPower = 0, l3activeImportPower = 0;
|
||||
uint32_t l1activeExportPower = 0, l2activeExportPower = 0, l3activeExportPower = 0;
|
||||
double l1activeImportCounter = 0, l2activeImportCounter = 0, l3activeImportCounter = 0;
|
||||
double l1activeExportCounter = 0, l2activeExportCounter = 0, l3activeExportCounter = 0;
|
||||
float powerFactor = 0, l1PowerFactor = 0, l2PowerFactor = 0, l3PowerFactor = 0;
|
||||
double activeImportCounter = 0, reactiveImportCounter = 0, activeExportCounter = 0, reactiveExportCounter = 0;
|
||||
bool threePhase = false, twoPhase = false, counterEstimated = false, l2currentMissing = false;;
|
||||
|
||||
int8_t lastError = 0x00;
|
||||
uint8_t lastErrorCount = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
81
lib/AmsData/include/OBIScodes.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _OBISCODES_H
|
||||
#define _OBISCODES_H
|
||||
|
||||
#include "lwip/def.h"
|
||||
|
||||
#define OBIS_MEDIUM_ABSTRACT 0
|
||||
#define OBIS_MEDIUM_ELECTRICITY 1
|
||||
|
||||
#define OBIS_CHAN_0 0
|
||||
#define OBIS_CHAN_1 1
|
||||
|
||||
#define OBIS_RANGE_NA 0xFF
|
||||
|
||||
struct OBIS_head_t {
|
||||
uint8_t medium;
|
||||
uint8_t channel;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct OBIS_code_t {
|
||||
uint8_t sensor;
|
||||
uint8_t gr;
|
||||
uint8_t tariff;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct OBIS_t {
|
||||
OBIS_head_t head;
|
||||
OBIS_code_t code;
|
||||
uint8_t range;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
const OBIS_code_t OBIS_NULL PROGMEM = { 0, 0, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_FIRMWARE_VERSION PROGMEM = { 0, 2, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_VERSION PROGMEM = { 0, 2, 129 };
|
||||
const OBIS_code_t OBIS_METER_MODEL PROGMEM = { 96, 1, 1 };
|
||||
const OBIS_code_t OBIS_METER_MODEL_2 PROGMEM = { 96, 1, 7 };
|
||||
const OBIS_code_t OBIS_METER_ID PROGMEM = { 96, 1, 0 };
|
||||
const OBIS_code_t OBIS_METER_ID_2 PROGMEM = { 0, 0, 5 };
|
||||
const OBIS_code_t OBIS_METER_TIMESTAMP PROGMEM = { 1, 0, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_ACTIVE_IMPORT PROGMEM = { 1, 7, 0 };
|
||||
const OBIS_code_t OBIS_ACTIVE_IMPORT_COUNT PROGMEM = { 1, 8, 0 };
|
||||
const OBIS_code_t OBIS_ACTIVE_EXPORT PROGMEM = { 2, 7, 0 };
|
||||
const OBIS_code_t OBIS_ACTIVE_EXPORT_COUNT PROGMEM = { 2, 8, 0 };
|
||||
const OBIS_code_t OBIS_REACTIVE_IMPORT PROGMEM = { 3, 7, 0 };
|
||||
const OBIS_code_t OBIS_REACTIVE_IMPORT_COUNT PROGMEM = { 3, 8, 0 };
|
||||
const OBIS_code_t OBIS_REACTIVE_EXPORT PROGMEM = { 4, 7, 0 };
|
||||
const OBIS_code_t OBIS_REACTIVE_EXPORT_COUNT PROGMEM = { 4, 8, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_POWER_FACTOR PROGMEM = { 13, 7, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_ACTIVE_IMPORT_L1 PROGMEM = { 21, 7, 0 };
|
||||
const OBIS_code_t OBIS_ACTIVE_EXPORT_L1 PROGMEM = { 22, 7, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_CURRENT_L1 PROGMEM = { 31, 7, 0 };
|
||||
const OBIS_code_t OBIS_VOLTAGE_L1 PROGMEM = { 32, 7, 0 };
|
||||
const OBIS_code_t OBIS_POWER_FACTOR_L1 PROGMEM = { 33, 7, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_ACTIVE_IMPORT_L2 PROGMEM = { 41, 7, 0 };
|
||||
const OBIS_code_t OBIS_ACTIVE_EXPORT_L2 PROGMEM = { 42, 7, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_CURRENT_L2 PROGMEM = { 51, 7, 0 };
|
||||
const OBIS_code_t OBIS_VOLTAGE_L2 PROGMEM = { 52, 7, 0 };
|
||||
const OBIS_code_t OBIS_POWER_FACTOR_L2 PROGMEM = { 53, 7, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_ACTIVE_IMPORT_L3 PROGMEM = { 61, 7, 0 };
|
||||
const OBIS_code_t OBIS_ACTIVE_EXPORT_L3 PROGMEM = { 62, 7, 0 };
|
||||
|
||||
const OBIS_code_t OBIS_CURRENT_L3 PROGMEM = { 71, 7, 0 };
|
||||
const OBIS_code_t OBIS_VOLTAGE_L3 PROGMEM = { 72, 7, 0 };
|
||||
const OBIS_code_t OBIS_POWER_FACTOR_L3 PROGMEM = { 73, 7, 0 };
|
||||
|
||||
#endif
|
||||
366
lib/AmsData/src/AmsData.cpp
Normal file
@@ -0,0 +1,366 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AmsData.h"
|
||||
|
||||
AmsData::AmsData() {}
|
||||
|
||||
void AmsData::apply(AmsData& other) {
|
||||
if(other.getListType() < 3) {
|
||||
unsigned long ms = this->lastUpdateMillis > other.getLastUpdateMillis() ? 0 : other.getLastUpdateMillis() - this->lastUpdateMillis;
|
||||
|
||||
if(ms > 0) {
|
||||
if(other.getActiveImportPower() > 0) {
|
||||
uint32_t power = (activeImportPower + other.getActiveImportPower()) / 2;
|
||||
float add = power * (((float) ms) / 3600000.0);
|
||||
activeImportCounter += add / 1000.0;
|
||||
//Serial.printf("%dW, %dms, %.6fkWh added\n", other.getActiveImportPower(), ms, add);
|
||||
}
|
||||
|
||||
if(other.getListType() > 1) {
|
||||
ms = this->lastList2 > other.getLastUpdateMillis() ? 0 : other.getLastUpdateMillis() - this->lastList2;
|
||||
if(other.getActiveExportPower() > 0) {
|
||||
uint32_t power = (activeExportPower + other.getActiveExportPower()) / 2;
|
||||
float add = power * (((float) ms) / 3600000.0);
|
||||
activeExportCounter += add / 1000.0;
|
||||
}
|
||||
if(other.getReactiveImportPower() > 0) {
|
||||
uint32_t power = (reactiveImportPower + other.getReactiveImportPower()) / 2;
|
||||
float add = power * (((float) ms) / 3600000.0);
|
||||
reactiveImportCounter += add / 1000.0;
|
||||
}
|
||||
if(other.getReactiveExportPower() > 0) {
|
||||
uint32_t power = (reactiveExportPower + other.getReactiveExportPower()) / 2;
|
||||
float add = power * (((float) ms) / 3600000.0);
|
||||
reactiveExportCounter += add / 1000.0;
|
||||
}
|
||||
}
|
||||
counterEstimated = true;
|
||||
}
|
||||
}
|
||||
|
||||
this->lastUpdateMillis = other.getLastUpdateMillis();
|
||||
if(other.getListType() > 1) {
|
||||
this->lastList2 = this->lastUpdateMillis;
|
||||
}
|
||||
this->packageTimestamp = other.getPackageTimestamp();
|
||||
if(other.getListType() > this->listType)
|
||||
this->listType = other.getListType();
|
||||
switch(other.getListType()) {
|
||||
case 4:
|
||||
this->powerFactor = other.getPowerFactor();
|
||||
this->l1PowerFactor = other.getL1PowerFactor();
|
||||
this->l2PowerFactor = other.getL2PowerFactor();
|
||||
this->l3PowerFactor = other.getL3PowerFactor();
|
||||
this->l1activeImportPower = other.getL1ActiveImportPower();
|
||||
this->l2activeImportPower = other.getL2ActiveImportPower();
|
||||
this->l3activeImportPower = other.getL3ActiveImportPower();
|
||||
this->l1activeExportPower = other.getL1ActiveExportPower();
|
||||
this->l2activeExportPower = other.getL2ActiveExportPower();
|
||||
this->l3activeExportPower = other.getL3ActiveExportPower();
|
||||
this->l1activeImportCounter = other.getL1ActiveImportCounter();
|
||||
this->l2activeImportCounter = other.getL2ActiveImportCounter();
|
||||
this->l3activeImportCounter = other.getL3ActiveImportCounter();
|
||||
this->l1activeExportCounter = other.getL1ActiveExportCounter();
|
||||
this->l2activeExportCounter = other.getL2ActiveExportCounter();
|
||||
this->l3activeExportCounter = other.getL3ActiveExportCounter();
|
||||
case 3:
|
||||
this->meterTimestamp = other.getMeterTimestamp();
|
||||
this->activeImportCounter = other.getActiveImportCounter();
|
||||
this->activeExportCounter = other.getActiveExportCounter();
|
||||
this->reactiveImportCounter = other.getReactiveImportCounter();
|
||||
this->reactiveExportCounter = other.getReactiveExportCounter();
|
||||
this->counterEstimated = false;
|
||||
case 2:
|
||||
this->listId = other.getListId();
|
||||
this->meterId = other.getMeterId();
|
||||
this->meterType = other.getMeterType();
|
||||
this->meterModel = other.getMeterModel();
|
||||
this->reactiveImportPower = other.getReactiveImportPower();
|
||||
this->reactiveExportPower = other.getReactiveExportPower();
|
||||
this->l1current = other.getL1Current();
|
||||
this->l2current = other.getL2Current();
|
||||
this->l2currentMissing = other.isL2currentMissing();
|
||||
this->l3current = other.getL3Current();
|
||||
this->l1voltage = other.getL1Voltage();
|
||||
this->l2voltage = other.getL2Voltage();
|
||||
this->l3voltage = other.getL3Voltage();
|
||||
this->threePhase = other.isThreePhase();
|
||||
this->twoPhase = other.isTwoPhase();
|
||||
}
|
||||
|
||||
// Moved outside switch to handle meters alternating between sending active and accumulated values
|
||||
if(other.getListType() == 1 || (other.getActiveImportPower() > 0 || other.getActiveExportPower() > 0))
|
||||
this->activeImportPower = other.getActiveImportPower();
|
||||
if(other.getListType() == 2 || (other.getActiveImportPower() > 0 || other.getActiveExportPower() > 0))
|
||||
this->activeExportPower = other.getActiveExportPower();
|
||||
}
|
||||
|
||||
void AmsData::apply(OBIS_code_t obis, double value) {
|
||||
switch(obis.gr) {
|
||||
case 1:
|
||||
switch(obis.sensor) {
|
||||
case 7:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
activeImportPower = value;
|
||||
listType = max(listType, (uint8_t) 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
activeImportCounter = value;
|
||||
listType = max(listType, (uint8_t) 3);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch(obis.sensor) {
|
||||
case 7:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
activeExportPower = value;
|
||||
listType = max(listType, (uint8_t) 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
activeExportCounter = value;
|
||||
listType = max(listType, (uint8_t) 3);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch(obis.sensor) {
|
||||
case 7:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
reactiveImportPower = value;
|
||||
listType = max(listType, (uint8_t) 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
reactiveImportCounter = value;
|
||||
listType = max(listType, (uint8_t) 3);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch(obis.sensor) {
|
||||
case 7:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
reactiveExportPower = value;
|
||||
listType = max(listType, (uint8_t) 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
switch(obis.tariff) {
|
||||
case 0:
|
||||
reactiveExportCounter = value;
|
||||
listType = max(listType, (uint8_t) 3);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t AmsData::getLastUpdateMillis() {
|
||||
return this->lastUpdateMillis;
|
||||
}
|
||||
|
||||
time_t AmsData::getPackageTimestamp() {
|
||||
return this->packageTimestamp;
|
||||
}
|
||||
|
||||
uint8_t AmsData::getListType() {
|
||||
return this->listType;
|
||||
}
|
||||
|
||||
String AmsData::getListId() {
|
||||
return this->listId;
|
||||
}
|
||||
|
||||
String AmsData::getMeterId() {
|
||||
return this->meterId;
|
||||
}
|
||||
|
||||
uint8_t AmsData::getMeterType() {
|
||||
return this->meterType;
|
||||
}
|
||||
|
||||
String AmsData::getMeterModel() {
|
||||
return this->meterModel;
|
||||
}
|
||||
|
||||
time_t AmsData::getMeterTimestamp() {
|
||||
return this->meterTimestamp;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getActiveImportPower() {
|
||||
return this->activeImportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getReactiveImportPower() {
|
||||
return this->reactiveImportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getActiveExportPower() {
|
||||
return this->activeExportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getReactiveExportPower() {
|
||||
return this->reactiveExportPower;
|
||||
}
|
||||
|
||||
float AmsData::getL1Voltage() {
|
||||
return this->l1voltage;
|
||||
}
|
||||
|
||||
float AmsData::getL2Voltage() {
|
||||
return this->l2voltage;
|
||||
}
|
||||
|
||||
float AmsData::getL3Voltage() {
|
||||
return this->l3voltage;
|
||||
}
|
||||
|
||||
float AmsData::getL1Current() {
|
||||
return this->l1current;
|
||||
}
|
||||
|
||||
float AmsData::getL2Current() {
|
||||
return this->l2current;
|
||||
}
|
||||
|
||||
float AmsData::getL3Current() {
|
||||
return this->l3current;
|
||||
}
|
||||
|
||||
float AmsData::getPowerFactor() {
|
||||
return this->powerFactor;
|
||||
}
|
||||
|
||||
float AmsData::getL1PowerFactor() {
|
||||
return this->l1PowerFactor;
|
||||
}
|
||||
|
||||
float AmsData::getL2PowerFactor() {
|
||||
return this->l2PowerFactor;
|
||||
}
|
||||
|
||||
float AmsData::getL3PowerFactor() {
|
||||
return this->l3PowerFactor;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getL1ActiveImportPower() {
|
||||
return this->l1activeImportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getL2ActiveImportPower() {
|
||||
return this->l2activeImportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getL3ActiveImportPower() {
|
||||
return this->l3activeImportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getL1ActiveExportPower() {
|
||||
return this->l1activeExportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getL2ActiveExportPower() {
|
||||
return this->l2activeExportPower;
|
||||
}
|
||||
|
||||
uint32_t AmsData::getL3ActiveExportPower() {
|
||||
return this->l3activeExportPower;
|
||||
}
|
||||
|
||||
double AmsData::getL1ActiveImportCounter() {
|
||||
return this->l1activeImportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getL2ActiveImportCounter() {
|
||||
return this->l2activeImportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getL3ActiveImportCounter() {
|
||||
return this->l3activeImportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getL1ActiveExportCounter() {
|
||||
return this->l1activeExportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getL2ActiveExportCounter() {
|
||||
return this->l2activeExportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getL3ActiveExportCounter() {
|
||||
return this->l3activeExportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getActiveImportCounter() {
|
||||
return this->activeImportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getReactiveImportCounter() {
|
||||
return this->reactiveImportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getActiveExportCounter() {
|
||||
return this->activeExportCounter;
|
||||
}
|
||||
|
||||
double AmsData::getReactiveExportCounter() {
|
||||
return this->reactiveExportCounter;
|
||||
}
|
||||
|
||||
bool AmsData::isThreePhase() {
|
||||
return this->threePhase;
|
||||
}
|
||||
|
||||
bool AmsData::isTwoPhase() {
|
||||
return this->twoPhase;
|
||||
}
|
||||
|
||||
bool AmsData::isCounterEstimated() {
|
||||
return this->counterEstimated;
|
||||
}
|
||||
|
||||
bool AmsData::isL2currentMissing() {
|
||||
return this->l2currentMissing;
|
||||
}
|
||||
|
||||
int8_t AmsData::getLastError() {
|
||||
return lastErrorCount > 2 ? lastError : 0;
|
||||
}
|
||||
|
||||
void AmsData::setLastError(int8_t lastError) {
|
||||
this->lastError = lastError;
|
||||
if(lastError == 0) {
|
||||
lastErrorCount = 0;
|
||||
} else {
|
||||
lastErrorCount++;
|
||||
}
|
||||
}
|
||||
105
lib/AmsDataStorage/include/AmsDataStorage.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AMSDATASTORAGE_H
|
||||
#define _AMSDATASTORAGE_H
|
||||
#include "Arduino.h"
|
||||
#include "AmsData.h"
|
||||
#include "RemoteDebug.h"
|
||||
#include "Timezone.h"
|
||||
|
||||
struct DayDataPoints5 {
|
||||
uint8_t version;
|
||||
uint16_t hImport[24];
|
||||
time_t lastMeterReadTime;
|
||||
uint32_t activeImport;
|
||||
uint32_t activeExport;
|
||||
uint16_t hExport[24];
|
||||
uint8_t accuracy;
|
||||
};
|
||||
|
||||
struct MonthDataPoints6 {
|
||||
uint8_t version;
|
||||
uint16_t dImport[31];
|
||||
time_t lastMeterReadTime;
|
||||
uint32_t activeImport;
|
||||
uint32_t activeExport;
|
||||
uint16_t dExport[31];
|
||||
uint8_t accuracy;
|
||||
};
|
||||
|
||||
struct DayDataPoints {
|
||||
uint8_t version;
|
||||
uint16_t hImport[24];
|
||||
time_t lastMeterReadTime;
|
||||
uint64_t activeImport;
|
||||
uint64_t activeExport;
|
||||
uint16_t hExport[24];
|
||||
uint8_t accuracy;
|
||||
};
|
||||
|
||||
struct MonthDataPoints {
|
||||
uint8_t version;
|
||||
uint16_t dImport[31];
|
||||
time_t lastMeterReadTime;
|
||||
uint64_t activeImport;
|
||||
uint64_t activeExport;
|
||||
uint16_t dExport[31];
|
||||
uint8_t accuracy;
|
||||
};
|
||||
|
||||
class AmsDataStorage {
|
||||
public:
|
||||
AmsDataStorage(RemoteDebug*);
|
||||
void setTimezone(Timezone*);
|
||||
bool update(AmsData*);
|
||||
uint32_t getHourImport(uint8_t);
|
||||
uint32_t getHourExport(uint8_t);
|
||||
uint32_t getDayImport(uint8_t);
|
||||
uint32_t getDayExport(uint8_t);
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
DayDataPoints getDayData();
|
||||
bool setDayData(DayDataPoints&);
|
||||
MonthDataPoints getMonthData();
|
||||
bool setMonthData(MonthDataPoints&);
|
||||
|
||||
uint8_t getDayAccuracy();
|
||||
void setDayAccuracy(uint8_t);
|
||||
uint8_t getMonthAccuracy();
|
||||
void setMonthAccuracy(uint8_t);
|
||||
|
||||
bool isHappy();
|
||||
bool isDayHappy();
|
||||
bool isMonthHappy();
|
||||
|
||||
double getEstimatedImportCounter();
|
||||
|
||||
private:
|
||||
Timezone* tz;
|
||||
DayDataPoints day = {
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
10
|
||||
};
|
||||
MonthDataPoints month = {
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
10
|
||||
};
|
||||
RemoteDebug* debugger;
|
||||
void setHourImport(uint8_t, uint32_t);
|
||||
void setHourExport(uint8_t, uint32_t);
|
||||
void setDayImport(uint8_t, uint32_t);
|
||||
void setDayExport(uint8_t, uint32_t);
|
||||
};
|
||||
|
||||
#endif
|
||||
600
lib/AmsDataStorage/src/AmsDataStorage.cpp
Normal file
@@ -0,0 +1,600 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AmsDataStorage.h"
|
||||
#include <lwip/apps/sntp.h>
|
||||
#include "LittleFS.h"
|
||||
#include "AmsStorage.h"
|
||||
#include "FirmwareVersion.h"
|
||||
|
||||
AmsDataStorage::AmsDataStorage(RemoteDebug* debugger) {
|
||||
day.version = 6;
|
||||
day.accuracy = 1;
|
||||
month.version = 7;
|
||||
month.accuracy = 1;
|
||||
this->debugger = debugger;
|
||||
}
|
||||
|
||||
void AmsDataStorage::setTimezone(Timezone* tz) {
|
||||
this->tz = tz;
|
||||
}
|
||||
|
||||
bool AmsDataStorage::update(AmsData* data) {
|
||||
if(isHappy()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if(tz == NULL) {
|
||||
return false;
|
||||
}
|
||||
if(now < FirmwareVersion::BuildEpoch) {
|
||||
if(data->getMeterTimestamp() > FirmwareVersion::BuildEpoch) {
|
||||
now = data->getMeterTimestamp();
|
||||
} else if(data->getPackageTimestamp() > FirmwareVersion::BuildEpoch) {
|
||||
now = data->getPackageTimestamp();
|
||||
}
|
||||
}
|
||||
if(now < FirmwareVersion::BuildEpoch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tmElements_t utc, ltz, utcYesterday, ltzYesterDay;
|
||||
breakTime(now, utc);
|
||||
breakTime(tz->toLocal(now), ltz);
|
||||
breakTime(now-3600, utcYesterday);
|
||||
breakTime(tz->toLocal(now-3600), ltzYesterDay);
|
||||
|
||||
uint64_t importCounter = data->getActiveImportCounter() * 1000;
|
||||
uint64_t exportCounter = data->getActiveExportCounter() * 1000;
|
||||
|
||||
// Clear hours between last update and now
|
||||
if(day.lastMeterReadTime > now) {
|
||||
day.activeImport = importCounter;
|
||||
day.activeExport = exportCounter;
|
||||
day.lastMeterReadTime = now;
|
||||
} else if((importCounter > 0 && day.activeImport == 0) || now - day.lastMeterReadTime > 86400) {
|
||||
day.activeImport = importCounter;
|
||||
day.activeExport = exportCounter;
|
||||
day.lastMeterReadTime = now;
|
||||
for(int i = 0; i<24; i++) {
|
||||
setHourImport(i, 0);
|
||||
setHourExport(i, 0);
|
||||
}
|
||||
} else {
|
||||
tmElements_t last;
|
||||
breakTime(day.lastMeterReadTime, last);
|
||||
uint8_t endHour = utc.Hour;
|
||||
if(last.Hour > utc.Hour){
|
||||
for(int i = 0; i < utc.Hour; i++) {
|
||||
setHourImport(i, 0);
|
||||
setHourExport(i, 0);
|
||||
}
|
||||
endHour = 24;
|
||||
}
|
||||
for(int i = last.Hour; i < endHour; i++) {
|
||||
setHourImport(i, 0);
|
||||
setHourExport(i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear days between last update and now
|
||||
if(month.lastMeterReadTime > now) {
|
||||
month.activeImport = importCounter;
|
||||
month.activeExport = exportCounter;
|
||||
month.lastMeterReadTime = now;
|
||||
} else if((importCounter > 0 && month.activeImport == 0) || now - month.lastMeterReadTime > 2682000) {
|
||||
month.activeImport = importCounter;
|
||||
month.activeExport = exportCounter;
|
||||
month.lastMeterReadTime = now;
|
||||
for(int i = 1; i<=31; i++) {
|
||||
setDayImport(i, 0);
|
||||
setDayExport(i, 0);
|
||||
}
|
||||
} else {
|
||||
tmElements_t last;
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
uint8_t endDay = ltz.Day;
|
||||
if(last.Day > ltz.Day) {
|
||||
for(int i = 1; i < ltz.Day; i++) {
|
||||
setDayImport(i, 0);
|
||||
setDayExport(i, 0);
|
||||
}
|
||||
endDay = 31;
|
||||
}
|
||||
for(int i = last.Day; i < endDay; i++) {
|
||||
setDayImport(i, 0);
|
||||
setDayExport(i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(data->getListType() < 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
||||
// Update day plot
|
||||
if(!isDayHappy()) {
|
||||
if(day.activeImport > importCounter || day.activeExport > exportCounter) {
|
||||
day.activeImport = importCounter;
|
||||
day.activeExport = exportCounter;
|
||||
day.lastMeterReadTime = now;
|
||||
setHourImport(utcYesterday.Hour, 0);
|
||||
setHourExport(utcYesterday.Hour, 0);
|
||||
} else if(now - day.lastMeterReadTime < 4000) {
|
||||
uint32_t imp = importCounter - day.activeImport;
|
||||
uint32_t exp = exportCounter - day.activeExport;
|
||||
setHourImport(utcYesterday.Hour, imp);
|
||||
setHourExport(utcYesterday.Hour, exp);
|
||||
|
||||
day.activeImport = importCounter;
|
||||
day.activeExport = exportCounter;
|
||||
day.lastMeterReadTime = now;
|
||||
} else {
|
||||
float mins = (now - day.lastMeterReadTime) / 60.0;
|
||||
uint32_t im = importCounter - day.activeImport;
|
||||
uint32_t ex = exportCounter - day.activeExport;
|
||||
float ipm = im / mins;
|
||||
float epm = ex / mins;
|
||||
|
||||
tmElements_t last;
|
||||
breakTime(day.lastMeterReadTime, last);
|
||||
day.lastMeterReadTime = day.lastMeterReadTime - (last.Minute * 60) - last.Second;
|
||||
time_t stopAt = now - (utc.Minute * 60) - utc.Second;
|
||||
while(day.lastMeterReadTime < stopAt) {
|
||||
time_t cur = min(day.lastMeterReadTime + 3600, stopAt);
|
||||
uint8_t minutes = round((cur - day.lastMeterReadTime) / 60.0);
|
||||
if(minutes < 1) break;
|
||||
|
||||
breakTime(day.lastMeterReadTime, last);
|
||||
float imp = (ipm * minutes);
|
||||
float exp = (epm * minutes);
|
||||
setHourImport(last.Hour, imp);
|
||||
setHourExport(last.Hour, exp);
|
||||
|
||||
day.activeImport += imp;
|
||||
day.activeExport += exp;
|
||||
day.lastMeterReadTime = cur;
|
||||
}
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// Update month plot
|
||||
if(ltz.Hour == 0 && !isMonthHappy()) {
|
||||
if(month.activeImport > importCounter || month.activeExport > exportCounter) {
|
||||
month.activeImport = importCounter;
|
||||
month.activeExport = exportCounter;
|
||||
month.lastMeterReadTime = now;
|
||||
setDayImport(ltzYesterDay.Day, 0);
|
||||
setDayExport(ltzYesterDay.Day, 0);
|
||||
} else if(now - month.lastMeterReadTime < 90100 && now - month.lastMeterReadTime > 82700) { // DST days are 23h (82800s) and 25h (90000)
|
||||
uint32_t imp = importCounter - month.activeImport;
|
||||
uint32_t exp = exportCounter - month.activeExport;
|
||||
|
||||
setDayImport(ltzYesterDay.Day, imp);
|
||||
setDayExport(ltzYesterDay.Day, exp);
|
||||
month.activeImport = importCounter;
|
||||
month.activeExport = exportCounter;
|
||||
month.lastMeterReadTime = now;
|
||||
} else {
|
||||
// Make sure last month read is at midnight
|
||||
tmElements_t last;
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
month.lastMeterReadTime = month.lastMeterReadTime - (last.Hour * 3600) - (last.Minute * 60) - last.Second;
|
||||
|
||||
float hrs = (now - month.lastMeterReadTime) / 3600.0;
|
||||
uint32_t im = importCounter - month.activeImport;
|
||||
uint32_t ex = exportCounter - month.activeExport;
|
||||
float iph = im / hrs;
|
||||
float eph = ex / hrs;
|
||||
|
||||
time_t stopAt = now - (ltz.Hour * 3600) - (ltz.Minute * 60) - ltz.Second;
|
||||
while(month.lastMeterReadTime < stopAt) {
|
||||
time_t cur = min(month.lastMeterReadTime + 86400, stopAt);
|
||||
uint8_t hours = round((cur - month.lastMeterReadTime) / 3600.0);
|
||||
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
float imp = (iph * hours);
|
||||
float exp = (eph * hours);
|
||||
setDayImport(last.Day, imp);
|
||||
setDayExport(last.Day, exp);
|
||||
|
||||
month.activeImport += imp;
|
||||
month.activeExport += exp;
|
||||
month.lastMeterReadTime = cur;
|
||||
}
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AmsDataStorage::setHourImport(uint8_t hour, uint32_t val) {
|
||||
if(hour < 0 || hour > 24) return;
|
||||
|
||||
uint8_t accuracy = day.accuracy;
|
||||
uint32_t update = val / pow(10, accuracy);
|
||||
while(update > UINT16_MAX) {
|
||||
accuracy++;
|
||||
update = val / pow(10, accuracy);
|
||||
}
|
||||
|
||||
if(accuracy != day.accuracy) {
|
||||
setDayAccuracy(accuracy);
|
||||
}
|
||||
|
||||
day.hImport[hour] = update;
|
||||
|
||||
uint32_t max = 0;
|
||||
for(uint8_t i = 0; i < 24; i++) {
|
||||
if(day.hImport[i] > max)
|
||||
max = day.hImport[i];
|
||||
if(day.hExport[i] > max)
|
||||
max = day.hExport[i];
|
||||
}
|
||||
|
||||
while(max < UINT16_MAX/10 && accuracy > 0) {
|
||||
accuracy--;
|
||||
max = max*10;
|
||||
}
|
||||
|
||||
if(accuracy != day.accuracy) {
|
||||
setDayAccuracy(accuracy);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AmsDataStorage::getHourImport(uint8_t hour) {
|
||||
if(hour < 0 || hour > 24) return 0;
|
||||
return day.hImport[hour] * pow(10, day.accuracy);
|
||||
}
|
||||
|
||||
void AmsDataStorage::setHourExport(uint8_t hour, uint32_t val) {
|
||||
if(hour < 0 || hour > 24) return;
|
||||
|
||||
uint8_t accuracy = day.accuracy;
|
||||
uint32_t update = val / pow(10, accuracy);
|
||||
while(update > UINT16_MAX) {
|
||||
accuracy++;
|
||||
update = val / pow(10, accuracy);
|
||||
}
|
||||
|
||||
if(accuracy != day.accuracy) {
|
||||
setDayAccuracy(accuracy);
|
||||
}
|
||||
|
||||
day.hExport[hour] = update;
|
||||
|
||||
uint32_t max = 0;
|
||||
for(uint8_t i = 0; i < 24; i++) {
|
||||
if(day.hImport[i] > max)
|
||||
max = day.hImport[i];
|
||||
if(day.hExport[i] > max)
|
||||
max = day.hExport[i];
|
||||
}
|
||||
|
||||
while(max < UINT16_MAX/10 && accuracy > 0) {
|
||||
accuracy--;
|
||||
max = max*10;
|
||||
}
|
||||
|
||||
if(accuracy != day.accuracy) {
|
||||
setDayAccuracy(accuracy);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AmsDataStorage::getHourExport(uint8_t hour) {
|
||||
if(hour < 0 || hour > 24) return 0;
|
||||
return day.hExport[hour] * pow(10, day.accuracy);
|
||||
}
|
||||
|
||||
void AmsDataStorage::setDayImport(uint8_t day, uint32_t val) {
|
||||
if(day < 1 || day > 31) return;
|
||||
|
||||
uint8_t accuracy = month.accuracy;
|
||||
uint32_t update = val / pow(10, accuracy);
|
||||
while(update > UINT16_MAX) {
|
||||
accuracy++;
|
||||
update = val / pow(10, accuracy);
|
||||
}
|
||||
|
||||
if(accuracy != month.accuracy) {
|
||||
setMonthAccuracy(accuracy);
|
||||
}
|
||||
|
||||
month.dImport[day-1] = update;
|
||||
|
||||
uint32_t max = 0;
|
||||
for(uint8_t i = 0; i < 31; i++) {
|
||||
if(month.dImport[i] > max)
|
||||
max = month.dImport[i];
|
||||
if(month.dExport[i] > max)
|
||||
max = month.dExport[i];
|
||||
}
|
||||
|
||||
while(max < UINT16_MAX/10 && accuracy > 0) {
|
||||
accuracy--;
|
||||
max = max*10;
|
||||
}
|
||||
|
||||
if(accuracy != month.accuracy) {
|
||||
setMonthAccuracy(accuracy);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AmsDataStorage::getDayImport(uint8_t day) {
|
||||
if(day < 1 || day > 31) return 0;
|
||||
return (month.dImport[day-1] * pow(10, month.accuracy));
|
||||
}
|
||||
|
||||
void AmsDataStorage::setDayExport(uint8_t day, uint32_t val) {
|
||||
if(day < 1 || day > 31) return;
|
||||
|
||||
uint8_t accuracy = month.accuracy;
|
||||
uint32_t update = val / pow(10, accuracy);
|
||||
while(update > UINT16_MAX) {
|
||||
accuracy++;
|
||||
update = val / pow(10, accuracy);
|
||||
}
|
||||
|
||||
if(accuracy != month.accuracy) {
|
||||
setMonthAccuracy(accuracy);
|
||||
}
|
||||
|
||||
month.dExport[day-1] = update;
|
||||
|
||||
uint32_t max = 0;
|
||||
for(uint8_t i = 0; i < 31; i++) {
|
||||
if(month.dImport[i] > max)
|
||||
max = month.dImport[i];
|
||||
if(month.dExport[i] > max)
|
||||
max = month.dExport[i];
|
||||
}
|
||||
|
||||
while(max < UINT16_MAX/10 && accuracy > 0) {
|
||||
accuracy--;
|
||||
max = max*10;
|
||||
}
|
||||
|
||||
if(accuracy != month.accuracy) {
|
||||
setMonthAccuracy(accuracy);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AmsDataStorage::getDayExport(uint8_t day) {
|
||||
if(day < 1 || day > 31) return 0;
|
||||
return (month.dExport[day-1] * pow(10, month.accuracy));
|
||||
}
|
||||
|
||||
bool AmsDataStorage::load() {
|
||||
if(!LittleFS.begin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
if(LittleFS.exists(FILE_DAYPLOT)) {
|
||||
File file = LittleFS.open(FILE_DAYPLOT, "r");
|
||||
char buf[file.size()];
|
||||
file.readBytes(buf, file.size());
|
||||
if(buf[0] > 5) {
|
||||
DayDataPoints* day = (DayDataPoints*) buf;
|
||||
ret = setDayData(*day);
|
||||
} else {
|
||||
DayDataPoints5* old = (DayDataPoints5*) buf;
|
||||
DayDataPoints day = { old->version };
|
||||
day.lastMeterReadTime = old->lastMeterReadTime;
|
||||
day.activeImport = old->activeImport;
|
||||
day.activeExport = old->activeExport;
|
||||
day.accuracy = old->accuracy;
|
||||
for(uint8_t i = 0; i < 24; i++) {
|
||||
day.hImport[i] = old->hImport[i];
|
||||
day.hExport[i] = old->hExport[i];
|
||||
}
|
||||
|
||||
ret = setDayData(day);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
if(LittleFS.exists(FILE_MONTHPLOT)) {
|
||||
File file = LittleFS.open(FILE_MONTHPLOT, "r");
|
||||
char buf[file.size()];
|
||||
file.readBytes(buf, file.size());
|
||||
if(buf[0] > 6) {
|
||||
MonthDataPoints* month = (MonthDataPoints*) buf;
|
||||
ret &= setMonthData(*month);
|
||||
} else {
|
||||
MonthDataPoints6* old = (MonthDataPoints6*) buf;
|
||||
MonthDataPoints month = { old->version };
|
||||
month.lastMeterReadTime = old->lastMeterReadTime;
|
||||
month.activeImport = old->activeImport;
|
||||
month.activeExport = old->activeExport;
|
||||
month.accuracy = old->accuracy;
|
||||
for(uint8_t i = 0; i < 31; i++) {
|
||||
month.dImport[i] = old->dImport[i];
|
||||
month.dExport[i] = old->dExport[i];
|
||||
}
|
||||
|
||||
ret &= setMonthData(month);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AmsDataStorage::save() {
|
||||
if(!LittleFS.begin()) {
|
||||
return false;
|
||||
}
|
||||
{
|
||||
File file = LittleFS.open(FILE_DAYPLOT, "w");
|
||||
char buf[sizeof(day)];
|
||||
memcpy(buf, &day, sizeof(day));
|
||||
for(unsigned long i = 0; i < sizeof(day); i++) {
|
||||
file.write(buf[i]);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
{
|
||||
File file = LittleFS.open(FILE_MONTHPLOT, "w");
|
||||
char buf[sizeof(month)];
|
||||
memcpy(buf, &month, sizeof(month));
|
||||
for(unsigned long i = 0; i < sizeof(month); i++) {
|
||||
file.write(buf[i]);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DayDataPoints AmsDataStorage::getDayData() {
|
||||
return day;
|
||||
}
|
||||
|
||||
MonthDataPoints AmsDataStorage::getMonthData() {
|
||||
return month;
|
||||
}
|
||||
|
||||
bool AmsDataStorage::setDayData(DayDataPoints& day) {
|
||||
if(day.version == 5 || day.version == 6) {
|
||||
this->day = day;
|
||||
this->day.version = 6;
|
||||
return true;
|
||||
} else if(day.version == 4) {
|
||||
this->day = day;
|
||||
this->day.accuracy = 1;
|
||||
this->day.version = 6;
|
||||
return true;
|
||||
} else if(day.version == 3) {
|
||||
this->day = day;
|
||||
for(uint8_t i = 0; i < 24; i++) this->day.hExport[i] = 0;
|
||||
this->day.accuracy = 1;
|
||||
this->day.version = 6;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AmsDataStorage::setMonthData(MonthDataPoints& month) {
|
||||
if(month.version == 6 || month.version == 7) {
|
||||
this->month = month;
|
||||
this->month.version = 7;
|
||||
return true;
|
||||
} else if(month.version == 5) {
|
||||
this->month = month;
|
||||
this->month.accuracy = 1;
|
||||
this->month.version = 7;
|
||||
return true;
|
||||
} else if(month.version == 4) {
|
||||
this->month = month;
|
||||
for(uint8_t i = 0; i < 31; i++) this->month.dExport[i] = 0;
|
||||
this->month.accuracy = 1;
|
||||
this->month.version = 7;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t AmsDataStorage::getDayAccuracy() {
|
||||
return day.accuracy;
|
||||
}
|
||||
|
||||
void AmsDataStorage::setDayAccuracy(uint8_t accuracy) {
|
||||
if(day.accuracy != accuracy) {
|
||||
double multiplier = pow(10, day.accuracy)/pow(10, accuracy);
|
||||
for(uint8_t i = 0; i < 24; i++) {
|
||||
day.hImport[i] = day.hImport[i] * multiplier;
|
||||
day.hExport[i] = day.hExport[i] * multiplier;
|
||||
}
|
||||
day.accuracy = accuracy;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t AmsDataStorage::getMonthAccuracy() {
|
||||
return month.accuracy;
|
||||
}
|
||||
|
||||
void AmsDataStorage::setMonthAccuracy(uint8_t accuracy) {
|
||||
if(month.accuracy != accuracy) {
|
||||
double multiplier = pow(10, month.accuracy)/pow(10, accuracy);
|
||||
for(uint8_t i = 0; i < 31; i++) {
|
||||
month.dImport[i] = month.dImport[i] * multiplier;
|
||||
month.dExport[i] = month.dExport[i] * multiplier;
|
||||
}
|
||||
month.accuracy = accuracy;
|
||||
}
|
||||
month.accuracy = accuracy;
|
||||
}
|
||||
|
||||
bool AmsDataStorage::isHappy() {
|
||||
return isDayHappy() && isMonthHappy();
|
||||
}
|
||||
|
||||
bool AmsDataStorage::isDayHappy() {
|
||||
if(tz == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if(now < FirmwareVersion::BuildEpoch) return false;
|
||||
|
||||
if(now < day.lastMeterReadTime) {
|
||||
return false;
|
||||
}
|
||||
if(now-day.lastMeterReadTime > 3600) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tmElements_t tm, last;
|
||||
breakTime(tz->toLocal(now), tm);
|
||||
breakTime(tz->toLocal(day.lastMeterReadTime), last);
|
||||
if(tm.Hour != last.Hour) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AmsDataStorage::isMonthHappy() {
|
||||
if(tz == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if(now < FirmwareVersion::BuildEpoch) return false;
|
||||
tmElements_t tm, last;
|
||||
|
||||
if(now < month.lastMeterReadTime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
breakTime(tz->toLocal(now), tm);
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
if(tm.Day != last.Day) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(now-month.lastMeterReadTime > 90100) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
double AmsDataStorage::getEstimatedImportCounter() {
|
||||
if(day.lastMeterReadTime == 0) return 0;
|
||||
|
||||
time_t now = time(nullptr);
|
||||
double hours = (now - day.lastMeterReadTime) / 3600.0;
|
||||
uint64_t total = 0;
|
||||
for(uint8_t i = 0; i < 24; i++) {
|
||||
total += getHourImport(i);
|
||||
}
|
||||
double perHour = total / 24.0;
|
||||
return (day.activeImport + (perHour * hours)) / 1000.0;
|
||||
}
|
||||
98
lib/AmsDecoder/include/Cosem.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _COSEM_H
|
||||
#define _COSEM_H
|
||||
|
||||
#include "lwip/def.h"
|
||||
|
||||
// Blue book, Table 2
|
||||
enum CosemType {
|
||||
CosemTypeNull = 0x00,
|
||||
CosemTypeArray = 0x01,
|
||||
CosemTypeStructure = 0x02,
|
||||
CosemTypeOctetString = 0x09,
|
||||
CosemTypeString = 0x0A,
|
||||
CosemTypeDLongSigned = 0x05,
|
||||
CosemTypeDLongUnsigned = 0x06,
|
||||
CosemTypeLongSigned = 0x10,
|
||||
CosemTypeLongUnsigned = 0x12,
|
||||
CosemTypeLong64Signed = 0x14,
|
||||
CosemTypeLong64Unsigned = 0x15,
|
||||
CosemTypeDateTime = 0x19
|
||||
};
|
||||
|
||||
struct CosemBasic {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemString {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
uint8_t data[];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemLongSigned {
|
||||
uint8_t type;
|
||||
int16_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemLongUnsigned {
|
||||
uint8_t type;
|
||||
uint16_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemDLongSigned {
|
||||
uint8_t type;
|
||||
int32_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemDLongUnsigned {
|
||||
uint8_t type;
|
||||
uint32_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemLong64Signed {
|
||||
uint8_t type;
|
||||
int64_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemLong64Unsigned {
|
||||
uint8_t type;
|
||||
uint64_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CosemDateTime {
|
||||
uint8_t type;
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t dayOfMonth;
|
||||
uint8_t dayOfWeek;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t hundredths;
|
||||
int16_t deviation;
|
||||
uint8_t status;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef union {
|
||||
struct CosemBasic base;
|
||||
struct CosemString str;
|
||||
struct CosemString oct;
|
||||
struct CosemLongSigned ls;
|
||||
struct CosemLongUnsigned lu;
|
||||
struct CosemDLongSigned dls;
|
||||
struct CosemDLongUnsigned dlu;
|
||||
struct CosemLong64Signed l64s;
|
||||
struct CosemLong64Unsigned l64u;
|
||||
struct CosemDateTime dt;
|
||||
} CosemData;
|
||||
|
||||
time_t decodeCosemDateTime(CosemDateTime timestamp);
|
||||
|
||||
#endif
|
||||
41
lib/AmsDecoder/include/DataParser.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DATAPASERSER_H
|
||||
#define _DATAPASERSER_H
|
||||
|
||||
#define DATA_TAG_NONE 0x00
|
||||
#define DATA_TAG_AUTO 0x01
|
||||
#define DATA_TAG_HDLC 0x7E
|
||||
#define DATA_TAG_LLC 0xE6
|
||||
#define DATA_TAG_DLMS 0x0F
|
||||
#define DATA_TAG_DSMR 0x2F
|
||||
#define DATA_TAG_MBUS 0x68
|
||||
#define DATA_TAG_GBT 0xE0
|
||||
#define DATA_TAG_GCM 0xDB
|
||||
#define DATA_TAG_SNRM 0x81
|
||||
#define DATA_TAG_AARQ 0x60
|
||||
#define DATA_TAG_AARE 0x61
|
||||
#define DATA_TAG_RES 0xC4 // Get Response
|
||||
|
||||
#define DATA_PARSE_OK 0
|
||||
#define DATA_PARSE_FAIL -1
|
||||
#define DATA_PARSE_INCOMPLETE -2
|
||||
#define DATA_PARSE_BOUNDRY_FLAG_MISSING -3
|
||||
#define DATA_PARSE_HEADER_CHECKSUM_ERROR -4
|
||||
#define DATA_PARSE_FOOTER_CHECKSUM_ERROR -5
|
||||
#define DATA_PARSE_INTERMEDIATE_SEGMENT -6
|
||||
#define DATA_PARSE_FINAL_SEGMENT -7
|
||||
#define DATA_PARSE_UNKNOWN_DATA -9
|
||||
|
||||
struct DataParserContext {
|
||||
uint8_t type;
|
||||
uint16_t length;
|
||||
time_t timestamp;
|
||||
uint8_t system_title[8];
|
||||
};
|
||||
|
||||
#endif
|
||||
19
lib/AmsDecoder/include/DataParsers.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DATAPASERSERS_H
|
||||
#define _DATAPASERSERS_H
|
||||
|
||||
#include "HdlcParser.h"
|
||||
#include "DlmsParser.h"
|
||||
#include "DsmrParser.h"
|
||||
#include "MbusParser.h"
|
||||
#include "GbtParser.h"
|
||||
#include "GcmParser.h"
|
||||
#include "LlcParser.h"
|
||||
|
||||
#endif
|
||||
|
||||
18
lib/AmsDecoder/include/DlmsParser.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DLMSPARSER_H
|
||||
#define _DLMSPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
class DLMSParser {
|
||||
public:
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx);
|
||||
};
|
||||
|
||||
#endif
|
||||
23
lib/AmsDecoder/include/DsmrParser.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DSMRPARSER_H
|
||||
#define _DSMRPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
class DSMRParser {
|
||||
public:
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx, bool verified);
|
||||
uint16_t getCrc();
|
||||
uint16_t getCrcCalc();
|
||||
private:
|
||||
uint16_t crc;
|
||||
uint16_t crc_calc;
|
||||
};
|
||||
|
||||
#endif
|
||||
32
lib/AmsDecoder/include/GbtParser.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GBTPARSER_H
|
||||
#define _GBTPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
#define GBT_TAG 0xE0
|
||||
|
||||
typedef struct GBTHeader {
|
||||
uint8_t flag;
|
||||
uint8_t control;
|
||||
uint16_t sequence;
|
||||
uint16_t sequenceAck;
|
||||
uint8_t size;
|
||||
} __attribute__((packed)) GBTHeader;
|
||||
|
||||
class GBTParser {
|
||||
public:
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx);
|
||||
private:
|
||||
uint8_t lastSequenceNumber = 0;
|
||||
uint16_t pos = 0;
|
||||
uint8_t *buf = NULL;
|
||||
};
|
||||
|
||||
#endif
|
||||
27
lib/AmsDecoder/include/GcmParser.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GCMPARSER_H
|
||||
#define _GCMPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
#define GCM_TAG 0xDB
|
||||
#define GCM_AUTH_FAILED -51
|
||||
#define GCM_DECRYPT_FAILED -52
|
||||
#define GCM_ENCRYPTION_KEY_FAILED -53
|
||||
|
||||
class GCMParser {
|
||||
public:
|
||||
GCMParser(uint8_t *encryption_key, uint8_t *authentication_key);
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx);
|
||||
private:
|
||||
uint8_t encryption_key[16];
|
||||
uint8_t authentication_key[16];
|
||||
};
|
||||
|
||||
#endif
|
||||
40
lib/AmsDecoder/include/HdlcParser.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HDLCPARSER_H
|
||||
#define _HDLCPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
#define HDLC_FLAG 0x7E
|
||||
|
||||
typedef struct HDLCHeader {
|
||||
uint8_t flag;
|
||||
uint16_t format;
|
||||
} __attribute__((packed)) HDLCHeader;
|
||||
|
||||
typedef struct HDLCFooter {
|
||||
uint16_t fcs;
|
||||
uint8_t flag;
|
||||
} __attribute__((packed)) HDLCFooter;
|
||||
|
||||
typedef struct HDLC3CtrlHcs {
|
||||
uint8_t control;
|
||||
uint16_t hcs;
|
||||
} __attribute__((packed)) HDLC3CtrlHcs;
|
||||
|
||||
class HDLCParser {
|
||||
public:
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx);
|
||||
|
||||
private:
|
||||
uint8_t lastSequenceNumber = 0;
|
||||
uint16_t pos = 0;
|
||||
uint8_t *buf = NULL;
|
||||
};
|
||||
|
||||
#endif
|
||||
24
lib/AmsDecoder/include/LlcParser.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LLCPARSER_H
|
||||
#define _LLCPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
typedef struct LLCHeader {
|
||||
uint8_t dst;
|
||||
uint8_t src;
|
||||
uint8_t control;
|
||||
} __attribute__((packed)) LLCHeader;
|
||||
|
||||
class LLCParser {
|
||||
public:
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx);
|
||||
};
|
||||
|
||||
#endif
|
||||
40
lib/AmsDecoder/include/MbusParser.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _MBUSPARSER_H
|
||||
#define _MBUSPARSER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DataParser.h"
|
||||
|
||||
#define MBUS_START 0x68
|
||||
#define MBUS_END 0x16
|
||||
#define MBUS_FRAME_LENGTH_NOT_EQUAL -41
|
||||
|
||||
typedef struct MbusHeader {
|
||||
uint8_t flag1;
|
||||
uint8_t len1;
|
||||
uint8_t len2;
|
||||
uint8_t flag2;
|
||||
} __attribute__((packed)) MbusHeader;
|
||||
|
||||
typedef struct MbusFooter {
|
||||
uint8_t fcs;
|
||||
uint8_t flag;
|
||||
} __attribute__((packed)) MbusFooter;
|
||||
|
||||
class MBUSParser {
|
||||
public:
|
||||
int8_t parse(uint8_t *buf, DataParserContext &ctx);
|
||||
uint16_t write(const uint8_t* d, DataParserContext &ctx);
|
||||
private:
|
||||
uint8_t lastSequenceNumber = 0;
|
||||
uint16_t pos = 0;
|
||||
uint8_t *buf = NULL;
|
||||
uint8_t checksum(const uint8_t* p, int len);
|
||||
};
|
||||
|
||||
#endif
|
||||
17
lib/AmsDecoder/include/crc.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CRC_H
|
||||
#define _CRC_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <stdint.h>
|
||||
|
||||
uint16_t crc16(const uint8_t* p, int len);
|
||||
uint16_t crc16_x25(const uint8_t* p, int len);
|
||||
uint16_t crc16_1021(const uint8_t* p, int len);
|
||||
|
||||
#endif
|
||||
14
lib/AmsDecoder/include/ntohll.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NTOHLL_H
|
||||
#define _NTOHLL_H
|
||||
|
||||
#include "lwip/def.h"
|
||||
|
||||
uint64_t ntohll(uint64_t x);
|
||||
|
||||
#endif
|
||||
30
lib/AmsDecoder/src/Cosem.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Cosem.h"
|
||||
#include "lwip/def.h"
|
||||
#include <TimeLib.h>
|
||||
|
||||
time_t decodeCosemDateTime(CosemDateTime timestamp) {
|
||||
tmElements_t tm;
|
||||
uint16_t year = ntohs(timestamp.year);
|
||||
if(year < 1970) return 0;
|
||||
tm.Year = year - 1970;
|
||||
tm.Month = timestamp.month;
|
||||
tm.Day = timestamp.dayOfMonth;
|
||||
tm.Hour = timestamp.hour;
|
||||
tm.Minute = timestamp.minute;
|
||||
tm.Second = timestamp.second;
|
||||
|
||||
//Serial.printf("\nY: %d, M: %d, D: %d, h: %d, m: %d, s: %d, deviation: 0x%2X, status: 0x%1X\n", tm.Year, tm.Month, tm.Day, tm.Hour, tm.Minute, tm.Second, timestamp.deviation, timestamp.status);
|
||||
|
||||
time_t time = makeTime(tm);
|
||||
int16_t deviation = ntohs(timestamp.deviation);
|
||||
if(deviation >= -720 && deviation <= 720) {
|
||||
time -= deviation * 60;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
44
lib/AmsDecoder/src/DlmsParser.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "DlmsParser.h"
|
||||
#include "Cosem.h"
|
||||
|
||||
int8_t DLMSParser::parse(uint8_t *buf, DataParserContext &ctx) {
|
||||
if(ctx.length < 6) return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
uint8_t* ptr = buf+1;
|
||||
ptr += 4; // Skip invoke ID and priority
|
||||
|
||||
CosemData* item = (CosemData*) ptr;
|
||||
if(item->base.type == CosemTypeOctetString) {
|
||||
if(item->base.length == 0x0C) {
|
||||
CosemDateTime* dateTime = (CosemDateTime*) (ptr+1);
|
||||
ctx.timestamp = decodeCosemDateTime(*dateTime);
|
||||
}
|
||||
uint8_t len = 5+14;
|
||||
ctx.length -= len;
|
||||
return len;
|
||||
} else if(item->base.type == CosemTypeNull) {
|
||||
ctx.timestamp = 0;
|
||||
uint8_t len = 5+1;
|
||||
ctx.length -= len;
|
||||
return len;
|
||||
} else if(item->base.type == CosemTypeDateTime) {
|
||||
CosemDateTime* dateTime = (CosemDateTime*) (ptr);
|
||||
ctx.timestamp = decodeCosemDateTime(*dateTime);
|
||||
uint8_t len = 5+13;
|
||||
ctx.length -= len;
|
||||
return len;
|
||||
} else if(item->base.type == 0x0C) { // Kamstrup bug...
|
||||
CosemDateTime* dateTime = (CosemDateTime*) (ptr);
|
||||
ctx.timestamp = decodeCosemDateTime(*dateTime);
|
||||
uint8_t len = 5+13;
|
||||
ctx.length -= len;
|
||||
return len;
|
||||
}
|
||||
return DATA_PARSE_UNKNOWN_DATA;
|
||||
}
|
||||
42
lib/AmsDecoder/src/DsmrParser.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "DsmrParser.h"
|
||||
#include "crc.h"
|
||||
#include "hexutils.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
int8_t DSMRParser::parse(uint8_t *buf, DataParserContext &ctx, bool verified) {
|
||||
uint16_t crcPos = 0;
|
||||
bool reachedEnd = verified;
|
||||
uint8_t lastByte = 0x00;
|
||||
for(int pos = 0; pos < ctx.length; pos++) {
|
||||
uint8_t b = *(buf+pos);
|
||||
if(pos == 0 && b != '/') return DATA_PARSE_BOUNDRY_FLAG_MISSING;
|
||||
if(pos > 0 && b == '!' && lastByte == '\n') crcPos = pos+1;
|
||||
if(crcPos > 0 && b == '\n') reachedEnd = true;
|
||||
lastByte = b;
|
||||
}
|
||||
if(!reachedEnd) return DATA_PARSE_INCOMPLETE;
|
||||
buf[ctx.length+1] = '\0';
|
||||
if(crcPos > 0) {
|
||||
crc_calc = crc16(buf, crcPos);
|
||||
crc = 0x0000;
|
||||
fromHex((uint8_t*) &crc, String((char*) buf+crcPos), 2);
|
||||
crc = ntohs(crc);
|
||||
|
||||
if(crc != crc_calc)
|
||||
return DATA_PARSE_FOOTER_CHECKSUM_ERROR;
|
||||
}
|
||||
return DATA_PARSE_OK;
|
||||
}
|
||||
|
||||
uint16_t DSMRParser::getCrc() {
|
||||
return crc;
|
||||
}
|
||||
uint16_t DSMRParser::getCrcCalc() {
|
||||
return crc_calc;
|
||||
}
|
||||
38
lib/AmsDecoder/src/GbtParser.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "GbtParser.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
int8_t GBTParser::parse(uint8_t *d, DataParserContext &ctx) {
|
||||
GBTHeader* h = (GBTHeader*) (d);
|
||||
uint16_t sequence = ntohs(h->sequence);
|
||||
|
||||
if(h->flag != GBT_TAG) return DATA_PARSE_BOUNDRY_FLAG_MISSING;
|
||||
|
||||
if(sequence == 1) {
|
||||
if(buf == NULL) buf = (uint8_t *)malloc((size_t)1024); // TODO find out from first package ?
|
||||
pos = 0;
|
||||
} else if(lastSequenceNumber != sequence-1) {
|
||||
return DATA_PARSE_FAIL;
|
||||
}
|
||||
|
||||
if(buf == NULL) return DATA_PARSE_FAIL;
|
||||
|
||||
uint8_t* ptr = (uint8_t*) &h[1];
|
||||
memcpy(buf + pos, ptr, h->size);
|
||||
pos += h->size;
|
||||
lastSequenceNumber = sequence;
|
||||
|
||||
if((h->control & 0x80) == 0x00) {
|
||||
return DATA_PARSE_INTERMEDIATE_SEGMENT;
|
||||
} else {
|
||||
memcpy((uint8_t *) d, buf, pos);
|
||||
}
|
||||
ctx.length = pos;
|
||||
return DATA_PARSE_OK;
|
||||
|
||||
}
|
||||
145
lib/AmsDecoder/src/GcmParser.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "GcmParser.h"
|
||||
#include "lwip/def.h"
|
||||
#if defined(ESP8266)
|
||||
#include "bearssl/bearssl.h"
|
||||
#elif defined(ESP32)
|
||||
#include "mbedtls/gcm.h"
|
||||
#endif
|
||||
|
||||
GCMParser::GCMParser(uint8_t *encryption_key, uint8_t *authentication_key) {
|
||||
memcpy(this->encryption_key, encryption_key, 16);
|
||||
memcpy(this->authentication_key, authentication_key, 16);
|
||||
}
|
||||
|
||||
int8_t GCMParser::parse(uint8_t *d, DataParserContext &ctx) {
|
||||
if(ctx.length < 12) return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
uint8_t* ptr = (uint8_t*) d;
|
||||
if(*ptr != GCM_TAG) return DATA_PARSE_BOUNDRY_FLAG_MISSING;
|
||||
ptr++;
|
||||
// Encrypted APDU
|
||||
// http://www.weigu.lu/tutorials/sensors2bus/04_encryption/index.html
|
||||
|
||||
uint8_t systemTitleLength = *ptr;
|
||||
ptr++;
|
||||
|
||||
uint8_t initialization_vector[12];
|
||||
memcpy(ctx.system_title, ptr, systemTitleLength);
|
||||
memcpy(initialization_vector, ctx.system_title, systemTitleLength);
|
||||
|
||||
uint32_t len = 0;
|
||||
uint32_t headersize = 2 + systemTitleLength;
|
||||
ptr += systemTitleLength;
|
||||
if(((*ptr) & 0xFF) == 0x81) {
|
||||
// 1-byte payload length
|
||||
ptr++;
|
||||
len = *ptr++;
|
||||
headersize += 2;
|
||||
} else if(((*ptr) & 0xFF) == 0x82) {
|
||||
// 2-byte payload length
|
||||
ptr++;
|
||||
len = *ptr++ << 8;
|
||||
len |= *ptr++;
|
||||
headersize += 3;
|
||||
} else if(((*ptr) & 0xFF) == 0x84) {
|
||||
// 4-byte payload length
|
||||
ptr++;
|
||||
len = *ptr++ << 24;
|
||||
len |= *ptr++ << 16;
|
||||
len |= *ptr++ << 8;
|
||||
len |= *ptr++;
|
||||
headersize += 5;
|
||||
} else {
|
||||
len = *ptr++;
|
||||
headersize++;
|
||||
}
|
||||
if(len + headersize > ctx.length)
|
||||
return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
uint8_t additional_authenticated_data[17];
|
||||
memcpy(additional_authenticated_data, ptr, 1);
|
||||
|
||||
// Security tag
|
||||
uint8_t sec = *ptr;
|
||||
ptr++;
|
||||
headersize++;
|
||||
|
||||
// Frame counter
|
||||
memcpy(initialization_vector + 8, ptr, 4);
|
||||
ptr += 4;
|
||||
headersize += 4;
|
||||
|
||||
int footersize = 0;
|
||||
|
||||
// Authentication enabled
|
||||
bool authenticate = false;
|
||||
uint8_t authentication_tag[12];
|
||||
uint8_t authkeylen = 0, aadlen = 0;
|
||||
if((sec & 0x10) == 0x10) {
|
||||
authkeylen = 12;
|
||||
aadlen = 17;
|
||||
footersize += authkeylen;
|
||||
memcpy(additional_authenticated_data + 1, authentication_key, 16);
|
||||
memcpy(authentication_tag, ptr + len - footersize - 5, authkeylen);
|
||||
for(uint8_t i; i < 16; i++) authenticate |= authentication_key[i] > 0;
|
||||
}
|
||||
|
||||
#if defined(ESP8266)
|
||||
br_gcm_context gcmCtx;
|
||||
br_aes_ct_ctr_keys bc;
|
||||
br_aes_ct_ctr_init(&bc, encryption_key, 16);
|
||||
br_gcm_init(&gcmCtx, &bc.vtable, br_ghash_ctmul32);
|
||||
br_gcm_reset(&gcmCtx, initialization_vector, sizeof(initialization_vector));
|
||||
if(authenticate) {
|
||||
br_gcm_aad_inject(&gcmCtx, additional_authenticated_data, aadlen);
|
||||
}
|
||||
br_gcm_flip(&gcmCtx);
|
||||
br_gcm_run(&gcmCtx, 0, (void*) (ptr), len - authkeylen - 5); // 5 == security tag and frame counter
|
||||
if(authkeylen > 0 && br_gcm_check_tag_trunc(&gcmCtx, authentication_tag, authkeylen) != 1) {
|
||||
return GCM_AUTH_FAILED;
|
||||
}
|
||||
#elif defined(ESP32)
|
||||
uint8_t cipher_text[len - authkeylen - 5];
|
||||
memcpy(cipher_text, ptr, len - authkeylen - 5);
|
||||
|
||||
mbedtls_gcm_context m_ctx;
|
||||
mbedtls_gcm_init(&m_ctx);
|
||||
int success = mbedtls_gcm_setkey(&m_ctx, MBEDTLS_CIPHER_ID_AES, encryption_key, 128);
|
||||
if (0 != success) {
|
||||
return GCM_ENCRYPTION_KEY_FAILED;
|
||||
}
|
||||
if (authenticate) {
|
||||
success = mbedtls_gcm_auth_decrypt(&m_ctx, sizeof(cipher_text), initialization_vector, sizeof(initialization_vector),
|
||||
additional_authenticated_data, aadlen, authentication_tag, authkeylen,
|
||||
cipher_text, (unsigned char*)(ptr));
|
||||
if (authkeylen > 0 && success == MBEDTLS_ERR_GCM_AUTH_FAILED) {
|
||||
mbedtls_gcm_free(&m_ctx);
|
||||
return GCM_AUTH_FAILED;
|
||||
} else if(success == MBEDTLS_ERR_GCM_BAD_INPUT) {
|
||||
mbedtls_gcm_free(&m_ctx);
|
||||
return GCM_DECRYPT_FAILED;
|
||||
}
|
||||
} else {
|
||||
success = mbedtls_gcm_starts(&m_ctx, MBEDTLS_GCM_DECRYPT, initialization_vector, sizeof(initialization_vector),NULL, 0);
|
||||
if (0 != success) {
|
||||
mbedtls_gcm_free(&m_ctx);
|
||||
return GCM_DECRYPT_FAILED;
|
||||
}
|
||||
success = mbedtls_gcm_update(&m_ctx, sizeof(cipher_text), cipher_text, (unsigned char*)(ptr));
|
||||
if (0 != success) {
|
||||
mbedtls_gcm_free(&m_ctx);
|
||||
return GCM_DECRYPT_FAILED;
|
||||
}
|
||||
}
|
||||
mbedtls_gcm_free(&m_ctx);
|
||||
#endif
|
||||
|
||||
ctx.length -= footersize + headersize;
|
||||
return ptr-d;
|
||||
}
|
||||
95
lib/AmsDecoder/src/HdlcParser.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "HdlcParser.h"
|
||||
#include "lwip/def.h"
|
||||
#include "crc.h"
|
||||
|
||||
int8_t HDLCParser::parse(uint8_t *d, DataParserContext &ctx) {
|
||||
int len;
|
||||
|
||||
uint8_t* ptr;
|
||||
if(ctx.length < 3)
|
||||
return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
HDLCHeader* h = (HDLCHeader*) d;
|
||||
ptr = (uint8_t*) &h[1];
|
||||
|
||||
// Frame format type 3
|
||||
if((h->format & 0xF0) == 0xA0) {
|
||||
// Length field (11 lsb of format)
|
||||
len = (ntohs(h->format) & 0x7FF) + 2;
|
||||
if(len > ctx.length)
|
||||
return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
HDLCFooter* f = (HDLCFooter*) (d + len - sizeof *f);
|
||||
|
||||
// First and last byte should be HDLC_FLAG
|
||||
if(h->flag != HDLC_FLAG || f->flag != HDLC_FLAG)
|
||||
return DATA_PARSE_BOUNDRY_FLAG_MISSING;
|
||||
|
||||
// Verify FCS
|
||||
if(ntohs(f->fcs) != crc16_x25(d + 1, len - sizeof *f - 1))
|
||||
return DATA_PARSE_FOOTER_CHECKSUM_ERROR;
|
||||
|
||||
// Skip destination address, LSB marks last byte
|
||||
while(((*ptr) & 0x01) == 0x00) {
|
||||
ptr++;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
// Skip source address, LSB marks last byte
|
||||
while(((*ptr) & 0x01) == 0x00) {
|
||||
ptr++;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
HDLC3CtrlHcs* t3 = (HDLC3CtrlHcs*) (ptr);
|
||||
|
||||
// Verify HCS
|
||||
if(ntohs(t3->hcs) != crc16_x25(d + 1, ptr-d))
|
||||
return DATA_PARSE_HEADER_CHECKSUM_ERROR;
|
||||
ptr += 3;
|
||||
|
||||
// Exclude all of header and 3 byte footer
|
||||
ctx.length -= ptr-d;
|
||||
if(ctx.length > 1) {
|
||||
ctx.length -= 3;
|
||||
}
|
||||
|
||||
// Payload incomplete
|
||||
if((h->format & 0x08) == 0x08) {
|
||||
if(lastSequenceNumber == 0) {
|
||||
if(buf == NULL) buf = (uint8_t *)malloc((size_t)1024);
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
if(buf == NULL) return DATA_PARSE_FAIL;
|
||||
|
||||
memcpy(buf + pos, ptr+3, ctx.length); // +3 to skip LLC
|
||||
pos += ctx.length;
|
||||
|
||||
lastSequenceNumber++;
|
||||
return DATA_PARSE_INTERMEDIATE_SEGMENT;
|
||||
} else if(lastSequenceNumber > 0) {
|
||||
lastSequenceNumber = 0;
|
||||
if(buf == NULL) return DATA_PARSE_FAIL;
|
||||
|
||||
memcpy(buf + pos, ptr+3, ctx.length); // +3 to skip LLC
|
||||
pos += ctx.length;
|
||||
|
||||
memcpy((uint8_t *) d, buf, pos);
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
ctx.length = pos;
|
||||
pos = 0;
|
||||
return DATA_PARSE_OK;
|
||||
} else {
|
||||
return ptr-d;
|
||||
}
|
||||
}
|
||||
return DATA_PARSE_UNKNOWN_DATA;
|
||||
}
|
||||
12
lib/AmsDecoder/src/LlcParser.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "LlcParser.h"
|
||||
|
||||
int8_t LLCParser::parse(uint8_t *buf, DataParserContext &ctx) {
|
||||
ctx.length -= 3;
|
||||
return 3;
|
||||
}
|
||||
93
lib/AmsDecoder/src/MbusParser.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "MbusParser.h"
|
||||
|
||||
int8_t MBUSParser::parse(uint8_t *d, DataParserContext &ctx) {
|
||||
int len;
|
||||
int headersize = 3;
|
||||
int footersize = 1;
|
||||
|
||||
uint8_t* ptr;
|
||||
|
||||
// https://m-bus.com/documentation-wired/06-application-layer
|
||||
if(ctx.length < 4)
|
||||
return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
MbusHeader* mh = (MbusHeader*) d;
|
||||
if(mh->flag1 != MBUS_START || mh->flag2 != MBUS_START)
|
||||
return DATA_PARSE_BOUNDRY_FLAG_MISSING;
|
||||
|
||||
// First two bytes is 1-byte length value repeated. Only used for last segment
|
||||
if(mh->len1 != mh->len2)
|
||||
return MBUS_FRAME_LENGTH_NOT_EQUAL;
|
||||
len = mh->len1;
|
||||
ptr = (uint8_t*) &mh[1];
|
||||
headersize = 4;
|
||||
footersize = 2;
|
||||
|
||||
if(len == 0x00)
|
||||
len = ctx.length - headersize - footersize;
|
||||
// Payload can max be 255 bytes, so I think the following case is only valid for austrian meters
|
||||
if(len < headersize)
|
||||
len += 256;
|
||||
|
||||
if((headersize + footersize + len) > ctx.length)
|
||||
return DATA_PARSE_INCOMPLETE;
|
||||
|
||||
MbusFooter* mf = (MbusFooter*) (d + len + headersize);
|
||||
if(mf->flag != MBUS_END)
|
||||
return DATA_PARSE_BOUNDRY_FLAG_MISSING;
|
||||
if(checksum(d + headersize, len) != mf->fcs)
|
||||
return DATA_PARSE_FOOTER_CHECKSUM_ERROR;
|
||||
|
||||
ptr += 2; len -= 2;
|
||||
|
||||
// Control information field
|
||||
uint8_t ci = *ptr;
|
||||
|
||||
// Skip CI, STSAP and DTSAP
|
||||
ptr += 3; len -= 3;
|
||||
|
||||
// Bits 7 6 5 4 3 2 1 0
|
||||
// 0 0 0 Finished Sequence number
|
||||
uint8_t sequenceNumber = (ci & 0x0F);
|
||||
if((ci & 0x10) == 0x00) { // Not finished yet
|
||||
if(sequenceNumber == 0) {
|
||||
if(buf == NULL) buf = (uint8_t *)malloc((size_t)1024); // TODO find out from first package ?
|
||||
pos = 0;
|
||||
} else if(buf == NULL || pos + len > 1024 || sequenceNumber != (lastSequenceNumber + 1)) {
|
||||
return DATA_PARSE_FAIL;
|
||||
}
|
||||
memcpy(buf+pos, ptr, len);
|
||||
pos += len;
|
||||
lastSequenceNumber = sequenceNumber;
|
||||
return DATA_PARSE_INTERMEDIATE_SEGMENT;
|
||||
} else if(sequenceNumber > 0) { // This is the last frame of multiple, assembly needed
|
||||
if(buf == NULL || pos + len > 1024 || sequenceNumber != (lastSequenceNumber + 1)) {
|
||||
return DATA_PARSE_FAIL;
|
||||
}
|
||||
memcpy(buf+pos, ptr, len);
|
||||
pos += len;
|
||||
return DATA_PARSE_FINAL_SEGMENT;
|
||||
}
|
||||
return ptr-d;
|
||||
}
|
||||
|
||||
uint16_t MBUSParser::write(const uint8_t* d, DataParserContext &ctx) {
|
||||
if(buf != NULL) {
|
||||
memcpy((uint8_t *) d, buf, pos);
|
||||
ctx.length = pos;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t MBUSParser::checksum(const uint8_t* p, int len) {
|
||||
uint8_t ret = 0;
|
||||
while(len--)
|
||||
ret += *p++;
|
||||
return ret;
|
||||
}
|
||||
54
lib/AmsDecoder/src/crc.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
uint16_t crc16_x25(const uint8_t* p, int len)
|
||||
{
|
||||
uint16_t crc = UINT16_MAX;
|
||||
|
||||
while(len--)
|
||||
for (uint16_t i = 0, d = 0xff & *p++; i < 8; i++, d >>= 1)
|
||||
crc = ((crc & 1) ^ (d & 1)) ? (crc >> 1) ^ 0x8408 : (crc >> 1);
|
||||
|
||||
return (~crc << 8) | (~crc >> 8 & 0xff);
|
||||
}
|
||||
|
||||
uint16_t crc16 (const uint8_t *p, int len) {
|
||||
uint16_t crc = 0;
|
||||
|
||||
while (len--) {
|
||||
uint8_t i;
|
||||
crc ^= *p++;
|
||||
for (i = 0 ; i < 8 ; ++i) {
|
||||
if (crc & 1)
|
||||
crc = (crc >> 1) ^ 0xa001;
|
||||
else
|
||||
crc = (crc >> 1);
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
uint16_t crc16_1021(const uint8_t *p, int len) {
|
||||
uint32_t crc = 0x0000;
|
||||
for(int i = 0; i < len; i++) {
|
||||
int mask = 0x80;
|
||||
while(mask > 0) {
|
||||
crc <<= 1;
|
||||
if (p[i] & mask){
|
||||
crc |= 1;
|
||||
}
|
||||
mask>>=1;
|
||||
if (crc & 0x10000) {
|
||||
crc &= 0xffff;
|
||||
crc ^= 0x1021;
|
||||
}
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
11
lib/AmsDecoder/src/ntohll.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ntohll.h"
|
||||
|
||||
uint64_t ntohll(uint64_t x) {
|
||||
return (((uint64_t)ntohl((uint32_t)x)) << 32) + ntohl(x >> 32);
|
||||
}
|
||||
70
lib/AmsMqttHandler/include/AmsMqttHandler.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AMSMQTTHANDLER_H
|
||||
#define _AMSMQTTHANDLER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <MQTT.h>
|
||||
#include "AmsData.h"
|
||||
#include "AmsConfiguration.h"
|
||||
#include "EnergyAccounting.h"
|
||||
#include "HwTools.h"
|
||||
#include "PriceService.h"
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <esp_task_wdt.h>
|
||||
#endif
|
||||
|
||||
class AmsMqttHandler {
|
||||
public:
|
||||
AmsMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf) {
|
||||
this->mqttConfig = mqttConfig;
|
||||
this->mqttConfigChanged = true;
|
||||
this->debugger = debugger;
|
||||
this->json = buf;
|
||||
mqtt.dropOverflow(true);
|
||||
};
|
||||
|
||||
void setCaVerification(bool);
|
||||
void setConfig(MqttConfig& mqttConfig);
|
||||
|
||||
bool connect();
|
||||
void disconnect();
|
||||
lwmqtt_err_t lastError();
|
||||
bool connected();
|
||||
bool loop();
|
||||
|
||||
virtual uint8_t getFormat() { return 0; };
|
||||
|
||||
virtual bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) { return false; };
|
||||
virtual bool publishTemperatures(AmsConfiguration*, HwTools*) { return false; };
|
||||
virtual bool publishPrices(PriceService* ps) { return false; };
|
||||
virtual bool publishSystem(HwTools*, PriceService*, EnergyAccounting*) { return false; };
|
||||
virtual bool publishRaw(String data) { return false; };
|
||||
virtual void onMessage(String &topic, String &payload) {};
|
||||
|
||||
virtual ~AmsMqttHandler() {
|
||||
if(mqttClient != NULL) {
|
||||
mqttClient->stop();
|
||||
delete mqttClient;
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
RemoteDebug* debugger;
|
||||
MqttConfig mqttConfig;
|
||||
bool mqttConfigChanged = true;
|
||||
MQTTClient mqtt = MQTTClient(256);
|
||||
unsigned long lastMqttRetry = -10000;
|
||||
bool caVerification = true;
|
||||
WiFiClient *mqttClient = NULL;
|
||||
WiFiClientSecure *mqttSecureClient = NULL;
|
||||
char* json;
|
||||
uint16_t BufferSize = 2048;
|
||||
};
|
||||
|
||||
#endif
|
||||
167
lib/AmsMqttHandler/src/AmsMqttHandler.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AmsMqttHandler.h"
|
||||
#include "FirmwareVersion.h"
|
||||
#include "AmsStorage.h"
|
||||
#include "LittleFS.h"
|
||||
|
||||
void AmsMqttHandler::setCaVerification(bool caVerification) {
|
||||
this->caVerification = caVerification;
|
||||
}
|
||||
|
||||
void AmsMqttHandler::setConfig(MqttConfig& mqttConfig) {
|
||||
this->mqttConfig = mqttConfig;
|
||||
this->mqttConfigChanged = true;
|
||||
}
|
||||
|
||||
bool AmsMqttHandler::connect() {
|
||||
if(millis() - lastMqttRetry < 10000) {
|
||||
yield();
|
||||
return false;
|
||||
}
|
||||
lastMqttRetry = millis();
|
||||
|
||||
time_t epoch = time(nullptr);
|
||||
|
||||
WiFiClient *actualClient = NULL;
|
||||
|
||||
if(mqttConfig.ssl) {
|
||||
if(epoch < FirmwareVersion::BuildEpoch) {
|
||||
return false;
|
||||
}
|
||||
if(mqttSecureClient == NULL) {
|
||||
mqttSecureClient = new WiFiClientSecure();
|
||||
#if defined(ESP8266)
|
||||
mqttSecureClient->setBufferSizes(512, 512);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(mqttConfigChanged) {
|
||||
if(caVerification && LittleFS.begin()) {
|
||||
File file;
|
||||
|
||||
if(LittleFS.exists(FILE_MQTT_CA)) {
|
||||
file = LittleFS.open(FILE_MQTT_CA, (char*) "r");
|
||||
#if defined(ESP8266)
|
||||
BearSSL::X509List *serverTrustedCA = new BearSSL::X509List(file);
|
||||
mqttSecureClient->setTrustAnchors(serverTrustedCA);
|
||||
#elif defined(ESP32)
|
||||
if(!mqttSecureClient->loadCACert(file, file.size())) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
file.close();
|
||||
} else {
|
||||
mqttSecureClient->setInsecure();
|
||||
}
|
||||
|
||||
#if defined(ESP8266)
|
||||
if(LittleFS.exists(FILE_MQTT_CERT) && LittleFS.exists(FILE_MQTT_KEY)) {
|
||||
file = LittleFS.open(FILE_MQTT_CERT, (char*) "r");
|
||||
BearSSL::X509List *serverCertList = new BearSSL::X509List(file);
|
||||
file.close();
|
||||
|
||||
file = LittleFS.open(FILE_MQTT_KEY, (char*) "r");
|
||||
BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file);
|
||||
file.close();
|
||||
|
||||
mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ESP32)
|
||||
if(LittleFS.exists(FILE_MQTT_CERT)) {
|
||||
file = LittleFS.open(FILE_MQTT_CERT, (char*) "r");
|
||||
mqttSecureClient->loadCertificate(file, file.size());
|
||||
file.close();
|
||||
}
|
||||
|
||||
if(LittleFS.exists(FILE_MQTT_KEY)) {
|
||||
file = LittleFS.open(FILE_MQTT_KEY, (char*) "r");
|
||||
mqttSecureClient->loadPrivateKey(file, file.size());
|
||||
file.close();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
mqttSecureClient->setInsecure();
|
||||
}
|
||||
}
|
||||
actualClient = mqttSecureClient;
|
||||
} else {
|
||||
if(mqttClient == NULL) {
|
||||
mqttClient = new WiFiClient();
|
||||
}
|
||||
actualClient = mqttClient;
|
||||
}
|
||||
|
||||
mqttConfigChanged = false;
|
||||
mqtt.begin(mqttConfig.host, mqttConfig.port, *actualClient);
|
||||
String statusTopic = String(mqttConfig.publishTopic) + "/status";
|
||||
mqtt.setWill(statusTopic.c_str(), "offline", true, 0);
|
||||
|
||||
#if defined(ESP8266)
|
||||
if(mqttSecureClient) {
|
||||
time_t epoch = time(nullptr);
|
||||
mqttSecureClient->setX509Time(epoch);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Connect to a unsecure or secure MQTT server
|
||||
if ((strlen(mqttConfig.username) == 0 && mqtt.connect(mqttConfig.clientId)) ||
|
||||
(strlen(mqttConfig.username) > 0 && mqtt.connect(mqttConfig.clientId, mqttConfig.username, mqttConfig.password))) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Successfully connected to MQTT\n"));
|
||||
mqtt.onMessage(std::bind(&AmsMqttHandler::onMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
if(strlen(mqttConfig.subscribeTopic) > 0) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR(" Subscribing to [%s]\n"), mqttConfig.subscribeTopic);
|
||||
if(!mqtt.subscribe(mqttConfig.subscribeTopic)) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR(" Unable to subscribe to to [%s]\n"), mqttConfig.subscribeTopic);
|
||||
}
|
||||
}
|
||||
mqtt.publish(statusTopic, "online", true, 0);
|
||||
mqtt.loop();
|
||||
return true;
|
||||
} else {
|
||||
if (debugger->isActive(RemoteDebug::ERROR)) {
|
||||
debugger->printf_P(PSTR("Failed to connect to MQTT: %d\n"), mqtt.lastError());
|
||||
#if defined(ESP8266)
|
||||
if(mqttSecureClient) {
|
||||
mqttSecureClient->getLastSSLError((char*) json, BufferSize);
|
||||
debugger->println((char*) json);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AmsMqttHandler::disconnect() {
|
||||
mqtt.disconnect();
|
||||
mqtt.loop();
|
||||
delay(10);
|
||||
yield();
|
||||
}
|
||||
|
||||
lwmqtt_err_t AmsMqttHandler::lastError() {
|
||||
return mqtt.lastError();
|
||||
}
|
||||
|
||||
bool AmsMqttHandler::connected() {
|
||||
return mqtt.connected();
|
||||
}
|
||||
|
||||
bool AmsMqttHandler::loop() {
|
||||
bool ret = mqtt.loop();
|
||||
delay(10);
|
||||
yield();
|
||||
#if defined(ESP32)
|
||||
esp_task_wdt_reset();
|
||||
#elif defined(ESP8266)
|
||||
ESP.wdtFeed();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
114
lib/CloudConnector/include/CloudConnector.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CLOUDCONNECTOR_H
|
||||
#define _CLOUDCONNECTOR_H
|
||||
|
||||
#include "RemoteDebug.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/net.h"
|
||||
#include "mbedtls/esp_debug.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/rsa.h"
|
||||
#include "AmsConfiguration.h"
|
||||
#include "AmsData.h"
|
||||
#include "EnergyAccounting.h"
|
||||
#include "HwTools.h"
|
||||
#include "AmsMqttHandler.h"
|
||||
#include "ConnectionHandler.h"
|
||||
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#elif defined(ESP32) // ARDUINO_ARCH_ESP32
|
||||
#include <HTTPClient.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include <WiFiUdp.h>
|
||||
#else
|
||||
#warning "Unsupported board type"
|
||||
#endif
|
||||
|
||||
#define CC_BUF_SIZE 2048
|
||||
|
||||
static const char CC_JSON_POWER[] PROGMEM = ",\"%s\":{\"P\":%lu,\"Q\":%lu}";
|
||||
static const char CC_JSON_POWER_LIST3[] PROGMEM = ",\"%s\":{\"P\":%lu,\"Q\":%lu,\"tP\":%.3f,\"tQ\":%.3f}";
|
||||
static const char CC_JSON_PHASE[] PROGMEM = "%s\"%d\":{\"u\":%.2f,\"i\":%s}";
|
||||
static const char CC_JSON_PHASE_LIST4[] PROGMEM = "%s\"%d\":{\"u\":%.2f,\"i\":%s,\"Pim\":%lu,\"Pex\":%lu,\"pf\":%.2f}";
|
||||
static const char CC_JSON_STATUS[] PROGMEM = ",\"status\":{\"esp\":{\"state\":%d,\"error\":%d},\"han\":{\"state\":%d,\"error\":%d},\"wifi\":{\"state\":%d,\"error\":%d},\"mqtt\":{\"state\":%d,\"error\":%d}}";
|
||||
static const char CC_JSON_INIT[] PROGMEM = ",\"init\":{\"mac\":\"%s\",\"apmac\":\"%s\",\"version\":\"%s\",\"boardType\":%d,\"bootReason\":%d,\"bootCause\":%d,\"utcOffset\":%d},\"meter\":{\"manufacturerId\":%d,\"manufacturer\":\"%s\",\"model\":\"%s\",\"id\":\"%s\",\"system\":\"%s\",\"fuse\":%d,\"import\":%d,\"export\":%d},\"network\":{\"ip\":\"%s\",\"mask\":\"%s\",\"gw\":\"%s\",\"dns1\":\"%s\",\"dns2\":\"%s\"}";
|
||||
|
||||
struct CloudData {
|
||||
uint8_t type;
|
||||
int16_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
class CloudConnector {
|
||||
public:
|
||||
CloudConnector(RemoteDebug*);
|
||||
bool setup(CloudConfig& config, MeterConfig& meter, SystemConfig& system, HwTools* hw, ResetDataContainer* rdc);
|
||||
void setMqttHandler(AmsMqttHandler* mqttHandler);
|
||||
void update(AmsData& data, EnergyAccounting& ea);
|
||||
void forceUpdate();
|
||||
void setTimezone(Timezone* tz);
|
||||
void setConnectionHandler(ConnectionHandler* ch);
|
||||
|
||||
private:
|
||||
RemoteDebug* debugger = NULL;
|
||||
HwTools* hw = NULL;
|
||||
ConnectionHandler* ch = NULL;
|
||||
ResetDataContainer* rdc = NULL;
|
||||
Timezone* tz = NULL;
|
||||
AmsMqttHandler* mqttHandler = NULL;
|
||||
CloudConfig config;
|
||||
HTTPClient http;
|
||||
WiFiUDP udp;
|
||||
int maxPwr = 0;
|
||||
uint8_t boardType = 0;
|
||||
uint8_t distributionSystem = 0;
|
||||
uint16_t mainFuse = 0, productionCapacity = 0;
|
||||
|
||||
String uuid;
|
||||
bool initialized = false;
|
||||
unsigned long lastUpdate = 0;
|
||||
char mac[18];
|
||||
char apmac[18];
|
||||
|
||||
char clearBuffer[CC_BUF_SIZE];
|
||||
unsigned char encryptedBuffer[256];
|
||||
mbedtls_rsa_context* rsa = nullptr;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
mbedtls_entropy_context entropy;
|
||||
char* pers = "amsreader";
|
||||
|
||||
bool init();
|
||||
void debugPrint(byte *buffer, int start, int length);
|
||||
|
||||
String meterManufacturer(uint8_t type) {
|
||||
switch(type) {
|
||||
case AmsTypeAidon: return F("Aidon");
|
||||
case AmsTypeKaifa: return F("Kaifa");
|
||||
case AmsTypeKamstrup: return F("Kamstrup");
|
||||
case AmsTypeIskra: return F("Iskra");
|
||||
case AmsTypeLandisGyr: return F("Landis+Gyr");
|
||||
case AmsTypeSagemcom: return F("Sagemcom");
|
||||
}
|
||||
return F("");
|
||||
}
|
||||
|
||||
String distributionSystemStr(uint8_t ds) {
|
||||
switch(ds) {
|
||||
case 1: return F("IT");
|
||||
case 2: return F("TN");
|
||||
}
|
||||
return F("");
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
409
lib/CloudConnector/src/CloudConnector.cpp
Normal file
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CloudConnector.h"
|
||||
#include "FirmwareVersion.h"
|
||||
#include "crc.h"
|
||||
#include "Uptime.h"
|
||||
#include "hexutils.h"
|
||||
#if defined(ESP32)
|
||||
#include <ESPRandom.h>
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
||||
#include "esp32/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#endif
|
||||
|
||||
CloudConnector::CloudConnector(RemoteDebug* debugger) {
|
||||
this->debugger = debugger;
|
||||
|
||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
http.setReuse(false);
|
||||
http.setTimeout(60000);
|
||||
http.setUserAgent("ams2mqtt/" + String(FirmwareVersion::VersionString));
|
||||
http.useHTTP10(true);
|
||||
|
||||
uint8_t mac[6];
|
||||
uint8_t apmac[6];
|
||||
|
||||
#if defined(ESP8266)
|
||||
wifi_get_macaddr(STATION_IF, mac);
|
||||
wifi_get_macaddr(SOFTAP_IF, apmac);
|
||||
#elif defined(ESP32)
|
||||
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_STA, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_AP, apmac);
|
||||
#endif
|
||||
sprintf_P(this->mac, PSTR("%02X:%02X:%02X:%02X:%02X:%02X"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
sprintf_P(this->apmac, PSTR("%02X:%02X:%02X:%02X:%02X:%02X"), apmac[0], apmac[1], apmac[2], apmac[3], apmac[4], apmac[5]);
|
||||
}
|
||||
|
||||
bool CloudConnector::setup(CloudConfig& config, MeterConfig& meter, SystemConfig& system, HwTools* hw, ResetDataContainer* rdc) {
|
||||
bool ret = false;
|
||||
#if defined(ESP32)
|
||||
if(!ESPRandom::isValidV4Uuid(config.clientId)) {
|
||||
ESPRandom::uuid4(config.clientId);
|
||||
ret = true;
|
||||
}
|
||||
uuid = ESPRandom::uuidToString(config.clientId);
|
||||
#endif
|
||||
|
||||
this->config = config;
|
||||
this->hw = hw;
|
||||
this->rdc = rdc;
|
||||
|
||||
this->boardType = system.boardType;
|
||||
|
||||
this->maxPwr = 0;
|
||||
this->distributionSystem = meter.distributionSystem;
|
||||
this->mainFuse = meter.mainFuse;
|
||||
this->productionCapacity = meter.productionCapacity;
|
||||
|
||||
this->initialized = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CloudConnector::setMqttHandler(AmsMqttHandler* mqttHandler) {
|
||||
this->mqttHandler = mqttHandler;
|
||||
}
|
||||
|
||||
bool CloudConnector::init() {
|
||||
if(config.enabled) {
|
||||
//if(config.port == 0)
|
||||
config.port = 7443;
|
||||
//if(strlen(config.hostname) == 0)
|
||||
strcpy_P(config.hostname, PSTR("cloud.amsleser.no"));
|
||||
|
||||
snprintf_P(clearBuffer, CC_BUF_SIZE, PSTR("http://%s/hub/cloud/public.key"), config.hostname);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(CloudConnector) Downloading public key from %s\n"), clearBuffer);
|
||||
#if defined(ESP8266)
|
||||
WiFiClient client;
|
||||
client.setTimeout(5000);
|
||||
if(http.begin(client, clearBuffer)) {
|
||||
#elif defined(ESP32)
|
||||
if(http.begin(clearBuffer)) {
|
||||
#endif
|
||||
int status = http.GET();
|
||||
|
||||
#if defined(ESP32)
|
||||
esp_task_wdt_reset();
|
||||
#elif defined(ESP8266)
|
||||
ESP.wdtFeed();
|
||||
#endif
|
||||
|
||||
if(status == HTTP_CODE_OK) {
|
||||
String pub = http.getString();
|
||||
http.end();
|
||||
|
||||
memset(clearBuffer, 0, CC_BUF_SIZE);
|
||||
snprintf(clearBuffer, CC_BUF_SIZE, pub.c_str());
|
||||
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Cloud public key:\n%s\n"), clearBuffer);
|
||||
|
||||
mbedtls_pk_context pk;
|
||||
mbedtls_pk_init(&pk);
|
||||
|
||||
int error_code = 0;
|
||||
if((error_code = mbedtls_pk_parse_public_key(&pk, (unsigned char*) clearBuffer, strlen((const char*) clearBuffer)+1)) == 0){
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("RSA public key OK\n"));
|
||||
rsa = mbedtls_pk_rsa(pk);
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
mbedtls_entropy_init(&entropy);
|
||||
|
||||
int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen(pers));
|
||||
if(ret != 0) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("mbedtls_ctr_drbg_seed return code: %d\n"), ret);
|
||||
}
|
||||
return ret == 0;
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("RSA public key read error: ");
|
||||
mbedtls_strerror(error_code, clearBuffer, CC_BUF_SIZE);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("%s\n", clearBuffer);
|
||||
}
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(CloudConnector) Communication error, returned status: %d\n"), status);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(http.errorToString(status).c_str());
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(http.getString().c_str());
|
||||
|
||||
http.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CloudConnector::update(AmsData& data, EnergyAccounting& ea) {
|
||||
if(!config.enabled) return;
|
||||
unsigned long now = millis();
|
||||
if(now-lastUpdate < config.interval*1000) return;
|
||||
if(!ESPRandom::isValidV4Uuid(config.clientId)) {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("(CloudConnector) Client ID is not valid\n"));
|
||||
return;
|
||||
}
|
||||
if(data.getListType() < 2) return;
|
||||
|
||||
if(!initialized && !init()) {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("Unable to initialize cloud connector\n"));
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
|
||||
memset(clearBuffer, 0, CC_BUF_SIZE);
|
||||
|
||||
int pos = 0;
|
||||
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR("{\"id\":\"%s\""), uuid.c_str());
|
||||
|
||||
if(lastUpdate == 0) {
|
||||
if(mainFuse > 0 && distributionSystem > 0) {
|
||||
int voltage = distributionSystem == 2 ? 400 : 230;
|
||||
if(data.isThreePhase()) {
|
||||
maxPwr = mainFuse * sqrt(3) * voltage;
|
||||
} else if(data.isTwoPhase()) {
|
||||
maxPwr = mainFuse * voltage;
|
||||
} else {
|
||||
maxPwr = mainFuse * 230;
|
||||
}
|
||||
}
|
||||
|
||||
IPAddress localIp;
|
||||
IPAddress subnet;
|
||||
IPAddress gateway;
|
||||
IPAddress dns1;
|
||||
IPAddress dns2;
|
||||
|
||||
if(ch == NULL) {
|
||||
localIp = WiFi.localIP();
|
||||
subnet = IPAddress(255,255,255,0);
|
||||
gateway = WiFi.subnetMask();
|
||||
dns1 = WiFi.dnsIP(0);
|
||||
dns2 = WiFi.dnsIP(1);
|
||||
} else {
|
||||
localIp = ch->getIP();
|
||||
subnet = ch->getSubnetMask();
|
||||
gateway = ch->getGateway();
|
||||
dns1 = ch->getDns(0);
|
||||
dns2 = ch->getDns(1);
|
||||
}
|
||||
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_INIT,
|
||||
mac,
|
||||
apmac,
|
||||
FirmwareVersion::VersionString,
|
||||
boardType,
|
||||
rtc_get_reset_reason(0),
|
||||
rdc == NULL ? 0 : rdc->last_cause,
|
||||
tz == NULL ? 0 : (tz->toLocal(now)-now)/3600,
|
||||
data.getMeterType(),
|
||||
meterManufacturer(data.getMeterType()).c_str(),
|
||||
data.getMeterModel().c_str(),
|
||||
data.getMeterId().c_str(),
|
||||
distributionSystemStr(distributionSystem).c_str(),
|
||||
mainFuse,
|
||||
maxPwr,
|
||||
productionCapacity,
|
||||
localIp.toString().c_str(),
|
||||
subnet.toString().c_str(),
|
||||
gateway.toString().c_str(),
|
||||
dns1.toString().c_str(),
|
||||
dns2.toString().c_str()
|
||||
);
|
||||
}
|
||||
|
||||
float vcc = 0.0;
|
||||
int rssi = 0;
|
||||
float temperature = -127;
|
||||
if(hw != NULL) {
|
||||
vcc = hw->getVcc();
|
||||
rssi = hw->getWifiRssi();
|
||||
temperature = hw->getTemperature();
|
||||
}
|
||||
|
||||
uint8_t espStatus;
|
||||
#if defined(ESP8266)
|
||||
if(vcc < 2.0) { // Voltage not correct, ESP would not run on this voltage
|
||||
espStatus = 1;
|
||||
} else if(vcc > 2.8 && vcc < 3.5) {
|
||||
espStatus = 1;
|
||||
} else if(vcc > 2.7 && vcc < 3.6) {
|
||||
espStatus = 2;
|
||||
} else {
|
||||
espStatus = 3;
|
||||
}
|
||||
#elif defined(ESP32)
|
||||
if(vcc < 2.0) { // Voltage not correct, ESP would not run on this voltage
|
||||
espStatus = 1;
|
||||
} else if(vcc > 3.1 && vcc < 3.5) {
|
||||
espStatus = 1;
|
||||
} else if(vcc > 3.0 && vcc < 3.6) {
|
||||
espStatus = 2;
|
||||
} else {
|
||||
espStatus = 3;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t hanStatus;
|
||||
if(data.getLastError() != 0) {
|
||||
hanStatus = 3;
|
||||
} else if(data.getLastUpdateMillis() == 0 && now < 30000) {
|
||||
hanStatus = 0;
|
||||
} else if(now - data.getLastUpdateMillis() < 15000) {
|
||||
hanStatus = 1;
|
||||
} else if(now - data.getLastUpdateMillis() < 30000) {
|
||||
hanStatus = 2;
|
||||
} else {
|
||||
hanStatus = 3;
|
||||
}
|
||||
|
||||
uint8_t wifiStatus;
|
||||
if(rssi > -75) {
|
||||
wifiStatus = 1;
|
||||
} else if(rssi > -95) {
|
||||
wifiStatus = 2;
|
||||
} else {
|
||||
wifiStatus = 3;
|
||||
}
|
||||
|
||||
uint8_t mqttStatus;
|
||||
if(mqttHandler == NULL) {
|
||||
mqttStatus = 0;
|
||||
} else if(mqttHandler->connected()) {
|
||||
mqttStatus = 1;
|
||||
} else if(mqttHandler->lastError() == 0) {
|
||||
mqttStatus = 2;
|
||||
} else {
|
||||
mqttStatus = 3;
|
||||
}
|
||||
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR(",\"data\":{\"clock\":%lu,\"up\":%lu,\"lastUpdate\":%lu,\"est\":%s"),
|
||||
(uint32_t) time(nullptr),
|
||||
(uint32_t) (millis64()/1000),
|
||||
(uint32_t) (data.getLastUpdateMillis()/1000),
|
||||
data.isCounterEstimated() ? "true" : "false"
|
||||
);
|
||||
if(data.getListType() > 2) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_POWER_LIST3, "import", data.getActiveImportPower(), data.getReactiveImportPower(), data.getActiveImportCounter(), data.getReactiveImportCounter());
|
||||
} else {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_POWER, "import", data.getActiveImportPower(), data.getReactiveImportPower());
|
||||
}
|
||||
if(data.getListType() > 2) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_POWER_LIST3, "export", data.getActiveExportPower(), data.getReactiveExportPower(), data.getActiveExportCounter(), data.getReactiveExportCounter());
|
||||
} else {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_POWER, "export", data.getActiveExportPower(), data.getReactiveExportPower());
|
||||
}
|
||||
|
||||
if(data.getListType() > 1) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR(",\"phases\":{"));
|
||||
bool first = true;
|
||||
if(data.getL1Voltage() > 0.0) {
|
||||
if(data.getListType() > 3) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_PHASE_LIST4, first ? "" : ",", 1, data.getL1Voltage(), String(data.getL1Current(), 2).c_str(), data.getL1ActiveImportPower(), data.getL1ActiveExportPower(), data.getL1PowerFactor());
|
||||
} else {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_PHASE, first ? "" : ",", 1, data.getL1Voltage(), String(data.getL1Current(), 2).c_str());
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if(data.getL2Voltage() > 0.0) {
|
||||
if(data.getListType() > 3) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_PHASE_LIST4, first ? "" : ",", 2, data.getL2Voltage(), String(data.getL2Current(), 2).c_str(), data.getL2ActiveImportPower(), data.getL2ActiveExportPower(), data.getL2PowerFactor());
|
||||
} else {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_PHASE, first ? "" : ",", 2, data.getL2Voltage(), data.isL2currentMissing() ? "null" : String(data.getL2Current(), 2).c_str());
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if(data.getL3Voltage() > 0.0) {
|
||||
if(data.getListType() > 3) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_PHASE_LIST4, first ? "" : ",", 3, data.getL3Voltage(), String(data.getL3Current(), 2).c_str(), data.getL3ActiveImportPower(), data.getL3ActiveExportPower(), data.getL3PowerFactor());
|
||||
} else {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_PHASE, first ? "" : ",", 3, data.getL3Voltage(), String(data.getL3Current(), 2).c_str());
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR("}"));
|
||||
}
|
||||
if(data.getListType() > 3) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR(",\"pf\":%.2f"), data.getPowerFactor());
|
||||
}
|
||||
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR(",\"realtime\":{\"import\":%.3f,\"export\":%.3f}"), ea.getUseThisHour(), ea.getProducedThisHour());
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR(",\"vcc\":%.2f,\"temp\":%.2f,\"rssi\":%d,\"free\":%d"), vcc, temperature, rssi, ESP.getFreeHeap());
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, CC_JSON_STATUS,
|
||||
espStatus, 0,
|
||||
hanStatus, data.getLastError(),
|
||||
wifiStatus, 0,
|
||||
mqttStatus, mqttHandler == NULL ? 0 : mqttHandler->lastError()
|
||||
);
|
||||
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR("}"));
|
||||
|
||||
uint16_t crc = crc16((uint8_t*) clearBuffer, pos);
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR(",\"crc\":\"%04X\"}"), crc);
|
||||
|
||||
if(rsa == nullptr) return;
|
||||
int ret = mbedtls_rsa_check_pubkey(rsa);
|
||||
if(ret != 0) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("mbedtls_rsa_pkcs1_encrypt return code: %d\n"), ret);
|
||||
mbedtls_strerror(ret, clearBuffer, CC_BUF_SIZE);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("%s\n"), clearBuffer);
|
||||
return;
|
||||
}
|
||||
memset(encryptedBuffer, 0, rsa->len);
|
||||
|
||||
int maxlen = 100 * (rsa->len/128);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(CloudConnector) Sending %d bytes and maxlen %d\n", pos, maxlen);
|
||||
udp.beginPacket(config.hostname,7443);
|
||||
for(int i = 0; i < pos; i += maxlen) {
|
||||
int size = min(maxlen, pos-i);
|
||||
int ret = mbedtls_rsa_pkcs1_encrypt(rsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, size, (unsigned char*) (clearBuffer+i), encryptedBuffer);
|
||||
if(ret == 0) {
|
||||
udp.write(encryptedBuffer, rsa->len);
|
||||
delay(1);
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("mbedtls_rsa_pkcs1_encrypt return code: %d\n"), ret);
|
||||
mbedtls_strerror(ret, clearBuffer, CC_BUF_SIZE);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("%s\n"), clearBuffer);
|
||||
}
|
||||
}
|
||||
udp.endPacket();
|
||||
|
||||
lastUpdate = now;
|
||||
}
|
||||
|
||||
void CloudConnector::forceUpdate() {
|
||||
lastUpdate = 0;
|
||||
}
|
||||
|
||||
void CloudConnector::setTimezone(Timezone* tz) {
|
||||
this->tz = tz;
|
||||
}
|
||||
|
||||
void CloudConnector::setConnectionHandler(ConnectionHandler* ch) {
|
||||
this->ch = ch;
|
||||
}
|
||||
|
||||
void CloudConnector::debugPrint(byte *buffer, int start, int length) {
|
||||
for (int i = start; i < start + length; i++) {
|
||||
if (buffer[i] < 0x10)
|
||||
debugger->print(F("0"));
|
||||
debugger->print(buffer[i], HEX);
|
||||
debugger->print(F(" "));
|
||||
if ((i - start + 1) % 16 == 0)
|
||||
debugger->println(F(""));
|
||||
else if ((i - start + 1) % 4 == 0)
|
||||
debugger->print(F(" "));
|
||||
|
||||
yield(); // Let other get some resources too
|
||||
}
|
||||
debugger->println(F(""));
|
||||
}
|
||||
48
lib/ConnectionHandler/include/ConnectionHandler.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @copyright Utilitech AS 2023
|
||||
* License: Fair Source
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CONNECTIONHANDLER_H
|
||||
#define _CONNECTIONHANDLER_H
|
||||
|
||||
#include "AmsConfiguration.h"
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
esp_netif_t* get_esp_interface_netif(esp_interface_t interface);
|
||||
#endif
|
||||
|
||||
#define NETWORK_MODE_WIFI_CLIENT 1
|
||||
#define NETWORK_MODE_WIFI_AP 2
|
||||
#define NETWORK_MODE_ETH_CLIENT 3
|
||||
|
||||
class ConnectionHandler {
|
||||
public:
|
||||
virtual ~ConnectionHandler() {};
|
||||
virtual bool connect(NetworkConfig config, SystemConfig sys);
|
||||
virtual void disconnect(unsigned long reconnectDelay);
|
||||
virtual bool isConnected();
|
||||
virtual bool isConfigChanged();
|
||||
virtual void getCurrentConfig(NetworkConfig& networkConfig);
|
||||
virtual IPAddress getIP();
|
||||
virtual IPAddress getSubnetMask();
|
||||
virtual IPAddress getGateway();
|
||||
virtual IPAddress getDns(uint8_t idx);
|
||||
#if defined(ESP32)
|
||||
virtual IPv6Address getIPv6();
|
||||
virtual IPv6Address getDNSv6(uint8_t idx);
|
||||
virtual void eventHandler(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
#endif
|
||||
|
||||
uint8_t getMode() {
|
||||
return this->mode;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
#endif
|
||||