{
// Calculate sensor requirements
const baseSensors = soilZones * sensorsPerZone;
const totalSensors = baseSensors + topoSensors;
const fieldM2 = fieldHectares * 10000;
const m2PerSensor = fieldM2 / totalSensors;
const avgSpacing = Math.sqrt(m2PerSensor);
const totalCost = totalSensors * sensorCost;
// Create visualization
const div = html`<div style="font-family: Arial, sans-serif; padding: 20px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #3498DB;">
<h3 style="color: #2C3E50; margin-top: 0;">Sensor Spacing Calculator</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; margin: 20px 0;">
<div style="background: white; padding: 15px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #7F8C8D; font-size: 14px; margin-bottom: 5px;">Base Sensors</div>
<div style="color: #2C3E50; font-size: 24px; font-weight: bold;">${baseSensors}</div>
<div style="color: #7F8C8D; font-size: 12px; margin-top: 5px;">${soilZones} zones × ${sensorsPerZone}</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #7F8C8D; font-size: 14px; margin-bottom: 5px;">Total Sensors</div>
<div style="color: #3498DB; font-size: 24px; font-weight: bold;">${totalSensors}</div>
<div style="color: #7F8C8D; font-size: 12px; margin-top: 5px;">+${topoSensors} topographic</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #7F8C8D; font-size: 14px; margin-bottom: 5px;">Average Spacing</div>
<div style="color: #16A085; font-size: 24px; font-weight: bold;">${avgSpacing.toFixed(0)}m</div>
<div style="color: #7F8C8D; font-size: 12px; margin-top: 5px;">${m2PerSensor.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")} m²/sensor</div>
</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 15px;">
<div style="color: #7F8C8D; font-size: 14px; margin-bottom: 5px;">Total System Cost</div>
<div style="color: #E67E22; font-size: 28px; font-weight: bold;">$${totalCost.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}</div>
<div style="color: #7F8C8D; font-size: 12px; margin-top: 5px;">
${totalSensors} sensors × $${sensorCost} = Cost per hectare: $${(totalCost/fieldHectares).toFixed(0)}
</div>
</div>
<div style="background: #EBF5FB; padding: 12px; border-radius: 6px; border-left: 3px solid #3498DB;">
<strong style="color: #2C3E50;">Deployment Plan:</strong>
<span style="color: #2C3E50;">Deploy ${totalSensors} sensors across ${fieldHectares} hectares (${soilZones} soil zones). Average spacing of ${avgSpacing.toFixed(0)}m provides ${(1000/(avgSpacing*avgSpacing)).toFixed(2)} sensors per 1000m². Total investment: $${totalCost.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}.</span>
</div>
</div>`;
return div;
}Sensor Spacing Calculator
Sensor Spacing Calculator
animation
agriculture
sensors
Try Change Distinct Soil Zones, then press Calculate spacing.
Observe After Calculate spacing, watch Total Sensors, Average Spacing and Total System Cost.
Explain Describe how Total Sensors changes Average Spacing after Calculate spacing.
Technical boundaries. Average Spacing uses the square root of field area divided by Total Sensors. Total System Cost includes sensors multiplied by sensor cost.