Show code
viewof distance_m = Inputs.range([1, 20000], {
value: 1000,
step: 100,
label: "Distance (m)"
})
viewof frequency_mhz = Inputs.select([433, 868, 915, 2400, 5800], {
value: 868,
label: "Frequency (MHz)"
})
fspl_db = 20 * Math.log10(distance_m) + 20 * Math.log10(frequency_mhz * 1e6) - 147.55
html`
<div class="quick-ref-card" style="background: linear-gradient(135deg, #16A085 0%, #1ABC9C 100%); color: white; padding: 20px; border-radius: 12px; margin: 15px 0;">
<h4 class="depth-l1" style="margin: 0 0 15px 0; border-bottom: 2px solid rgba(255,255,255,0.3); padding-bottom: 10px;">Free Space Path Loss Calculator</h4>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px; font-family: monospace; font-size: 16px; margin-bottom: 15px;">
<div style="text-align: center;">
<div style="font-size: 36px; font-weight: bold; margin: 10px 0;">${fspl_db.toFixed(1)} dB</div>
<div style="font-size: 14px; opacity: 0.9;">Path loss at ${distance_m.toLocaleString()}m @ ${frequency_mhz} MHz</div>
</div>
</div>
<div style="font-size: 12px; opacity: 0.85;">
Formula: FSPL(dB) = 20log₁₀(d) + 20log₁₀(f) - 147.55
</div>
</div>
`Show code
viewof tx_power = Inputs.range([-10, 30], {
value: 14,
step: 1,
label: "TX Power (dBm)"
})
viewof tx_gain = Inputs.range([0, 10], {
value: 2,
step: 0.5,
label: "TX Antenna Gain (dBi)"
})
viewof rx_gain = Inputs.range([0, 10], {
value: 2,
step: 0.5,
label: "RX Antenna Gain (dBi)"
})
viewof path_loss = Inputs.range([60, 150], {
value: 91,
step: 1,
label: "Path Loss (dB)"
})
viewof fade_margin = Inputs.range([0, 30], {
value: 10,
step: 1,
label: "Fade Margin (dB)"
})
rx_power = tx_power + tx_gain + rx_gain - path_loss - fade_margin
html`
<div class="quick-ref-card" style="background: linear-gradient(135deg, #3498DB 0%, #2980B9 100%); color: white; padding: 20px; border-radius: 12px; margin: 15px 0;">
<h4 class="depth-l1" style="margin: 0 0 15px 0; border-bottom: 2px solid rgba(255,255,255,0.3); padding-bottom: 10px;">Link Budget Calculator</h4>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px; margin-bottom: 15px;">
<div style="text-align: center;">
<div style="font-size: 36px; font-weight: bold; font-family: monospace; margin: 10px 0;">${rx_power.toFixed(1)} dBm</div>
<div style="font-size: 14px; opacity: 0.9;">Received Power</div>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; font-size: 13px; font-family: monospace;">
<div>TX Power: ${tx_power} dBm</div>
<div>+</div>
<div>TX Gain: ${tx_gain} dBi</div>
<div>RX Gain: ${rx_gain} dBi</div>
<div>-</div>
<div>Path Loss: ${path_loss} dB</div>
<div>Fade Margin: ${fade_margin} dB</div>
<div>-</div>
<div></div>
</div>
</div>
`Show code
viewof battery_capacity = Inputs.range([100, 5000], {
value: 2400,
step: 100,
label: "Battery Capacity (mAh)"
})
viewof active_current = Inputs.range([1, 100], {
value: 30,
step: 1,
label: "Active Current (mA)"
})
viewof sleep_current = Inputs.range([0.001, 10], {
value: 0.001,
step: 0.001,
label: "Sleep Current (mA)"
})
viewof active_time = Inputs.range([1, 1000], {
value: 40,
step: 10,
label: "Active Time per Event (ms)"
})
viewof events_per_hour = Inputs.range([1, 100], {
value: 6,
step: 1,
label: "Events per Hour"
})
avg_current = ((sleep_current * (3600 - events_per_hour * active_time / 1000)) +
(active_current * events_per_hour * active_time / 1000)) / 3600
battery_hours = (battery_capacity * 0.8) / avg_current
battery_days = battery_hours / 24
battery_years = battery_days / 365
html`
<div class="quick-ref-card" style="background: linear-gradient(135deg, #9B59B6 0%, #8E44AD 100%); color: white; padding: 20px; border-radius: 12px; margin: 15px 0;">
<h4 class="depth-l1" style="margin: 0 0 15px 0; border-bottom: 2px solid rgba(255,255,255,0.3); padding-bottom: 10px;">Battery Life Calculator</h4>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px; margin-bottom: 15px;">
<div style="text-align: center;">
<div style="font-size: 36px; font-weight: bold; font-family: monospace; margin: 10px 0;">${battery_years.toFixed(1)} years</div>
<div style="font-size: 14px; opacity: 0.9;">${battery_days.toFixed(0)} days | ${battery_hours.toFixed(0)} hours</div>
<div style="font-size: 13px; opacity: 0.8; margin-top: 5px;">Average current: ${avg_current.toFixed(4)} mA</div>
</div>
</div>
<div style="font-size: 12px; opacity: 0.85;">
Using 80% of rated capacity. Active ${(events_per_hour * active_time / 1000).toFixed(1)}s/hour, Sleep ${(3600 - events_per_hour * active_time / 1000).toFixed(1)}s/hour.
</div>
</div>
`Show code
viewof vref = Inputs.range([1.0, 5.0], {
value: 3.3,
step: 0.1,
label: "Reference Voltage (V)"
})
viewof adc_bits = Inputs.select([8, 10, 12, 16, 24], {
value: 12,
label: "ADC Bits"
})
adc_steps = Math.pow(2, adc_bits)
adc_resolution = (vref / adc_steps) * 1000 // in mV
html`
<div class="quick-ref-card" style="background: linear-gradient(135deg, #E67E22 0%, #F39C12 100%); color: white; padding: 20px; border-radius: 12px; margin: 15px 0;">
<h4 class="depth-l1" style="margin: 0 0 15px 0; border-bottom: 2px solid rgba(255,255,255,0.3); padding-bottom: 10px;">ADC Resolution Calculator</h4>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px; margin-bottom: 15px;">
<div style="text-align: center;">
<div style="font-size: 36px; font-weight: bold; font-family: monospace; margin: 10px 0;">${adc_resolution.toFixed(2)} mV</div>
<div style="font-size: 14px; opacity: 0.9;">Per step (${adc_steps.toLocaleString()} steps total)</div>
</div>
</div>
<div style="font-size: 12px; opacity: 0.85;">
Formula: Step = V<sub>ref</sub> / 2<sup>bits</sup> = ${vref}V / ${adc_steps.toLocaleString()} = ${adc_resolution.toFixed(2)} mV
</div>
</div>
`