The sensor suite implemented in AR2 provides a range of environmental monitoring, with each sensor chosen for specific aspects of fire defence decision-making.

Three DS18B20 digital temperature sensors connect to a common 1-Wire bus on pin D6, providing external ambient temperature (EXT_TEMP, labeled T1), internal shed temperature (INT_TEMP, labeled T2), and either secondary external or tank temperature (EXT2_TEMP, labeled T3). These sensors communicate using the Dallas 1-Wire protocol, which allows multiple sensors on a single data line differentiated by unique 64-bit hardware addresses burned into each device during manufacturing.

The implementation uses address-locked mapping where each sensor's hardware address is explicitly bound to its logical function in the code. Device address 0x28-5B-83-57-00-00-00-13 is mapped to EXT_TEMP, address 0x28-2E-53-57-00-00-00-3E to INT_TEMP, and address 0x28-11-F1-35-00-00-00-D0 to EXT2_TEMP. This prevents confusion if sensors are disconnected and reconnected in different orders—each sensor's identity follows its hardware rather than its physical position in the cable. When the Dallas library requests temperature from a specific address, it returns the reading from that exact sensor regardless of bus topology.

The temperature sensors operate at 12-bit resolution, providing 0.0625 degree Celsius precision. The 1-Wire bus protocol requires careful timing and is susceptible to electrical noise, so AR2 implements resilience logic monitoring for complete bus failure. If all three sensors return invalid readings (values outside the valid range of -55 to +125 degrees Celsius, or the specific constant DEVICE_DISCONNECTED_C returned by the library when a sensor doesn't respond) for five consecutive sampling cycles, AR2 automatically performs a bus reset and reinitialization sequence. This handles cases where a voltage transient or electromagnetic pulse from lightning has disrupted the bus state, restoring functionality without requiring manual intervention. When sensors are not available, the code provides sensible default values—31 degrees for external temperature, 30 degrees for internal temperature, 32 degrees for secondary external—rather than allowing NaN (Not a Number) to propagate through calculations where it would cause comparison operations to fail.

Water depth measurement uses an analog pressure sensor connected to pin A0. The sensor sits at the bottom of the water tank and outputs a voltage proportional to the water column height above it, with the relationship calibrated such that 3.3 volts represents 3.2 meters of water depth. The Arduino's 10-bit analog-to-digital converter reads this voltage, and a simple linear mapping converts it to depth in meters: depth = (voltage / 3.3) × 3.2. This measurement is critical for water conservation decisions—the autonomous algorithm must know precisely how much water remains to determine whether aggressive fire defence is sustainable or whether conservation measures must take priority. The sensor's bottom-mounting position means that any water in the tank will be detected, even as levels fall to the minimum safe pump intake height.

Flow measurement employs two Hall-effect pulse sensors, one on the DN15 mains water feed line and one on the DN50 pump output line. Each sensor contains a small turbine that rotates in the water stream, with a magnet attached to the turbine and a Hall-effect sensor detecting each magnet passage, generating one pulse per rotation. The pulse rate is proportional to volumetric flow rate, with the proportionality constant depending on pipe diameter and turbine geometry. The DN15 sensor provides approximately 450 pulses per liter, calibrated by the manufacturer, while the DN50 sensor provides approximately 60 pulses per liter though this value requires field calibration by running the pump at a known flow rate and counting pulses over a timed interval.

These sensors connect to interrupt-capable pins on Arduino AR2 (pins 2 and 3), allowing pulse counting to occur asynchronously in interrupt service routines without requiring the main program loop to poll them. The interrupt service routines implement 8-millisecond debouncing by checking the time since the last pulse and only incrementing the counter if sufficient time has elapsed, preventing switch bounce or electrical noise from causing erroneous counts. Every 100 milliseconds, the main loop reads the accumulated pulse counts from the previous 100-millisecond interval, clears the counters to begin the next interval, and converts pulses to flow rate in liters per minute. The conversion first calculates pulse frequency in Hertz by multiplying the pulse count by 10 (since we're counting over 100-millisecond intervals, 10 intervals per second), then divides by the pulses-per-liter constant and multiplies by 60 to convert from liters per second to liters per minute.

<< The Heartbeat System and Mode Transitions | | Sensors cont >>      |Table of Contents>


Page last modified on February 17, 2026, at 07:18 am