diff --git a/.github/docs-site.sh b/.github/docs-site.sh index 87a645e13..29007d6b5 100644 --- a/.github/docs-site.sh +++ b/.github/docs-site.sh @@ -33,12 +33,15 @@ rm -f "$stage/docs/docs.md" # how to build upstream's site, not for readers # README of the fork: "## O tomto forku" .. "## About this fork" = Czech, # from there to "## About MeshCore" = English. One heading level up, links -# into docs/ made site-relative, any other repo path absolute. +# into docs/ made site-relative, any other repo path absolute. The docs/ +# links are marked (@) before the absolute rewrite and unmarked after it, +# otherwise that rewrite caught them too (src/branch/main/power.md, a 404). readme_part() { sed -n "/^## $1/,/^## $2/p" README.md | sed '$d' | sed -E 's/^#(#+) /\1 /' | - sed -E 's#\]\((\./)?docs/([^)]+)\)#](\2)#g' | - sed -E "s#\\]\\((\\./)?([a-zA-Z][^):]*)\\)#](${src//#/\\#}/\\2)#g" + sed -E 's#\]\((\./)?docs/([^)]+)\)#](@\2)#g' | + sed -E "s#\\]\\((\\./)?([a-zA-Z][^):]*)\\)#](${src//#/\\#}/\\2)#g" | + sed -E 's#\]\(@#](#g' } readme_part 'About this fork' 'About MeshCore' >"$stage/docs/index.md" readme_part 'O tomto forku' 'About this fork' >"$stage/docs/cs.md" diff --git a/README.md b/README.md index e3e9e0b33..fabcc808e 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ Každá úspora proti upstreamu s naměřeným proudem a vlivem na příjem je v tabulce: [docs/power.md](docs/power.md#summary-every-option-against-stock-firmware). Změřeno proti upstreamu na stejné desce (XIAO, 3,3 V): náš repeater **6,87 mA**, upstream v1.19.0, jak ho dostanete, **10,13 mA** (−32 %; [protokol](docs/measurements/2026-12-04-stock-vs-tth/protocol.md)). +Kolik to dá pro váš uzel (deska, firmware, nastavení, provoz, baterie, panel): +[kalkulačka spotřeby](docs/power-calculator.md#cs). * GPS duty cycle (`gps duty`), i na T1000-E, kde nebyl: přijímač běží jen kolem synchronizace hodin (jednou denně, po neúspěšném okně znovu za 6 h). @@ -541,6 +543,8 @@ Every saving against upstream, with the measured current and its effect on reception, is in one table: [docs/power.md](docs/power.md#summary-every-option-against-stock-firmware). Measured against upstream on the same board (XIAO, 3.3 V): our repeater **6.87 mA**, upstream v1.19.0 as shipped **10.13 mA** (−32 %; [protocol](docs/measurements/2026-12-04-stock-vs-tth/protocol.md)). +What that means for your node (board, firmware, settings, traffic, battery, +panel): [power calculator](docs/power-calculator.md). * GPS duty cycle (`gps duty`), also on the T1000-E, which had none: the receiver runs only around a clock sync (once a day, after a window without diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js new file mode 100644 index 000000000..c58ceead3 --- /dev/null +++ b/docs/_js/power-calculator.js @@ -0,0 +1,691 @@ +/* Power calculator of the docs site (docs/power-calculator.md, issue #48). + Plain JS, no framework, no build step. Loaded on every page through + extra_javascript in mkdocs.tth.yml; does nothing unless the page has +
. Every number comes from docs/power-data.json, this file + holds only the method (baseline + deltas + LoRa airtime) and the UI text. + UI: a simple view (what an operator knows), one "Advanced" section for the + rest, the result on top (sticky right column on a wide screen). */ +(function () { + 'use strict'; + var script = document.currentScript; + + var T = { + en: { + node: 'Node', settings: 'Settings', traffic: 'Traffic', battery: 'Battery', + advanced: 'Advanced', breakdown: 'Breakdown', values: 'All values of the data file', + board: 'Board', firmware: 'Firmware', + powersaving: 'powersaving', rxps: 'radio.rxps', rxgain: 'radio.rxgain', ble: 'BLE', gps: 'GPS', + mah: 'Battery (mAh)', panel_w: 'Solar panel (W)', panel_hint: '0 = no panel', + rx_override: 'received packets / h', tx_override: 'transmitted packets / h', + override_hint: 'empty = the preset (quiet 30/10, normal 120/60, busy 600/300 RX/TX per hour)', + payload: 'packet length (bytes)', sf: 'SF', bw: 'BW (kHz)', cr: 'CR (4/x)', + preamble: 'preamble (symbols)', tx_dbm: 'TX power (dBm)', + tx_ma: 'TX current (mA), estimate', rx_extra: 'extra current while receiving (mA), estimate', + usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', + charge_eff_pct: 'charging efficiency (%), estimate', site_pct: 'real installation (% of the model)', month: 'Month', orient: 'Panel faces', + panel_w_each: 'W per panel', charger: 'charger', chem: 'battery chemistry', dark_days: 'days without sun', + dark_ok: '{d} days without sun: the battery carries them ({p} % left)', + dark_bad: '{d} days without sun: the battery lasts only {n}', + recover: 'refilled in {n} days of this month\'s balance', norecover: 'this month\'s balance does not refill it', + coldcap: 'capacity −{p} % in the cold ({t} °C)', + sensors: 'I2C sensors', sensors_hint: 'datasheet estimate for how this firmware reads them', + covers: 'panel covers it', emptyafter: 'battery empty after {n} days in {m} (starting full)', + night: 'the battery does not carry the {h} h night of {m}: it lasts {x} h', + nightshort: 'but not through the night', monthbal: 'balance per month (mAh/day)', bal_in: 'balance in', perdayu: 'mAh/day', + unavailable: 'not in this firmware', + avg: 'average current', autonomy: 'autonomy', days: 'days', perday: 'per day', + balance: 'daily balance', nosun: 'without sun', sensorline: 'I2C sensor', + measured: 'measured', estimate: 'estimate', + part_node: 'node', part_tx: 'TX', part_rx: 'RX', + base: 'whole node', borrowed: 'taken from', fwoffset: 'firmware difference measured on', + nofwoffset: 'this firmware is not measured on this board: another firmware\'s baseline is used as is', + txline: 'transmitting', rxline: 'receiving', solar: 'solar gain per day', + details: 'details', src: 'source', kind: 'kind', option: 'option', value: 'value', date: 'date', + foot: 'Airtime of one packet {a} ms. Currents of the measurement rig at {v} V; the node is assumed to draw the same from the cell.', + loadfail: 'Could not load power-data.json: ' + }, + cs: { + node: 'Uzel', settings: 'Nastavení', traffic: 'Provoz', battery: 'Baterie', + advanced: 'Pokročilé', breakdown: 'Rozpis', values: 'Všechny hodnoty datového souboru', + board: 'Deska', firmware: 'Firmware', + powersaving: 'powersaving', rxps: 'radio.rxps', rxgain: 'radio.rxgain', ble: 'BLE', gps: 'GPS', + mah: 'Baterie (mAh)', panel_w: 'Solární panel (W)', panel_hint: '0 = bez panelu', + rx_override: 'přijatých paketů / h', tx_override: 'odvysílaných paketů / h', + override_hint: 'prázdné = předvolba (klidný 30/10, běžný 120/60, rušný 600/300 RX/TX za hodinu)', + payload: 'délka paketu (bajty)', sf: 'SF', bw: 'BW (kHz)', cr: 'CR (4/x)', + preamble: 'preambule (symboly)', tx_dbm: 'vysílací výkon (dBm)', + tx_ma: 'proud při vysílání (mA), odhad', rx_extra: 'proud navíc při příjmu (mA), odhad', + usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', + charge_eff_pct: 'účinnost nabíjení (%), odhad', site_pct: 'reálná instalace (% modelu)', month: 'Měsíc', orient: 'Panel míří na', + panel_w_each: 'W na jeden panel', charger: 'nabíječ', chem: 'chemie článku', dark_days: 'dny bez slunce', + dark_ok: 'po {d} dnech bez slunce zbude v baterii {p} %', + dark_bad: 'bez slunce vydrží baterie jen {n} (zadáno {d})', + recover: 'dobije se za {n} dní bilance tohoto měsíce', norecover: 'bilance tohoto měsíce ji nedobije', + coldcap: 'kapacita −{p} % zimou ({t} °C)', + sensors: 'Čidla na I2C', sensors_hint: 'odhad z datasheetu podle toho, jak je tento firmware čte', + covers: 'panel stačí', emptyafter: 'baterie prázdná po {n} dnech, měsíc {m} (z plné)', + night: 'baterie neutáhne {h} h noci (měsíc {m}): vydrží {x} h', + nightshort: 'ale noc nevydrží', monthbal: 'bilance po měsících (mAh/den)', bal_in: 'bilance, měsíc', perdayu: 'mAh/den', + unavailable: 'tento firmware nemá', + avg: 'průměrný proud', autonomy: 'výdrž', days: 'dní', perday: 'za den', + balance: 'denní bilance', nosun: 'bez slunce', sensorline: 'čidlo na I2C', + measured: 'změřeno', estimate: 'odhad', + part_node: 'uzel', part_tx: 'TX', part_rx: 'RX', + base: 'celý uzel', borrowed: 'převzato z', fwoffset: 'rozdíl firmwarů změřený na', + nofwoffset: 'tento firmware na této desce změřený není: použit základ jiného firmwaru tak, jak je', + txline: 'vysílání', rxline: 'příjem', solar: 'zisk ze soláru za den', + details: 'podrobnosti', src: 'zdroj', kind: 'druh', option: 'volba', value: 'hodnota', date: 'datum', + foot: 'Vysílání jednoho paketu trvá {a} ms. Proudy měřicí sestavy při {v} V; předpokládá se, že uzel bere z článku stejný proud.', + loadfail: 'Nepodařilo se načíst power-data.json: ' + } + }; + + function el(tag, attrs, kids) { + var e = document.createElement(tag); + Object.keys(attrs || {}).forEach(function (k) { + if (k === 'text') e.textContent = attrs[k]; + else if (attrs[k] !== false && attrs[k] != null) e.setAttribute(k, attrs[k]); + }); + (kids || []).forEach(function (c) { + if (c != null) e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); + }); + return e; + } + + function start() { + var root = document.getElementById('pcalc'); + if (!root || !script) return; + var base = new URL('../', script.src); // the script lives in /_js/ + fetch(new URL('power-data.json', base)) + .then(function (r) { + if (!r.ok) throw new Error('HTTP ' + r.status); + return r.json(); + }) + .then(function (d) { new Calc(root, d, base); }) + .catch(function (e) { root.textContent = T.en.loadfail + e.message; }); + } + + function Calc(root, d, base) { + this.root = root; + this.d = d; + this.base = base; + this.open = {}; + var h = location.hash.replace('#', ''); + this.lang = h === 'cs' || h === 'en' ? h : + (navigator.language || '').slice(0, 2) === 'cs' ? 'cs' : 'en'; + var td = d.traffic.defaults, b = d.battery; + this.s = { + board: d.boards[0].id, firmware: d.firmwares[0].id, + preset: td.preset, rx_override: '', tx_override: '', payload: td.payload, + sf: td.sf, bw: td.bw, cr: td.cr, preamble: td.preamble, tx_dbm: td.tx_dbm, + rx_extra: d.traffic.rx_extra.value, + mah: b.mah, usable_pct: b.usable_pct, voltage: b.voltage, + panel_w: b.panel_w, charge_eff_pct: b.charge_eff_pct, site_pct: d.battery.site_pct, + month: d.solar.default_month, orient: d.solar.orientation[0].id, sensors: {}, + charger: d.solar.chargers[0].id, chem: d.solar.chemistries[0].id, dark_days: d.solar.dark_days + }; + this.s.tx_ma = this.txCurrent(this.s.tx_dbm); + this.applyDefaults(true); + this.build(); + } + + var P = Calc.prototype; + + P.t = function (k) { return T[this.lang][k] || k; }; + P.n = function (o) { return o[this.lang] || o.en; }; // localized name of a data object + P.fmt = function (x, dec) { + var s = x.toFixed(dec == null ? 2 : dec); + return this.lang === 'cs' ? s.replace('.', ',') : s; + }; + P.board = function () { var s = this.s; return this.d.boards.filter(function (b) { return b.id === s.board; })[0]; }; + P.fw = function () { var s = this.s; return this.d.firmwares.filter(function (f) { return f.id === s.firmware; })[0]; }; + P.fwById = function (id) { return this.d.firmwares.filter(function (f) { return f.id === id; })[0] || { en: id }; }; + P.boardById = function (id) { return this.d.boards.filter(function (f) { return f.id === id; })[0] || { en: id }; }; + P.available = function (opt) { + if (opt === 'gps' && !this.board().gps) return false; + return this.fw().options.indexOf(opt) >= 0; + }; + + // board defaults, then what the firmware ships with; options it lacks are pinned off + // boardChanged: also the battery and panel the board ships with + P.applyDefaults = function (boardChanged) { + var self = this, def = Object.assign({}, this.board().defaults, this.fw().defaults); + if (boardChanged) { + ['mah', 'panel_w'].forEach(function (k) { + self.s[k] = def[k] != null ? def[k] : self.d.battery[k]; + }); + if (def.charger) this.setCharger(def.charger); + if (def.chem) this.setChem(def.chem); + } + Object.keys(this.d.settings).forEach(function (k) { + var vals = self.d.settings[k]; + if (!self.available(k)) self.s[k] = vals.indexOf('off') >= 0 ? 'off' : vals[0]; + else if (def[k] != null) self.s[k] = def[k]; + else if (vals.indexOf(self.s[k]) < 0) self.s[k] = vals[0]; + }); + }; + + // radio current in TX, linear between the points of the data file + P.txCurrent = function (dbm) { + var pts = this.d.traffic.tx_current.points.slice().sort(function (a, b) { return a.dbm - b.dbm; }); + if (dbm <= pts[0].dbm) return pts[0].value; + for (var i = 1; i < pts.length; i++) { + if (dbm <= pts[i].dbm) { + var a = pts[i - 1], b = pts[i]; + return Math.round(a.value + (b.value - a.value) * (dbm - a.dbm) / (b.dbm - a.dbm)); + } + } + return pts[pts.length - 1].value; + }; + + // LoRa time on air, Semtech SX1262 datasheet / AN1200.13: explicit header, CRC on + P.airtime = function () { + var s = this.s, sf = +s.sf, bw = +s.bw * 1000, cr = +s.cr - 4; + var tsym = Math.pow(2, sf) / bw; + var de = tsym > 0.016 ? 1 : 0; + var num = 8 * s.payload - 4 * sf + 28 + 16; + var nPay = 8 + Math.max(Math.ceil(num / (4 * (sf - 2 * de))) * (cr + 4), 0); + return (+s.preamble + 4.25) * tsym + nPay * tsym; + }; + + // packets per hour: the explicit numbers of the advanced section, else the preset + P.traffic = function () { + var s = this.s, p = this.d.traffic.presets.filter(function (x) { return x.id === s.preset; })[0]; + return { + rx: s.rx_override === '' ? p.rx_per_h : +s.rx_override, + tx: s.tx_override === '' ? p.tx_per_h : +s.tx_override + }; + }; + + // a charger / chemistry preset sets the numbers it stands for (still overridable) + P.setCharger = function (id) { + var c = this.d.solar.chargers.filter(function (x) { return x.id === id; })[0]; + if (c) { this.s.charger = id; this.s.charge_eff_pct = c.eff_pct; } + }; + P.setChem = function (id) { + var c = this.d.solar.chemistries.filter(function (x) { return x.id === id; })[0]; + if (c) { this.s.chem = id; this.s.usable_pct = c.usable_pct; this.s.voltage = c.voltage; } + }; + // capacity lost to cold in month m, % (linear between the points of the data file) + P.coldLoss = function (m) { + var t = this.d.solar.temp_c[m - 1]; + var pts = this.d.solar.cold_derate.slice().sort(function (a, b) { return a.t - b.t; }); + if (t <= pts[0].t) return pts[0].loss_pct; + for (var i = 1; i < pts.length; i++) { + if (t <= pts[i].t) { + var a = pts[i - 1], b = pts[i]; + return a.loss_pct + (b.loss_pct - a.loss_pct) * (t - a.t) / (b.t - a.t); + } + } + return pts[pts.length - 1].loss_pct; + }; + P.usableAt = function (m) { + var s = this.s; + return s.mah * s.usable_pct / 100 * (1 - this.coldLoss(m) / 100); + }; + + P.orientRow = function () { + var s = this.s; + return this.d.solar.orientation.filter(function (x) { return x.id === s.orient; })[0]; + }; + + // solar gain in mAh per day in month m (1..12) + P.solarGain = function (m) { + var s = this.s, so = this.d.solar; + var o = so.orientation.filter(function (x) { return x.id === s.orient; })[0]; + var f = o.factor_month ? o.factor_month[m - 1] : o.factor; + return s.panel_w * so.sun_h[m - 1] * f * (s.charge_eff_pct / 100) * (s.site_pct / 100) / s.voltage * 1000; + }; + P.monthName = function (m) { + return new Date(2026, m - 1, 15).toLocaleString(this.lang === 'cs' ? 'cs-CZ' : 'en-GB', { month: 'long' }); + }; + + P.range = function (v) { return Array.isArray(v) ? [Math.min(v[0], v[1]), Math.max(v[0], v[1])] : [v, v]; }; + + P.pickBaseline = function () { + var s = this.s, keys = Object.keys(this.d.settings); + var bid = s.board, like = this.board().like; + var rows = this.d.values.filter(function (v) { return v.kind === 'baseline' && v.board === bid; }); + if (!rows.length && like) rows = this.d.values.filter(function (v) { return v.kind === 'baseline' && v.board === like; }); + var same = rows.filter(function (v) { return v.firmware === s.firmware; }); + var pool = same.length ? same : rows; + function diff(v) { return keys.filter(function (k) { return v.settings[k] !== s[k]; }).length; } + pool.sort(function (a, b) { + return diff(a) - diff(b) || (b.measured - a.measured) || (a.firmware === 'tth' ? -1 : 1); + }); + return { row: pool[0], borrowed: !same.length, boardBorrowed: pool[0].board !== bid }; + }; + + // delta rows of one option between two values, best match first: + // same board and firmware, same board, any board + P.findDelta = function (opt, from, to) { + var s = this.s, best = null; + this.d.values.forEach(function (v) { + if (v.kind !== 'delta' || v.option !== opt) return; + var sign = v.from === from && v.to === to ? 1 : v.from === to && v.to === from ? -1 : 0; + if (!sign) return; + var fwOk = v.firmware === '*' || v.firmware === s.firmware; + var rank = (v.board === s.board ? 0 : 2) + (fwOk ? 0 : 1); + if (!best || rank < best.rank) best = { row: v, sign: sign, rank: rank }; + }); + return best; + }; + + // (chosen firmware) - (baseline's firmware) with identical settings on another board + P.fwOffset = function (b) { + var s = this.s, vals = this.d.values, found = null; + vals.forEach(function (a) { + if (found || a.kind !== 'baseline' || a.firmware !== s.firmware || a.board === b.board) return; + vals.forEach(function (c) { + if (found || c.kind !== 'baseline' || c.board !== a.board || c.firmware !== b.firmware) return; + if (JSON.stringify(a.settings) === JSON.stringify(c.settings)) found = { board: a.board, value: a.value - c.value, row: a }; + }); + }); + return found; + }; + + P.cost = function (opt, to) { + return this.d.values.filter(function (v) { return v.kind === 'reception' && v.option === opt && v.to === to; })[0]; + }; + + P.settingsText = function (row) { + var self = this; + return Object.keys(row.settings).filter(function (k) { + return k !== 'gps' || self.board().gps; + }).map(function (k) { return k + ' ' + row.settings[k]; }).join(', '); + }; + + // lines of the breakdown; part = node | tx | rx (the bar), lo/hi in mA + P.compute = function () { + var self = this, s = this.s, d = this.d, lines = []; + var pb = this.pickBaseline(), b = pb.row; + var u = b.uncertainty || 0, bmeas = b.measured && !pb.borrowed && !pb.boardBorrowed; + var bnote = pb.boardBorrowed ? this.t('borrowed') + ' ' + this.n(this.boardById(b.board)) : + b.firmware !== s.firmware ? this.t('borrowed') + ' ' + this.n(this.fwById(b.firmware)) : null; + lines.push({ part: 'node', label: this.t('base') + ' (' + this.settingsText(b) + ')', lo: b.value - u, hi: b.value + u, + approx: b.approx, measured: bmeas, row: b, note: bnote || (b['note_' + this.lang] || b.note_en) }); + + if (pb.borrowed) { // offset between the two firmwares, measured on another board + var off = this.fwOffset(b); + if (off) lines.push({ part: 'node', label: this.t('fwoffset') + ' ' + this.n(this.boardById(off.board)), lo: off.value, hi: off.value, measured: false, row: off.row }); + else lines.push({ part: 'node', label: this.t('nofwoffset'), lo: 0, hi: 0, measured: false, row: null, nonum: true }); + } + + Object.keys(d.settings).forEach(function (k) { + var from = b.settings[k], to = s[k]; + if (from === to || from == null) return; + var path = [], dd = self.findDelta(k, from, to); + if (dd) path.push(dd); + else d.settings[k].some(function (mid) { // one step through an intermediate value + var a = self.findDelta(k, from, mid), c = a && self.findDelta(k, mid, to); + if (a && c) { path.push(a, c); return true; } + return false; + }); + if (!path.length) { + lines.push({ part: 'node', label: k + ': ' + from + ' → ' + to, nonum: true, measured: false, row: null, lo: 0, hi: 0, note: '?' }); + return; + } + path.forEach(function (p) { + var r = self.range(p.row.value).map(function (x) { return x * p.sign; }); + var meas = p.row.measured && p.rank === 0; + var note = p.rank ? self.t('borrowed') + ' ' + self.n(self.boardById(p.row.board)) + + (p.row.firmware !== '*' ? ' / ' + self.n(self.fwById(p.row.firmware)) : '') : null; + lines.push({ part: 'node', label: k + ': ' + (p.sign > 0 ? p.row.from + ' → ' + p.row.to : p.row.to + ' → ' + p.row.from), + lo: Math.min(r[0], r[1]), hi: Math.max(r[0], r[1]), approx: p.row.approx, measured: meas, row: p.row, + note: note || (p.row['note_' + self.lang] || p.row.note_en) }); + }); + }); + + d.sensors.list.forEach(function (x) { + if (!s.sensors[x.id]) return; + var v = x[s.firmware] != null ? x[s.firmware] : x['*']; + lines.push({ part: 'node', label: self.t('sensorline') + ': ' + x.name, lo: v, hi: v, measured: false, + row: { source: d.sensors.source }, note: x.how }); + }); + + var at = this.airtime(), tr = this.traffic(); + var tx = tr.tx * at / 3600 * s.tx_ma, rx = tr.rx * at / 3600 * s.rx_extra; + var ms = this.fmt(at * 1000, 0); + lines.push({ part: 'tx', label: this.t('txline') + ' (' + tr.tx + '/h × ' + ms + ' ms × ' + s.tx_ma + ' mA)', lo: tx, hi: tx, measured: false, row: null }); + lines.push({ part: 'rx', label: this.t('rxline') + ' (' + tr.rx + '/h × ' + ms + ' ms × ' + s.rx_extra + ' mA)', lo: rx, hi: rx, measured: false, row: null }); + + var r = { lines: lines, lo: 0, hi: 0, meas: 0, est: 0, parts: { node: 0, tx: 0, rx: 0 }, airtime: at, voltage: b.voltage }; + lines.forEach(function (l) { + var mid = (l.lo + l.hi) / 2; + r.lo += l.lo; r.hi += l.hi; r.parts[l.part] += mid; + if (l.measured) r.meas += mid; else r.est += mid; + }); + return r; + }; + + P.srcLink = function (key) { + var src = this.d.sources[key]; + if (!src) return document.createTextNode(key || ''); + if (!src.url) return document.createTextNode(this.n(src)); + var parts = src.url.split('#'), p = parts[0]; + // mkdocs directory URLs: power.md -> power/, a/index.md -> a/ + p = p.replace(/(^|\/)index\.md$/, '$1').replace(/\.md$/, '/'); + var href = new URL(p, this.base).href + (parts[1] ? '#' + parts[1] : ''); + return el('a', { href: href, text: this.n(src) }); + }; + + P.badge = function (m) { + return el('span', { 'class': m ? 'pc-m' : 'pc-e', text: m ? this.t('measured') : this.t('estimate') }); + }; + + // ---- UI ---- + + // segmented buttons; disabled = the option does not exist in this firmware + P.seg = function (key, opts, disabled) { + var s = this.s; + return el('div', { 'class': 'pc-seg', role: 'group', 'aria-label': this.t(key) }, opts.map(function (o) { + return el('button', { type: 'button', 'data-k': key, 'data-v': o.v, 'aria-pressed': String(s[key]) === String(o.v) ? 'true' : 'false', + disabled: disabled ? 'disabled' : false, text: o.t }); + })); + }; + + P.field = function (label, input, hint) { + return el('div', { 'class': 'pc-field' }, [el('label', { 'class': 'pc-label', text: label }), input, + hint ? el('div', { 'class': 'pc-hint' }, [hint]) : null]); + }; + + P.num = function (key, opts) { + opts = opts || {}; + return el('input', { type: 'number', name: key, value: this.s[key], step: opts.step || 'any', + min: opts.min != null ? opts.min : '0', placeholder: opts.ph || false, inputmode: 'decimal' }); + }; + + P.select = function (key, opts) { + var s = this.s, e = el('select', { name: key }); + opts.forEach(function (o) { + var op = el('option', { value: o.v, text: o.t }); + if (String(s[key]) === String(o.v)) op.selected = true; + e.appendChild(op); + }); + return e; + }; + + // reception cost of a setting, as one warning line with its source + P.warn = function (key, small) { + var c = this.cost(key, this.s[key]); + if (!c) return null; + var link = this.srcLink(c.source); + if (link.tagName === 'A') { link.textContent = this.t('details'); link.title = this.n(c); } + return el('div', { 'class': 'pc-hint', role: 'note' }, + [(c['short_' + this.lang] || this.n(c)) + ' · ', link]); + }; + + P.settingRow = function (k, small) { + var on = this.available(k); + var hint = on ? this.warn(k, small) : el('div', { 'class': 'pc-hint', text: this.t('unavailable') }); + return el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t(k) }), + this.seg(k, this.d.settings[k].map(function (v) { return { v: v, t: v }; }), !on), hint]); + }; + + P.build = function () { + var self = this, s = this.s, d = this.d; + var focus = document.activeElement && this.root.contains(document.activeElement) ? + document.activeElement.getAttribute('data-k') + '=' + document.activeElement.getAttribute('data-v') : null; + this.root.textContent = ''; + + var langSeg = el('div', { 'class': 'pc-seg pc-lang', role: 'group', 'aria-label': 'language' }, [['cs', 'CZ'], ['en', 'EN']].map(function (l) { + return el('button', { type: 'button', 'data-lang': l[0], 'aria-pressed': self.lang === l[0] ? 'true' : 'false', text: l[1] }); + })); + + // simple view + var form = el('form', { 'class': 'pc-form' }); + form.appendChild(el('div', { 'class': 'pc-two pc-sel' }, [ + this.field(this.t('board'), this.select('board', d.boards.map(function (b) { return { v: b.id, t: self.n(b) }; }))), + this.field(this.t('firmware'), this.select('firmware', d.firmwares.map(function (f) { return { v: f.id, t: self.n(f) }; }))) + ])); + var sets = el('div', { 'class': 'pc-sets' }); + ['powersaving', 'rxps', 'ble', 'gps'].forEach(function (k) { + if (k === 'gps' && !self.board().gps) return; + sets.appendChild(self.settingRow(k)); + }); + form.appendChild(sets); + var presetDis = s.rx_override !== '' && s.tx_override !== ''; + form.appendChild(el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('traffic') }), + this.seg('preset', d.traffic.presets.map(function (p) { return { v: p.id, t: self.n(p) }; }), presetDis)])); + form.appendChild(el('div', { 'class': 'pc-two' }, [ + this.field(this.t('mah'), this.num('mah', { step: 100 })), + this.field(this.t(this.orientRow().per_panel ? 'panel_w_each' : 'panel_w'), this.num('panel_w', { step: 0.5 }), this.t('panel_hint')) + ])); + var months = []; + for (var m = 1; m <= 12; m++) months.push({ v: m, t: this.monthName(m) }); + form.appendChild(el('div', { 'class': 'pc-two' }, [ + this.field(this.t('month'), this.select('month', months)), + this.field(this.t('dark_days'), this.num('dark_days', { step: 1 })) + ])); + // four orientations need the full width + form.appendChild(el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('orient') }), + this.seg('orient', d.solar.orientation.map(function (o) { return { v: o.id, t: self.n(o) }; }))])); + var chips = el('div', { 'class': 'pc-chips' }, d.sensors.list.map(function (x) { + var cb = el('input', { type: 'checkbox', 'data-sensor': x.id }); + cb.checked = !!s.sensors[x.id]; + return el('label', { 'class': 'pc-chip', title: x.how }, [cb, x.name]); + })); + // collapsed: a dozen chips would take half the page; the summary says how many are picked + var nSel = d.sensors.list.filter(function (x) { return s.sensors[x.id]; }).length; + var sens = el('details', { 'class': 'pc-adv pc-sens', 'data-open': 'sens' }); + if (this.open.sens) sens.open = true; + sens.appendChild(el('summary', { text: this.t('sensors') + (nSel ? ' (' + nSel + ')' : '') })); + sens.appendChild(chips); + sens.appendChild(el('div', { 'class': 'pc-hint' }, [this.t('sensors_hint') + ' ', this.badge(false)])); + form.appendChild(sens); + + // advanced + var adv = el('details', { 'class': 'pc-adv', 'data-open': 'adv' }); + if (this.open.adv) adv.open = true; + adv.appendChild(el('summary', { text: this.t('advanced') })); + adv.appendChild(this.settingRow('rxgain', true)); + var grid = el('div', { 'class': 'pc-grid3' }); + grid.appendChild(this.field(this.t('rx_override'), this.num('rx_override', { step: 1, ph: String(this.traffic().rx) }))); + grid.appendChild(this.field(this.t('tx_override'), this.num('tx_override', { step: 1, ph: String(this.traffic().tx) }))); + grid.appendChild(this.field(this.t('payload'), this.num('payload', { step: 1 }))); + grid.appendChild(this.field(this.t('sf'), this.select('sf', [7, 8, 9, 10, 11, 12].map(function (v) { return { v: v, t: v }; })))); + grid.appendChild(this.field(this.t('bw'), this.select('bw', [62.5, 125, 250].map(function (v) { return { v: v, t: v }; })))); + grid.appendChild(this.field(this.t('cr'), this.select('cr', [5, 6, 7, 8].map(function (v) { return { v: v, t: '4/' + v }; })))); + grid.appendChild(this.field(this.t('preamble'), this.num('preamble', { step: 1 }))); + grid.appendChild(this.field(this.t('tx_dbm'), this.num('tx_dbm', { step: 1, min: '-9' }))); + grid.appendChild(this.field(this.t('tx_ma'), this.num('tx_ma'))); + grid.appendChild(this.field(this.t('rx_extra'), this.num('rx_extra'))); + grid.appendChild(this.field(this.t('chem'), this.select('chem', d.solar.chemistries.map(function (c) { return { v: c.id, t: self.n(c) }; })))); + grid.appendChild(this.field(this.t('usable_pct'), this.num('usable_pct', { step: 5 }))); + grid.appendChild(this.field(this.t('voltage'), this.num('voltage', { step: 0.1 }))); + grid.appendChild(this.field(this.t('charger'), this.select('charger', d.solar.chargers.map(function (c) { return { v: c.id, t: self.n(c) + ' ' + c.eff_pct + ' %' }; })))); + grid.appendChild(this.field(this.t('charge_eff_pct'), this.num('charge_eff_pct', { step: 5 }))); + grid.appendChild(this.field(this.t('site_pct'), this.num('site_pct', { step: 5 }))); + adv.appendChild(grid); + adv.appendChild(el('p', { 'class': 'pc-hint', text: this.t('override_hint') })); + form.appendChild(adv); + + form.addEventListener('input', function (ev) { + var t = ev.target, k = t.name; + if (t.hasAttribute('data-sensor')) { s.sensors[t.getAttribute('data-sensor')] = t.checked; self.render(); return; } + if (!k) return; + if (t.tagName === 'SELECT') { + s[k] = isNaN(+t.value) ? t.value : +t.value; + if (k === 'board' || k === 'firmware') self.applyDefaults(k === 'board'); + if (k === 'charger') self.setCharger(t.value); + if (k === 'chem') self.setChem(t.value); + self.build(); + return; + } + if (t.value === '') { + if (k === 'rx_override' || k === 'tx_override') s[k] = ''; + else return; + } else s[k] = +t.value; + if (k === 'tx_dbm') { + s.tx_ma = self.txCurrent(s[k]); + self.root.querySelector('[name=tx_ma]').value = s.tx_ma; + } + self.render(); + }); + form.addEventListener('submit', function (ev) { ev.preventDefault(); }); + + this.out = el('div', { 'class': 'pc-result', 'aria-live': 'polite' }); + this.root.appendChild(el('div', { 'class': 'pc-card' }, [ + el('div', { 'class': 'pc-head' }, [el('strong', { text: this.lang === 'cs' ? 'Kalkulačka spotřeby' : 'Power calculator' }), langSeg]), + el('div', { 'class': 'pc-layout' }, [this.out, form]) + ])); + + var vals = el('details', { 'class': 'pc-values', 'data-open': 'values' }, [el('summary', { text: this.t('values') })]); + if (this.open.values) vals.open = true; + // at the end of the page when it has a place for it, else under the card + var vbox = document.getElementById('pcalc-values') || this.root; + if (vbox !== this.root) vbox.textContent = ''; + vbox.appendChild(vals); + this.renderValues(vals); + + this.root.addEventListener('click', this.onClick || (this.onClick = function (ev) { + var b = ev.target.closest('button'); + if (!b || !self.root.contains(b)) return; + if (b.hasAttribute('data-lang')) { self.lang = b.getAttribute('data-lang'); self.build(); return; } + var k = b.getAttribute('data-k'); + if (!k) return; + var v = b.getAttribute('data-v'); + s[k] = isNaN(+v) ? v : +v; + self.build(); + })); + this.onToggle = this.onToggle || function (ev) { + var k = ev.target.getAttribute && ev.target.getAttribute('data-open'); + if (k) self.open[k] = ev.target.open; + }; + this.root.addEventListener('toggle', this.onToggle, true); + vbox.addEventListener('toggle', this.onToggle, true); + + this.render(); + if (focus) { + var f = this.root.querySelector('[data-k="' + focus.split('=')[0] + '"][data-v="' + focus.split('=')[1] + '"]'); + if (f) f.focus(); + } + }; + + P.render = function () { + var self = this, s = this.s, r = this.compute(), out = this.out; + out.textContent = ''; + var mid = (r.lo + r.hi) / 2, perDay = mid * 24, usable = this.usableAt(s.month); + var so = this.d.solar, tmon = so.temp_c[s.month - 1], cold = this.coldLoss(s.month), notes = []; + if (cold > 0.5) notes.push(this.t('coldcap').replace('{p}', this.fmt(cold, 0)).replace('{t}', this.fmt(tmon, 1))); + + // the two big numbers + var rng = r.hi - r.lo > 0.005 ? this.fmt(r.lo) + ' … ' + this.fmt(r.hi) + ' mA' : ''; + var autoBig, autoSub, autoLabel = this.t('autonomy'), warnNight = null, strip = null, autoBad = false, darkLine = null; + if (s.panel_w > 0) { + var mn = this.monthName(s.month), bal = this.solarGain(s.month) - perDay; + autoLabel = this.t('bal_in') + ' ' + mn; + autoBig = (bal >= 0 ? '+' : '−') + this.fmt(Math.abs(bal), 0); + autoBad = bal < 0; + autoSub = this.t('perdayu') + ' · ' + (bal >= 0 ? this.t('covers') : + this.t('emptyafter').replace('{n}', this.fmt(usable / -bal, 1)).replace('{m}', mn)) + + ' · ' + this.t('nosun') + ' ' + this.fmt(usable / perDay, 1) + ' ' + this.t('days'); + strip = el('div', { 'class': 'pc-strip' }); + for (var m = 1; m <= 12; m++) { + var bm = this.solarGain(m) - perDay, ab = Math.abs(bm); + var txt = (bm >= 0 ? '+' : '−') + (ab >= 1000 ? this.fmt(ab / 1000, 1) + 'k' : this.fmt(ab, 0)); + strip.appendChild(el('span', { 'class': (bm < 0 ? 'pc-neg' : 'pc-pos') + (m === +s.month ? ' pc-cur' : ''), + title: this.monthName(m) + ': ' + txt + ' ' + this.t('perdayu') }, [ + el('b', { text: this.monthName(m).slice(0, 3) }), el('span', { text: txt })])); + } + // the cell must carry the night of that month (said only when it does not) + var nh = this.d.solar.night_h[s.month - 1], lasts = usable / mid; + if (lasts < nh) warnNight = this.t('night').replace('{h}', this.fmt(nh, 0)).replace('{m}', mn).replace('{x}', this.fmt(lasts, 1)); + if (warnNight) { autoBad = true; autoSub = autoSub.replace(this.t('covers'), '⚠ ' + this.t('nightshort')); } + // a dark streak from full, then how long this month's surplus takes to refill it + var dd = +s.dark_days || 0; + if (dd > 0) { + var need = dd * perDay; + if (need <= usable) { + var dl = this.t('dark_ok').replace('{d}', dd).replace('{p}', this.fmt((usable - need) / usable * 100, 0)); + dl += ' · ' + (bal > 0 ? this.t('recover').replace('{n}', this.fmt(need / bal, 1)) : this.t('norecover')); + darkLine = el('div', { 'class': 'pc-hint', text: dl }); + } else { + darkLine = el('div', { 'class': 'pc-warn', text: this.t('dark_bad').replace('{d}', dd) + .replace('{n}', this.fmt(usable / perDay, 1) + ' ' + this.t('days')) }); + } + } + } else { + autoBig = this.fmt(usable / perDay, 1); + autoSub = this.t('days') + ' · ' + this.fmt(perDay, 0) + ' mAh ' + this.t('perday'); + } + out.appendChild(el('div', { 'class': 'pc-big' }, [ + el('div', {}, [el('div', { 'class': 'pc-label', text: this.t('avg') }), + el('div', { 'class': 'pc-bignum' }, [this.fmt(mid, mid >= 10 ? 1 : 2), el('span', { 'class': 'pc-unit', text: ' mA' })]), + el('div', { 'class': 'pc-sub', text: rng || ' ' })]), + el('div', {}, [el('div', { 'class': 'pc-label', text: autoLabel }), + el('div', { 'class': 'pc-bignum' + (autoBad ? ' pc-bad' : ''), text: autoBig }), + el('div', { 'class': 'pc-sub', text: autoSub })]) + ])); + + if (strip) { + out.appendChild(el('div', { 'class': 'pc-label pc-strip-t', text: this.t('monthbal') })); + out.appendChild(strip); + } + if (darkLine) out.appendChild(darkLine); + if (warnNight) out.appendChild(el('div', { 'class': 'pc-warn', text: '⚠ ' + warnNight })); + if (tmon < 0) notes.push(so['cold_note_' + this.lang]); + notes.forEach(function (n) { out.appendChild(el('div', { 'class': 'pc-hint', text: n })); }); + + // split node / TX / RX + var tot = r.parts.node + r.parts.tx + r.parts.rx || 1, bar = el('div', { 'class': 'pc-bar', role: 'img', + 'aria-label': ['node', 'tx', 'rx'].map(function (p) { return self.t('part_' + p) + ' ' + self.fmt(r.parts[p]) + ' mA'; }).join(', ') }); + var legend = el('div', { 'class': 'pc-legend' }); + ['node', 'tx', 'rx'].forEach(function (p) { + var w = Math.max(0, r.parts[p]) / tot * 100; + bar.appendChild(el('span', { 'class': 'pc-b-' + p, style: 'width:' + w.toFixed(2) + '%' })); + legend.appendChild(el('span', {}, [el('i', { 'class': 'pc-b-' + p }), self.t('part_' + p) + ' ' + self.fmt(r.parts[p]) + ' mA'])); + }); + out.appendChild(bar); + out.appendChild(legend); + out.appendChild(el('div', { 'class': 'pc-me' }, [ + el('span', { 'class': 'pc-m-t', text: this.t('measured') + ': ' + this.fmt(r.meas) + ' mA' }), ' · ', + el('span', { 'class': 'pc-e-t', text: this.t('estimate') + ': ' + this.fmt(r.est) + ' mA' })])); + + // breakdown + var det = el('details', { 'class': 'pc-bd', 'data-open': 'bd' }, [el('summary', { text: this.t('breakdown') })]); + if (this.open.bd) det.open = true; + var tb = el('tbody'); + r.lines.forEach(function (l) { + var val = l.nonum ? '' : (l.approx ? '~' : '') + (l.lo === l.hi ? self.fmt(l.lo) : self.fmt(l.lo) + ' … ' + self.fmt(l.hi)) + ' mA'; + var info = [l.label, ' ', self.badge(l.measured)]; + var sub = []; + if (l.row && l.row.source) sub.push(self.srcLink(l.row.source)); + if (l.row && l.row.date) sub.push(' (' + l.row.date + ')'); + if (l.note) sub.push(' · ' + l.note); + if (sub.length) info.push(el('div', { 'class': 'pc-hint' }, sub)); + tb.appendChild(el('tr', {}, [el('td', {}, info), el('td', { 'class': 'pc-num', text: val })])); + }); + if (s.panel_w > 0) { + var g = this.solarGain(s.month); + tb.appendChild(el('tr', {}, [el('td', {}, [this.t('solar') + ' (' + this.monthName(s.month) + ') ', this.badge(false)]), el('td', { 'class': 'pc-num', text: this.fmt(g, 0) + ' mAh' })])); + } + det.appendChild(el('table', { 'class': 'pc-lines' }, [tb])); + det.appendChild(el('p', { 'class': 'pc-hint', text: this.t('foot').replace('{a}', this.fmt(r.airtime * 1000, 0)).replace('{v}', this.fmt(r.voltage, 2)) })); + out.appendChild(det); + }; + + P.renderValues = function (box) { + var self = this, d = this.d; + var head = el('tr', {}, ['kind', 'board', 'firmware', 'option', 'value', 'date', '', 'src'].map(function (k) { + return el('th', { text: k ? self.t(k) : '' }); + })); + var body = el('tbody'); + d.values.forEach(function (v) { + var what = v.kind === 'baseline' ? Object.keys(v.settings).map(function (k) { return k + ' ' + v.settings[k]; }).join(', ') : + v.option ? v.option + ': ' + (v.from ? v.from + ' → ' : '') + (v.to || '') : ''; + if (v.kind === 'reception' || v.kind === 'info') what += (what ? ' - ' : '') + self.n(v); + var val = v.value == null ? '' : (v.approx ? '~' : '') + (Array.isArray(v.value) ? self.fmt(v.value[0]) + ' … ' + self.fmt(v.value[1]) : self.fmt(v.value)) + + (v.uncertainty ? ' ± ' + self.fmt(v.uncertainty) : '') + ' ' + (v.unit || '') + (v.voltage ? ' @ ' + self.fmt(v.voltage, 2) + ' V' : ''); + body.appendChild(el('tr', {}, [ + el('td', { text: v.kind }), el('td', { text: v.board || '' }), el('td', { text: v.firmware || '' }), + el('td', { text: what }), el('td', { 'class': 'pc-num', text: val }), el('td', { text: v.date || '' }), + el('td', {}, [self.badge(v.measured)]), el('td', {}, [self.srcLink(v.source)]) + ])); + }); + box.appendChild(el('div', { 'class': 'pc-scroll' }, [el('table', {}, [el('thead', {}, [head]), body])])); + }; + + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); + else start(); +})(); diff --git a/docs/_stylesheets/tth.css b/docs/_stylesheets/tth.css index 0a049724e..11a3188d4 100644 --- a/docs/_stylesheets/tth.css +++ b/docs/_stylesheets/tth.css @@ -34,3 +34,99 @@ .admonition.important > .admonition-title { color: var(--primary-color); } + +/* power calculator (power-calculator.md, docs/_js/power-calculator.js): a + card of its own inside the theme, proportional labels, monospace numbers */ +.pc-card { + font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + border: 1px solid #333; border-radius: 10px; background: #0b0b0b; + padding: 1rem 1.25rem 1.25rem; margin: 1.5rem 0; line-height: 1.45; +} +.pc-card table, .pc-card td, .pc-card th { border: 0; } +.pc-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; + margin-bottom: 0.75rem; font-size: 1.05rem; } +.pc-layout { display: grid; grid-template-columns: 1fr; gap: 1.5rem; } +@media (min-width: 52em) { + .pc-layout { grid-template-columns: minmax(0, 1fr) minmax(19rem, 24rem); align-items: start; } + .pc-result { order: 2; position: sticky; top: 1rem; } +} +.pc-form { display: flex; flex-direction: column; gap: 1rem; } +.pc-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; } +.pc-sel { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); } +.pc-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; } +.pc-grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.75rem 1rem; margin-top: 0.75rem; } +.pc-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; } +.pc-label { font-size: 0.85rem; color: #b8bcc4; } +.pc-card input { font-family: ui-monospace, monospace; } +.pc-card select { font-family: inherit; } +.pc-card select, .pc-card input { + font-size: 0.95rem; width: 100%; box-sizing: border-box; + background: #151515; color: #e8e9ed; border: 1px solid #3a3a3a; border-radius: 6px; padding: 0.4rem 0.5rem; +} +.pc-card select:focus, .pc-card input:focus, .pc-seg button:focus-visible { + outline: 2px solid var(--primary-color); outline-offset: 1px; +} +.pc-seg { display: flex; flex-wrap: nowrap; max-width: 100%; border: 1px solid #3a3a3a; border-radius: 6px; overflow: hidden; width: fit-content; } +.pc-seg button { + font: inherit; font-size: 0.9rem; background: transparent; color: #e8e9ed; border: 0; + border-right: 1px solid #3a3a3a; padding: 0.35rem 0.8rem; cursor: pointer; margin: 0; border-radius: 0; + flex: 1 1 auto; white-space: nowrap; +} +@media (max-width: 30em) { .pc-seg button { font-size: 0.85rem; padding: 0.35rem 0.55rem; } .pc-card { padding: 0.8rem; } } +.pc-seg button:last-child { border-right: 0; } +.pc-seg button:hover:not(:disabled) { background: #1d2a22; } +.pc-seg button[aria-pressed="true"] { background: var(--primary-color); color: #000; font-weight: 600; } +.pc-seg button:disabled { color: #6b6f76; cursor: not-allowed; } +.pc-lang button { font-size: 0.8rem; padding: 0.15rem 0.55rem; } +.pc-warn { color: #f0b429; font-size: 0.85rem; } +.pc-warn.pc-small { font-size: 0.8rem; } +.pc-warn a, .pc-hint a { color: inherit; text-decoration: underline; } +.pc-hint { font-size: 0.8rem; color: #9da1a8; } +.pc-adv > summary, .pc-bd > summary, .pc-values > summary { cursor: pointer; color: #b8bcc4; } +.pc-adv { border-top: 1px solid #262626; padding-top: 0.75rem; } +.pc-adv[open] > .pc-field { margin-top: 0.75rem; } +.pc-result { background: #111; border: 1px solid #262626; border-radius: 8px; padding: 1rem; } +.pc-big { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; } +.pc-bignum { font-family: ui-monospace, monospace; font-size: 2.2rem; line-height: 1.1; font-weight: 700; + color: var(--primary-color); } +.pc-unit { font-size: 1rem; font-weight: 400; color: #b8bcc4; } +.pc-sub { font-size: 0.8rem; color: #9da1a8; min-height: 1.2em; } +.pc-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #222; margin: 1rem 0 0.4rem; } +.pc-bar span { display: block; height: 100%; } +.pc-b-node { background: #5fd38d; } +.pc-b-tx { background: #e5a50a; } +.pc-b-rx { background: #62a0ea; } +.pc-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.8rem; color: #b8bcc4; } +.pc-legend i { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 2px; margin-right: 0.35em; } +.pc-me { margin-top: 0.6rem; font-size: 0.85rem; } +.pc-m-t { color: #5fd38d; } +.pc-e-t { color: #f0b429; } +.pc-bd { margin-top: 0.8rem; font-size: 0.85rem; } +.pc-lines { width: 100%; margin-top: 0.5rem; } +.pc-lines td { padding: 0.25rem 0.3rem; vertical-align: top; } +.pc-num { text-align: right; white-space: nowrap; font-family: ui-monospace, monospace; } +.pc-m, .pc-e { font-size: 0.7rem; padding: 0 0.3em; border: 1px solid; border-radius: 3px; } +.pc-m { color: #5fd38d; } +.pc-e { color: #f0b429; } +.pc-values { margin: 1rem 0; } +.pc-scroll { overflow-x: auto; font-size: 0.85rem; } +.pc-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; } +.pc-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; padding: 0.15rem 0.5rem; + border: 1px solid #3a3a3a; border-radius: 999px; cursor: pointer; } +.pc-chip input { width: auto; margin: 0; accent-color: var(--primary-color); } +.pc-chip:has(input:checked) { border-color: var(--primary-color); color: var(--primary-color); } +.pc-strip-t { margin-top: 0.9rem; } +.pc-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; margin-top: 0.3rem; } +.pc-strip > span { display: flex; flex-direction: column; align-items: center; padding: 0.15rem 0; + border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.62rem; line-height: 1.25; } +.pc-strip b { font-family: system-ui, sans-serif; font-weight: 400; color: #b8bcc4; } +.pc-pos { background: #12301f; color: #8fe0b0; } +.pc-neg { background: #3a1414; color: #ff9b9b; } +.pc-cur { outline: 2px solid #e8e9ed; outline-offset: -1px; } +.pc-lines { table-layout: fixed; } +.pc-lines td:last-child { width: 6.5em; white-space: normal; } +.pc-bignum.pc-bad { color: #ff8a8a; } +.pc-layout > *, .pc-card { min-width: 0; } +.pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } +@media (max-width: 30em) { .pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } } +.pc-seg { flex-wrap: wrap; } diff --git a/docs/power-calculator.md b/docs/power-calculator.md new file mode 100644 index 000000000..8c8eb4ae2 --- /dev/null +++ b/docs/power-calculator.md @@ -0,0 +1,80 @@ +# Power calculator / Kalkulačka spotřeby + +Pick your board, firmware and settings; the calculator shows the expected +average current and how long a battery lasts. Česky: přepínač „CZ" v kartě. + +
+ +> [!NOTE] +> The page is interactive on the docs site, +> https://tth-pub.pages.rfa.cz/meshcore-tth/power-calculator/ (a repository +> browser shows only this text). + +## How it computes + +- **Node:** the measured whole-node current of the board and firmware closest + to your settings, plus the measured + [delta](power.md#summary-every-option-against-stock-firmware) of each setting + that differs. A number borrowed from another board or firmware counts as an + estimate; the result says how much of the total is measured. +- **Traffic:** packets × LoRa time on air (Semtech formula) × radio current. + The presets are 30/10, 120/60 and 600/300 received/transmitted packets per + hour; exact numbers, packet length, modulation and the (estimated) TX and RX + currents are under *Advanced*. +- **I2C sensors:** what the chip draws between reads (telemetry is read only + when asked), from its datasheet. This fork puts every sensor to sleep between + reads; upstream leaves the INA219/226/260/3221 converting (0.3-0.7 mA each) + and a BMP280 in normal mode. Estimates; only the idle bus itself was measured. +- **Battery:** usable mAh / (mA × 24 h). A board's choice fills in what it + ships with (SenseCAP Solar P1-Pro: 4× 18650, 13 400 mAh, 5 W panel). The + chemistry sets the usable share (Li-ion/NMC 80 %, LiFePO4 90 %), and the + month's mean temperature (Czech uplands) takes off what the cold costs + (~20 % at 0 °C, ~40 % at −20 °C after EastMesh; estimates). +- **Days without sun:** whether the battery, full at the start, carries that + many dark days (default 4; Voltaic recommends at least 4, EastMesh 3-5), and + how many days of the month's surplus it takes to refill it afterwards. +- **Solar:** W × equivalent full-sun hours of the chosen **month** × orientation + × charging efficiency / battery voltage. The efficiency comes from the + charger type (D-Central's presets: MPPT 70 %, PWM 55 %, linear 50 %; the + SenseCAP Solar and the XIAO charge linearly). Sun hours are PVGIS monthly means + for Prague at the optimal tilt (December 1.5 h, June 5.6 h a day); the + calculator opens on December, the worst month, and shows the balance of all + twelve. East/west is taken as 60 %, heavy shade 30 %, a flat panel that +snow covers 20-30 % in winter (estimates). A real installation delivers about + 45 % of that model (calibrated on two of our solar nodes, November 2026; + under *Advanced*). + +**rxps:** saves about 2 mA and hears fewer weak packets (13-28 % below 0 dB +SNR, [details](power.md#rx-duty-cycle-rxps)). With other repeaters around that +cover the same area it hardly matters; it does where the node is the only path. + +## Other calculators and guides / Jiné kalkulačky a návody + +- [D-Central Off-Grid Solar Node Planner](https://d-central.tech/solar-node-planner/) + -- interactive, Meshtastic/LoRa, sized for a Canadian winter. +- [Voltaic Systems off-grid sizing](https://voltaicsystems.com/sizing/) -- + interactive, generic IoT; aims at a power ratio of at least 1.5. +- [EastMesh wiki: Power & Solar](https://wiki.eastmesh.au/power/overview/) -- + a MeshCore community guide. +- [SDRstore: European winter battery and panel sizing](https://www.sdrstore.eu/solar-meshtastic-lilygo-european-winter-battery-panel-sizing/) + -- a worked example with a commissioning checklist. +- [Meshtastic: measure power consumption](https://meshtastic.org/docs/hardware/solar-powered/measure-power-consumption/) + -- how to measure your own node. +- [PVGIS (EU JRC)](https://re.jrc.ec.europa.eu/pvg_tools/en/) -- the sun + where your node actually stands. + +What this one adds: the per-option deltas measured on our bench, firmware +against firmware, and what an option costs in reception. +Co přidává tahle: rozdíly jednotlivých voleb změřené na naší lavici, srovnání +firmwarů a cenu voleb v příjmu. + +## Data + +All numbers live in one file, +[`power-data.json`](https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/docs/power-data.json), +each with board, date, source and whether it was measured; new measurements +are new rows there. + +
diff --git a/docs/power-data.json b/docs/power-data.json new file mode 100644 index 000000000..a66e1be46 --- /dev/null +++ b/docs/power-data.json @@ -0,0 +1,414 @@ +{ + "_comment": [ + "Data of the power calculator (docs/power-calculator.md). The ONE place for", + "its numbers: the page reads this file, the JS holds no value. Every row of", + "`values` carries board, value, unit, date, source and measured; a new", + "measurement is a new row (or an edited one), no code change.", + "kind baseline: whole-node current of a board + firmware with the given", + "settings, no traffic. kind delta: change of current when `option` goes", + "from `from` to `to` on that board/firmware ('*' = not tied to a firmware);", + "value is a number or [min, max]. kind reception: what an option costs in", + "reception, shown next to it (short_*: the one-line warning). kind info: shown in the table only.", + "Settings start at the board's defaults, then the firmware's (as shipped).", + "The calculator picks the baseline whose settings are closest to the chosen", + "ones and adds the deltas of the rest; a delta borrowed from another board", + "or firmware is shown as an estimate." + ], + "schema": 1, + "sources": { + "protocol-2026-12-04": { + "url": "measurements/2026-12-04-stock-vs-tth/protocol.md", + "en": "measurement protocol 4. 12. 2026 (stock vs this fork, k = 2)", + "cs": "protokol měření 4. 12. 2026 (upstream vs tento fork, k = 2)" + }, + "bench-2026-12-04-czech": { + "url": "measurements/2026-12-04-stock-vs-tth/protocol.md", + "en": "measurement protocol 4. 12. 2026, cells C and C2 (MeshCore Czech, k = 2)", + "cs": "protokol měření 4. 12. 2026, buňky C a C2 (MeshCore Czech, k = 2)" + }, + "power-summary": { + "url": "power.md#summary-every-option-against-stock-firmware", + "en": "docs/power.md, summary table", + "cs": "docs/power.md, souhrnná tabulka" + }, + "power-rxps": { + "url": "power.md#rx-duty-cycle-rxps", + "en": "docs/power.md, RX duty cycle (bench 4. 12. 2026, #46)", + "cs": "docs/power.md, RX duty cycle (lavice 4. 12. 2026, #46)" + }, + "power-gps": { + "url": "power.md#gps-is-the-whole-game", + "en": "docs/power.md, GPS", + "cs": "docs/power.md, GPS" + }, + "power-ble": { + "url": "power.md#ble-two-defaults-that-were-quietly-expensive", + "en": "docs/power.md, BLE", + "cs": "docs/power.md, BLE" + }, + "power-nrf52": { + "url": "power.md#nrf52-sleep-and-peripheral-fixes", + "en": "docs/power.md, nRF52 fixes", + "cs": "docs/power.md, opravy nRF52" + }, + "sx1262-datasheet": { + "url": "", + "en": "SX1262 datasheet (Semtech), not measured", + "cs": "datasheet SX1262 (Semtech), neměřeno" + }, + "seeed-table": { + "url": "https://files.seeedstudio.com/wiki/SenseCAP/Meshcore/SolarNode/mesh_repeater_power_table_en1.xlsx", + "en": "Seeed, Solar Node battery life calculation table (MeshCore): baseline 9.47 mA, GPS 40.2 mA, TX EU868 118.7 mA", + "cs": "Seeed, tabulka výdrže Solar Node (MeshCore): základ 9,47 mA, GPS 40,2 mA, TX EU868 118,7 mA" + }, + "seeed-wiki": { + "url": "https://wiki.seeedstudio.com/meshtastic_solar_node/", + "en": "Seeed wiki, SenseCAP Solar Node: 5 W panel, P1-Pro 4x 18650 NMC 3350 mAh, linear charger CN3165", + "cs": "Seeed wiki, SenseCAP Solar Node: panel 5 W, P1-Pro 4x 18650 NMC 3350 mAh, lineární nabíječ CN3165" + }, + "dcentral": { + "url": "https://d-central.tech/solar-node-planner/", + "en": "D-Central Off-Grid Solar Node Planner (presets), estimate", + "cs": "D-Central Off-Grid Solar Node Planner (předvolby), odhad" + }, + "eastmesh": { + "url": "https://wiki.eastmesh.au/power/overview/", + "en": "EastMesh wiki, Power & Solar, estimate", + "cs": "EastMesh wiki, Power & Solar, odhad" + }, + "voltaic": { + "url": "https://voltaicsystems.com/sizing/", + "en": "Voltaic Systems off-grid sizing", + "cs": "Voltaic Systems, dimenzování off-grid" + }, + "pvgis": { + "url": "https://re.jrc.ec.europa.eu/pvg_tools/en/", + "en": "PVGIS, Prague, optimal tilt, monthly mean - estimate", + "cs": "PVGIS, Praha, optimální sklon, měsíční průměr - odhad" + }, + "sensor-code": { + "url": "", + "en": "src/helpers/sensors/EnvironmentSensorManager.cpp + datasheet, not measured", + "cs": "src/helpers/sensors/EnvironmentSensorManager.cpp + datasheet, neměřeno" + }, + "estimate": { + "url": "", + "en": "rough estimate, not measured", + "cs": "hrubý odhad, neměřeno" + } + }, + "boards": [ + { + "id": "xiao", + "en": "XIAO nRF52840 + Wio-SX1262 (fed on 3V3)", + "cs": "XIAO nRF52840 + Wio-SX1262 (napájené na 3V3)", + "gps": false, + "defaults": { "ble": "off", "gps": "off", "mah": 3000, "panel_w": 0, "charger": "linear", "chem": "liion" }, + "_charger": "XIAO nRF52840 charges its cell with an on-board linear charger (BQ25101)" + }, + { + "id": "p1pro", + "en": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + L76K GPS)", + "cs": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + GPS L76K)", + "gps": true, + "defaults": { "ble": "on", "gps": "duty", "mah": 13400, "panel_w": 5, "charger": "linear", "chem": "liion" }, + "defaults_source": "seeed-wiki" + }, + { + "id": "p1", + "en": "SenseCAP Solar P1 (no GPS, own 4x 18650)", + "cs": "SenseCAP Solar P1 (bez GPS, vlastní 4x 18650)", + "gps": false, + "like": "p1pro", + "_comment": "not measured: the P1-Pro without its GPS receiver, every number borrowed from the P1-Pro (an estimate); ships without cells", + "defaults": { "ble": "on", "gps": "off", "mah": 13400, "panel_w": 5, "charger": "linear", "chem": "liion" }, + "defaults_source": "seeed-wiki" + } + ], + "firmwares": [ + { + "id": "tth", + "en": "this fork (meshcore-tth public release)", + "cs": "tento fork (veřejný release meshcore-tth)", + "options": ["powersaving", "rxps", "rxgain", "ble", "gps"], + "defaults": { "powersaving": "on", "rxps": "off", "rxgain": "on" } + }, + { + "id": "stock", + "en": "upstream MeshCore v1.19.0", + "cs": "upstream MeshCore v1.19.0", + "options": ["powersaving", "rxgain", "ble", "gps"], + "defaults": { "powersaving": "off", "rxps": "off", "rxgain": "on" } + }, + { + "id": "czech", + "en": "MeshCore Czech v1.19.0.01", + "cs": "MeshCore Czech v1.19.0.01", + "options": ["powersaving", "rxps", "rxgain", "ble", "gps"], + "defaults": { "powersaving": "on", "rxps": "balanced", "rxgain": "on" } + } + ], + "settings": { + "powersaving": ["on", "off"], + "rxps": ["off", "balanced", "max"], + "rxgain": ["on", "off"], + "ble": ["off", "on"], + "gps": ["off", "duty", "on"] + }, + "values": [ + { + "kind": "baseline", "board": "xiao", "firmware": "tth", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 6.87, "uncertainty": 0.08, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "stock", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 7.27, "uncertainty": 0.09, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "stock", + "settings": { "powersaving": "off", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 10.13, "uncertainty": 0.12, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "czech", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 7.35, "uncertainty": 0.09, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "czech", + "settings": { "powersaving": "on", "rxps": "balanced", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 5.45, "uncertainty": 0.17, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true + }, + { + "kind": "baseline", "board": "p1pro", "firmware": "stock", + "settings": { "powersaving": "off", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 9.47, "unit": "mA", + "note_en": "Seeed's measurement of a MeshCore repeater on the Solar Node (\"screen off\" baseline, GPS and TX apart); firmware, settings and the measuring point are not stated -- taken as stock defaults until our battery-side measurement", + "note_cs": "měření výrobce (Seeed), MeshCore repeater na Solar Node (základ „screen off“, GPS a vysílání zvlášť); firmware, nastavení ani místo měření neuvádí -- bráno jako výchozí stock, než změříme ze strany baterie", + "date": "2025", "source": "seeed-table", "measured": true + }, + { + "kind": "info", "board": "p1pro", "firmware": "tth", + "value": 24, "approx": true, "unit": "mA", "voltage": 5.0, + "note_en": "our August 2026 reading on the 5 V USB side (charger path included) -- not the battery-side draw, not used", + "note_cs": "naše čtení ze srpna 2026 na straně 5 V USB (včetně nabíjecí cesty) -- není to odběr z baterie, nepoužívá se", + "date": "2026-08", "source": "power-summary", "measured": true + }, + + { + "kind": "delta", "option": "powersaving", "from": "off", "to": "on", + "board": "xiao", "firmware": "stock", + "value": -2.86, "unit": "mA", "date": "2026-12-04", + "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "delta", "option": "powersaving", "from": "off", "to": "on", + "board": "xiao", "firmware": "tth", + "value": -2.7, "unit": "mA", "date": "2026-11", + "source": "power-summary", "measured": true + }, + { + "kind": "delta", "option": "rxps", "from": "off", "to": "balanced", + "board": "xiao", "firmware": "tth", + "value": [-2.0, -1.8], "unit": "mA", "date": "2026-11", + "source": "power-rxps", "measured": true + }, + { + "kind": "delta", "option": "rxps", "from": "off", "to": "max", + "board": "xiao", "firmware": "tth", + "value": [-2.5, -2.3], "unit": "mA", "date": "2026-11", + "source": "power-rxps", "measured": true + }, + { + "kind": "delta", "option": "rxgain", "from": "on", "to": "off", + "board": "xiao", "firmware": "tth", + "value": [-0.51, -0.45], "unit": "mA", "date": "2026-11", + "source": "power-nrf52", "measured": true + }, + { + "kind": "delta", "option": "ble", "from": "on", "to": "off", + "board": "p1pro", "firmware": "tth", + "value": -1, "approx": true, "unit": "mA", "date": "2026-08", + "source": "power-ble", "measured": true + }, + { + "kind": "delta", "option": "gps", "from": "duty", "to": "on", + "board": "p1pro", "firmware": "*", + "value": [42, 45], "unit": "mA", "date": "2026-08", + "note_en": "receiver 46 mA continuous; gps duty saves 42-45 mA of it", + "note_cs": "přijímač 46 mA trvale; gps duty z toho ušetří 42-45 mA", + "source": "power-gps", "measured": true + }, + { + "kind": "delta", "option": "gps", "from": "duty", "to": "off", + "board": "p1pro", "firmware": "*", + "value": [-0.6, -0.02], "unit": "mA", "date": "2026-12", + "note_en": "estimate for today's duty (one sync a day): ~40 mA for a ~38 s fix = 0.02 mA; without a fix 300 s every 6 h = 0.6 mA (Seeed's GPS figures, our duty timers)", + "note_cs": "odhad pro dnešní duty (sync jednou denně): ~40 mA na ~38 s fixu = 0,02 mA; bez fixu 300 s každých 6 h = 0,6 mA (čísla GPS od Seeedu, naše časovače duty)", + "source": "seeed-table", "measured": false + }, + + { + "kind": "reception", "option": "rxps", "to": "balanced", + "short_en": "hears fewer weak packets (13-28 % below 0 dB SNR); matters only where this node is the one path", + "short_cs": "slabé pakety zachytí hůř (13-28 % pod 0 dB SNR); vadí jen tam, kde je uzel jediná cesta", + "en": "loses 13-28 % of weak packets (SNR -2..-8) against 0 % without rxps; strong signal 0 lost. Not for a mast.", + "cs": "ztratí 13-28 % slabých paketů (SNR -2..-8) proti 0 % bez rxps; silný signál 0 ztrát. Ne na stožár.", + "date": "2026-12-04", "source": "power-rxps", "measured": true + }, + { + "kind": "reception", "option": "rxps", "to": "max", + "short_en": "hears fewer weak packets (13-28 % below 0 dB SNR, max a bit more); matters only where this node is the one path", + "short_cs": "slabé pakety zachytí hůř (13-28 % pod 0 dB SNR, max o něco víc); vadí jen tam, kde je uzel jediná cesta", + "en": "as balanced or worse: 13-28 % of weak packets lost; on a live mast -16 % received. Not for a mast.", + "cs": "jako balanced nebo hůř: ztráta 13-28 % slabých paketů; na ostrém stožáru -16 % přijatých. Ne na stožár.", + "date": "2026-12-04", "source": "power-rxps", "measured": true + }, + { + "kind": "reception", "option": "rxgain", "to": "off", + "short_en": "~1-3 dB less sensitive (datasheet, not measured)", + "short_cs": "citlivost o ~1-3 dB horší (datasheet, neměřeno)", + "en": "costs ~1-3 dB of sensitivity (datasheet, not measured).", + "cs": "stojí ~1-3 dB citlivosti (datasheet, neměřeno).", + "source": "sx1262-datasheet", "measured": false + }, + + { + "kind": "info", "option": "dcdc", "board": "xiao", "firmware": "tth", + "en": "DC/DC regulator off (all firmwares have it on)", + "cs": "DC/DC regulátor vypnutý (všechny firmwary ho mají zapnutý)", + "value": 0.6, "unit": "mA", "voltage": 3.3, "date": "2026-11", + "source": "power-nrf52", "measured": true + } + ], + "traffic": { + "_comment": "Defaults of the traffic inputs and the current the radio adds while it transmits/receives. All of it is an ESTIMATE the reader can overwrite on the page.", + "presets": [ + { "id": "quiet", "en": "quiet node", "cs": "klidný uzel", "rx_per_h": 30, "tx_per_h": 10 }, + { "id": "normal", "en": "normal node", "cs": "běžný uzel", "rx_per_h": 120, "tx_per_h": 60 }, + { "id": "busy", "en": "busy node", "cs": "rušný uzel", "rx_per_h": 600, "tx_per_h": 300 } + ], + "defaults": { + "preset": "normal", "payload": 60, + "sf": 7, "bw": 62.5, "cr": 5, "preamble": 16, "tx_dbm": 22 + }, + "rx_extra": { + "value": 3, "unit": "mA", "measured": false, "source": "estimate", + "en": "extra current while a packet is being received (radio held in RX, MCU awake)", + "cs": "proud navíc po dobu příjmu paketu (rádio drženo v RX, MCU vzhůru)" + }, + "tx_current": { + "_comment": "radio current in TX by output power; the page interpolates linearly in dBm. 14 and 22 dBm are datasheet figures, the rest a guess.", + "unit": "mA", "voltage": 3.3, + "points": [ + { "dbm": -9, "value": 15, "measured": false, "source": "estimate" }, + { "dbm": 0, "value": 20, "measured": false, "source": "estimate" }, + { "dbm": 14, "value": 45, "measured": false, "source": "sx1262-datasheet" }, + { "dbm": 22, "value": 118, "measured": false, "source": "sx1262-datasheet" } + ] + } + }, + "battery": { + "_comment": "defaults of the battery inputs (a board's defaults win); efficiency and voltage are assumptions", + "mah": 3000, "usable_pct": 80, "voltage": 3.7, + "panel_w": 0, "charge_eff_pct": 50, + "site_pct": 45, + "_site_pct": "share of the modelled panel yield a real installation delivers (dirt, horizon, panel temperature, fog/rime, full-cell cut-off): calibrated on two of our solar repeaters in November 2026 (south and east panel, frost days excluded), both about 0.45 of this model" + }, + "solar": { + "_comment": [ + "Equivalent full-sun hours per day (kWh/m2/day on the panel), by month, for a fixed", + "panel at the optimal tilt (38 deg, south) in Prague (50.08 N 14.42 E): PVGIS v5.2", + "MRcalc, H(i_opt)_m, mean of 2010-2020, divided by the days of the month (queried", + "4. 12. 2026). An ESTIMATE for a node: irradiation on the plane, before the losses", + "of the charger and cell (charge_eff_pct) and of a worse orientation (orientation).", + "night_h: hours without sun on the 15th of the month at 50 N (rounded), for the", + "check that the cell carries the night. default_month 12 = the worst month." + ], + "source": "pvgis", "measured": false, "default_month": 12, + "sun_h": [1.48, 2.57, 3.88, 5.13, 5.14, 5.57, 5.58, 5.29, 4.33, 2.88, 1.72, 1.47], + "night_h": [15.6, 14.2, 12.3, 10.4, 8.7, 7.8, 8.2, 9.7, 11.5, 13.4, 15.1, 16.1], + "orientation": [ + { "id": "south", "en": "south", "cs": "jih", "factor": 1.0 }, + { "id": "eastwest", "en": "east / west", "cs": "východ / západ", "factor": 0.6 }, + { "id": "shade", "en": "heavy shade", "cs": "silný stín", "factor": 0.3 }, + { "id": "flat", "en": "flat / snow-prone", "cs": "plochý / pod sněhem", + "factor_month": [0.2, 0.3, 0.7, 0.9, 0.95, 0.95, 0.95, 0.95, 0.85, 0.7, 0.4, 0.2], + "_comment": "a flat panel under snow makes nothing (D-Central); winter 0-40 % taken as 20-30 %, summer near the optimal tilt; estimate", + "source": "dcentral" }, + { "id": "triangle", "en": "triangle, 3 panels", "cs": "triangl, 3 panely", "per_panel": true, + "factor_month": [1.46, 1.47, 1.48, 1.45, 1.51, 1.51, 1.50, 1.47, 1.45, 1.45, 1.47, 1.46], + "factor_month_tilt60": [1.74, 1.82, 1.95, 2.06, 2.24, 2.29, 2.26, 2.13, 1.97, 1.84, 1.77, 1.68], + "_comment": [ + "Three panels around a mast, azimuths south and +-120 deg, vertical (90 deg, as usually built);", + "the panel input is then W PER PANEL. factor_month = (H(i)_m south + H(i)_m +120 + H(i)_m -120)", + "/ H(i)_m of one south panel at the optimal 38 deg, PVGIS v5.2 PVcalc (MRcalc ignores the", + "azimuth), Prague 50.08 N 14.42 E, SARAH2 2005-2020, DEM horizon, queried 4. 12. 2026.", + "factor_month_tilt60: the same at 60 deg, not used by the page. Estimate." + ], + "source": "pvgis" } + ], + "orientation_source": "estimate", + "chargers": [ + { "id": "mppt", "en": "MPPT", "cs": "MPPT", "eff_pct": 70 }, + { "id": "pwm", "en": "PWM", "cs": "PWM", "eff_pct": 55 }, + { "id": "linear", "en": "linear (CN3165, XIAO)", "cs": "lineární (CN3165, XIAO)", "eff_pct": 50 }, + { "id": "bench", "en": "optimistic / bench", "cs": "optimistický / lavice", "eff_pct": 80 } + ], + "chargers_source": "dcentral", + "chemistries": [ + { "id": "liion", "en": "Li-ion / NMC", "cs": "Li-ion / NMC", "usable_pct": 80, "voltage": 3.7 }, + { "id": "lifepo4", "en": "LiFePO4", "cs": "LiFePO4", "usable_pct": 90, "voltage": 3.2 } + ], + "_chemistries": "lead-acid left out: a 12 V battery needs a converter the node does not have", + "chemistries_source": "eastmesh", + "temp_c": [-3, -2, 1, 6, 11, 14, 16, 15.5, 11.5, 7, 2, -1.5], + "_temp_c": "monthly mean air temperature, Czech uplands ~600 m (rounded climate normals), estimate", + "cold_derate": [ { "t": 10, "loss_pct": 0 }, { "t": 0, "loss_pct": 20 }, { "t": -20, "loss_pct": 40 } ], + "_cold_derate": "capacity lost to cold, interpolated in temp_c (EastMesh: ~20 % at 0 C, ~40 % at -20 C), estimate", + "cold_source": "eastmesh", + "cold_note_en": "Li-ion must not be charged below 0 °C; the SenseCAP charger stops via an NTC (threshold about −10 °C, not verified)", + "cold_note_cs": "Li-ion se pod 0 °C nesmí nabíjet; SenseCAP to hlídá NTC na nabíječi (práh kolem −10 °C, neověřeno)", + "dark_days": 4, + "_dark_days": "days without sun the battery should carry: Voltaic recommends >= 4, EastMesh 3-5", + "dark_days_source": "voltaic" + }, + "sensors": { + "_comment": [ + "I2C sensors this firmware probes (src/helpers/sensors/EnvironmentSensorManager.cpp,", + "only builds with ENV_INCLUDE_*). Telemetry is read only when someone asks, so the", + "average is the chip's current between reads; a read itself (a few ms, rarely) is", + "left out. This fork puts every chip to sleep after init and triggers one", + "conversion per read; upstream (v1.19.0) leaves INA219/INA226/INA260/INA3221", + "converting continuously, BMP280 in normal mode and SHTC3 idle. A row with", + "firmware 'tth' is this fork, '*' every other firmware (MeshCore Czech assumed", + "to be upstream here). All values are datasheet ESTIMATES, nothing measured; the", + "bench measured only an idle I2C bus (TWIM, Wire.end()): +-0.00 mA, 3. 12. 2026.", + "Not listed: VL53L0X, BMP085, RAK12035 (not looked at)." + ], + "unit": "mA", "source": "sensor-code", "measured": false, + "list": [ + { "id": "aht20", "name": "AHT10/AHT20", "tth": 0.00025, "*": 0.00025, "how": "sleep 0.25 uA between reads" }, + { "id": "bme280", "name": "BME280", "tth": 0.0001, "*": 0.0001, "how": "forced mode, sleep 0.1 uA" }, + { "id": "bmp280", "name": "BMP280", "tth": 0.0001, "*": 0.65, "how": "here forced (sleep 0.1 uA); upstream normal mode, 1 ms standby: converting almost all the time" }, + { "id": "bmp3xx", "name": "BMP388/390", "tth": 0.002, "*": 0.002, "how": "forced reads, sleep ~2 uA" }, + { "id": "bme680", "name": "BME680", "tth": 0.00015, "*": 0.00015, "how": "performReading per query, sleep 0.15 uA (heater only during a read)" }, + { "id": "bme680bsec", "name": "BME680 + BSEC", "tth": 0.9, "*": 0.9, "how": "BSEC low-power mode: gas heater every 3 s, all the time" }, + { "id": "shtc3", "name": "SHTC3", "tth": 0.0003, "*": 0.045, "how": "here asleep after init (0.3 uA); upstream idle until the first read (45 uA)" }, + { "id": "sht4x", "name": "SHT4x", "tth": 0.0004, "*": 0.0004, "how": "idle 0.4 uA between single-shot reads" }, + { "id": "lps22hb", "name": "LPS22HB", "tth": 0.001, "*": 0.001, "how": "one-shot, power-down 1 uA" }, + { "id": "ina219", "name": "INA219", "tth": 0.006, "*": 0.7, "how": "here power-down 6 uA; upstream continuous ~0.7 mA" }, + { "id": "ina226", "name": "INA226", "tth": 0.002, "*": 0.33, "how": "here shutdown <=2 uA; upstream continuous ~0.33 mA" }, + { "id": "ina260", "name": "INA260", "tth": 0.002, "*": 0.31, "how": "here shutdown <=2 uA; upstream continuous ~0.31 mA" }, + { "id": "ina3221", "name": "INA3221", "tth": 0.002, "*": 0.35, "how": "here power-down ~2 uA; upstream continuous ~0.35 mA" }, + { "id": "mlx90614", "name": "MLX90614", "tth": 1.3, "*": 1.3, "how": "no sleep in the driver, ~1.3 mA" } + ] + } +} diff --git a/docs/power.md b/docs/power.md index 1a5383957..089426225 100644 --- a/docs/power.md +++ b/docs/power.md @@ -15,6 +15,11 @@ release. Current is the paired delta of switching the option on (negative = saves). Reception is what another board counted on the bench, or the live mesh where it says so. +What it adds up to for your node (board, firmware, settings, traffic, battery, +panel): the [power calculator](power-calculator.md), which reads its numbers +from [`power-data.json`](power-data.json) -- update that file together with +this table. + | option | stock | here | current | reception / transmission | details | |---|---|---|---|---|---| | GPS `gps duty` (receiver powered only around a daily clock sync) | continuous (`gps on`) or `gps period` | `gps duty` on mast builds | **−42 to −45 mA** of 46 (P1-Pro) | no effect on the radio | [GPS](#gps-is-the-whole-game) | diff --git a/mkdocs.tth.yml b/mkdocs.tth.yml index 4c85e5cc6..304f471be 100644 --- a/mkdocs.tth.yml +++ b/mkdocs.tth.yml @@ -23,6 +23,11 @@ theme: extra_css: - _stylesheets/tth.css +# the power calculator (power-calculator.md, data power-data.json); the +# script does nothing on a page without
+extra_javascript: + - _js/power-calculator.js + plugins: - search @@ -46,6 +51,7 @@ nav: - Console commands: tth-commands.md - Firmware update by the admin (OTA): ota.md - Power saving: power.md + - Power calculator: power-calculator.md - Budka as a sensor: budka-sensor.md - BLE/LoRa coexistence: ble-lora-coexistence.md - MeshCore (upstream):