Interactive Weight Explorer
Try Keep Accuracy weight at 9, then lower Waterproof weight from 10 and watch the sensor scores.
Observe The opening scores round to 65% for DS18B20, 24% for DHT22 and 44% for BME280. DS18B20 has the highest score under these weights.
Explain Waterproof weight contributes only to DS18B20, while Accuracy weight enters every score’s denominator without adding to any sensor’s numerator.
Calculate in panel
Reset
Technical boundaries. Scoring assumes fixed pass lists for the three sensors, with weights from 0 to 10. The highest score is not a qualification check; all-zero weights return zero scores and N/A.
Interactive Weight Explorer.
Adjust the requirement weights below to see how they change the sensor ranking. This demonstrates how your priorities directly determine the “best” sensor – there is no objectively best sensor, only the best sensor for your requirements.
viewof wAccuracy = Inputs. range ([0 , 10 ], {value : 9 , step : 1 , label : "Accuracy weight" })
viewof wWaterproof = Inputs. range ([0 , 10 ], {value : 10 , step : 1 , label : "Waterproof weight" })
viewof wSleepCur = Inputs. range ([0 , 10 ], {value : 7 , step : 1 , label : "Sleep current weight" })
viewof wCost = Inputs. range ([0 , 10 ], {value : 5 , step : 1 , label : "Cost weight" })
viewof wHumidity = Inputs. range ([0 , 10 ], {value : 3 , step : 1 , label : "Humidity weight" })
sensorScores = {
const totalWeight = wAccuracy + wWaterproof + wSleepCur + wCost + wHumidity;
if (totalWeight === 0 ) return {ds18b20 : 0 , dht22 : 0 , bme280 : 0 , winner : "N/A" };
const ds18b20 = (wWaterproof + wSleepCur + wCost) / totalWeight * 100 ;
const dht22 = (wCost + wHumidity) / totalWeight * 100 ;
const bme280 = (wSleepCur + wCost + wHumidity) / totalWeight * 100 ;
const scores = [{name : "DS18B20" , score : ds18b20}, {name : "DHT22" , score : dht22}, {name : "BME280" , score : bme280}];
scores. sort ((a, b) => b. score - a. score );
return {ds18b20, dht22, bme280, winner : scores[0 ]. name , ranking : scores};
}
html `<div style="background: var(--bs-light, #f8f9fa); padding: 1rem; border-radius: 8px; border-left: 4px solid #16A085; margin-top: 0.5rem;">
<p><strong>Weighted Scores:</strong></p>
<table style="width: 100%; border-collapse: collapse; margin: 0.5rem 0;">
<tr style="border-bottom: 2px solid #ccc;">
<th style="text-align: left; padding: 4px;">Sensor</th>
<th style="text-align: left; padding: 4px;">Passes</th>
<th style="text-align: right; padding: 4px;">Score</th>
</tr>
<tr style="border-bottom: 1px solid #eee; ${ sensorScores. winner === 'DS18B20' ? 'font-weight: bold; color: #16A085;' : '' } ">
<td style="padding: 4px;">DS18B20</td>
<td style="padding: 4px;">waterproof, sleep, cost</td>
<td style="text-align: right; padding: 4px;"> ${ sensorScores. ds18b20 . toFixed (0 )} %</td>
</tr>
<tr style="border-bottom: 1px solid #eee; ${ sensorScores. winner === 'DHT22' ? 'font-weight: bold; color: #16A085;' : '' } ">
<td style="padding: 4px;">DHT22</td>
<td style="padding: 4px;">cost, humidity</td>
<td style="text-align: right; padding: 4px;"> ${ sensorScores. dht22 . toFixed (0 )} %</td>
</tr>
<tr style=" ${ sensorScores. winner === 'BME280' ? 'font-weight: bold; color: #16A085;' : '' } ">
<td style="padding: 4px;">BME280</td>
<td style="padding: 4px;">sleep, cost, humidity</td>
<td style="text-align: right; padding: 4px;"> ${ sensorScores. bme280 . toFixed (0 )} %</td>
</tr>
</table>
<p><strong>Highest score (no qualified winner):</strong> ${ sensorScores. winner } at ${ Math . max (sensorScores. ds18b20 , sensorScores. dht22 , sensorScores. bme280 ). toFixed (0 )} %</p>
<p style="font-size: 0.85em; color: #7F8C8D;"><em>Note: "Passes" reflects inherent sensor capability regardless of weight setting. Setting a weight to 0 makes the requirement irrelevant to scoring, but does not change whether the sensor physically meets it.</em></p>
</div>`
Back to the chapter