ARMAC Fire Defence System - Technical Notes Part C
Electronics and Control Systems
This section describes the electronic control systems that operate the ARMAC fire defence system.
Pump-shed electronic sub-system
The pump shed contains three main electronic modules:
- The Relay Module (AR2) - Controls all relays that operate valves and the pump
- The Autonomous Module (AR3) - Makes automated decisions based on sensor inputs
- The Pump Control Module - Commercial unit with LTE connectivity
The Relay Module
The Relay Module (AR2) is an Arduino Mega 2560 that controls all the relays in the system. It receives commands from either:
- The Remote Control Module (AR1) in the house via RS485
- The Autonomous Module (AR3) directly when in autonomous mode
Arduino AR2 Pin Assignments:
| Pin | Function | Connection |
|---|---|---|
| D2-D13 | Relay outputs | To relay board inputs |
| A0-A7 | Spare analog inputs | Reserved for expansion |
| TX1/RX1 | RS485 communication | To house module AR1 |
| TX2/RX2 | Inter-module comms | To autonomous module AR3 |
The Autonomous Module
The Autonomous Module (AR3) is an Arduino Mega 2560 that monitors sensors and makes automated decisions when:
- Communication with the house is lost
- Manual control is unavailable
- Pre-programmed autonomous mode is activated
- Sensor thresholds are exceeded
Arduino AR3 pin assignments
| Pin | Function | Sensor/Device |
|---|---|---|
| A0 | External temperature | DS18B20 temperature sensor |
| A1 | Internal temperature | DS18B20 temperature sensor |
| A2 | Battery voltage | Voltage divider circuit |
| A3 | Flow sensor | Hall effect flow meter |
| A4 | Tank level | Ultrasonic distance sensor |
| A5 | Ember trap 1 | Thermal sensor |
| A6 | Ember trap 2 | Thermal sensor |
| A7 | Flame sensor | IR flame detector (720nm) |
| D2 | Ember trap 3 | Digital input |
| D3 | Ember trap 4 | Digital input |
| D11 | TestSys indicator | Reserved for test mode |
| TX2/RX2 | Inter-module comms | To relay module AR2 |
The Relay Module Details
The relay module controls:
Pump Control Relays (Hardware Interlocked):
- Relay 1: Pump START (momentary)
- Relay 2: Pump STOP (momentary)
- These use Songe latching relays with hardware interlock
Valve Control Relays:
- Relay 3: Low/High pressure 3-way motorised valve
- Relay 4: Spray/Recirculation 3-way motorised valve
- Relay 5: Shed cooling solenoid valve (NC)
- Relay 6: Gel injection valve
Spare Relays:
- Relays 7-12: Reserved for future expansion
Relays and the Arduino reset
A critical issue with Arduino-controlled relays is that when the Arduino resets (power-on or watchdog reset), all digital pins briefly go to their default state. This can cause unintended relay activation.
Solutions implemented:
- Hardware interlocks on pump START/STOP relays
- Pull-down resistors on all relay control lines
- Software initialization that sets safe states within 50ms of boot
- Watchdog timer to detect and recover from hangs
Logic Table for Hardware Interlocked Songe Latch Relays (Pump Control)
| START Signal | STOP Signal | Pump State | Notes |
|---|---|---|---|
| LOW | LOW | Maintained | No change |
| HIGH | LOW | STARTING | Pulse applied |
| LOW | HIGH | STOPPING | Pulse applied |
| HIGH | HIGH | BLOCKED | Hardware interlock prevents |
The hardware interlock uses diodes and resistors to ensure that if both START and STOP signals are accidentally HIGH simultaneously, neither relay activates. This prevents damage to the pump control module.
Key Hardware Behaviors
- Power-on Reset: Arduino pins default to INPUT (high impedance). Pull-down resistors ensure relays remain OFF during the ~50ms boot time.
- Watchdog Reset: If the program hangs, the watchdog timer triggers a reset. The system returns to a safe state.
- Communication Loss: If RS485 communication from the house is lost for > 30 seconds, the autonomous module takes over.
- Sensor Failure: If a critical sensor fails, the system uses fallback logic (see Sensor Failure Fallback section).
Relay setting programming notes
Key points from the relay control code:
- All relay states are tracked in a state variable array
- Changes to relay states are logged to SD card with timestamp
- Before activating a valve relay, the code checks that sufficient time has elapsed since the last change (motorised valves need ~15 seconds to complete travel)
- Pump START/STOP commands are momentary pulses (200ms)
- Gel injection valve has a flow totalizer to prevent over-dosing
Example code structure:
void setRelay(int relayNum, boolean state) {
if (relayState[relayNum] != state) {
digitalWrite(relayPin[relayNum], state);
relayState[relayNum] = state;
logRelayChange(relayNum, state);
}
}
Relay setting wiring notes
The relay board connections:
- Power: 12V supply from battery via fuse
- Control: Optoisolated inputs from Arduino pins
- Outputs: Relay contacts rated 10A at 240VAC
- LED indicators: Each relay has an LED showing state
- Protection: Snubber diodes across inductive loads
Wiring color code:
- Red: +12V power
- Black: Ground
- Yellow: Control signals from Arduino
- Blue: Valve control outputs
- Green: Pump control outputs
Tank Water Level Sensor installation
The tank water level sensor is an ultrasonic distance sensor (HC-SR04 style) mounted at the top of the tank. It measures the distance to the water surface and calculates the water level.
Specifications:
- Range: 2cm to 400cm
- Accuracy: ±3mm
- Update rate: 1 reading per second
- Power: 5V from Arduino
- Output: Pulse width proportional to distance
Mounting:
- Sensor mounted in weatherproof enclosure
- Cable: 4-wire shielded cable
- Entry: Through sealed gland in tank roof
- Calibration: Zero level set at tank bottom
The sensor reading is converted to litres using:
litres = PI * (radius^2) * (tankHeight - measuredDistance)
where radius = 1.75m and tankHeight = 3.1m for our 30.3kL tank.
System response to Ember attack
When an ember trap is triggered, the autonomous module follows this logic:
- Immediate: Activate shed cooling (if not already on)
- Within 30 seconds: Start pump if not running
- Within 60 seconds: Switch to low volume spray mode
- Monitor: External temperature and rate of rise
- Adjust: Switch to high volume if temp > 65°C or rate > 10°C/min
- Cycle: Enter intermittent mode if no further ember detections for 10 minutes
Inter-Module Communication
Communication between the house module (AR1) and pump shed modules (AR2, AR3) uses RS485 serial protocol over a 2-wire twisted pair cable.
RS485 Advantages:
- Differential signaling (immune to electrical noise)
- Long distance capable (>100m, we use 10m)
- Multiple devices on same bus
- Robust in harsh environments
Protocol:
- Baud rate: 9600 bps
- Data format: 8N1 (8 data bits, no parity, 1 stop bit)
- Message format: STX + Command + Data + Checksum + ETX
- Timeout: 5 seconds
- Retry: 3 attempts before failover to autonomous
Message Types:
| Command | Direction | Purpose |
|---|---|---|
| PUMP_START | House -> Shed | Start the pump |
| PUMP_STOP | House -> Shed | Stop the pump |
| SET_MODE | House -> Shed | Change spray mode |
| GET_STATUS | House -> Shed | Request sensor readings |
| STATUS_DATA | Shed -> House | Sensor data response |
| EMERGENCY | House -> Shed | Emergency activation |
| HEARTBEAT | House <-> Shed | Communication check |
The heartbeat message is sent every 10 seconds. If 3 consecutive heartbeats are missed, the system assumes communication failure and the autonomous module takes over.
Criteria for Automatic actions in the Autonomous mode
The autonomous module makes decisions based on a decision matrix:
| Condition | Pump Action | Mode | Notes |
|---|---|---|---|
| Ember trap triggered | START | Low volume | Immediate response |
| External temp > 65°C | Maintain ON | High volume | Fire front approaching |
| Temp rise > 10°C/min | Maintain ON | High volume | Rapid approach |
| Temp 45-65°C | START | Low volume | Moderate threat |
| Temp < 45°C, no embers 10min | Intermittent | Recirculation | Conserve water |
| Battery < 12.0V | Maintain state | Valve switch only | Preserve battery |
| Tank < 2000L | STOP | None | Protect pump |
| Manual override | As commanded | As commanded | Dashboard takes priority |
The autonomous module also implements hysteresis to prevent rapid switching:
- Temperature must drop 5°C below threshold before downgrading mode
- Ember trap must be clear for 10 minutes before reducing spray
- Mode changes are rate-limited to once per 5 minutes
Sensor Failure Fallback
If sensors fail, the system uses these fallback strategies:
| Failed Sensor | Fallback Strategy |
|---|---|
| External temperature | Use internal temp + 20°C estimate |
| Internal temperature | Assume 50°C if pump running |
| Flow sensor | Use mode-based flow estimate |
| Tank level | Assume 50% capacity |
| Battery voltage | Assume 12.5V, disable pump cycling |
| All ember traps | Rely on temperature sensors only |
| Camera | Continue with other sensors |
Multiple sensor failures trigger a warning message (if communication available) and the system defaults to a conservative strategy: low volume spray with recirculation cycling.
System Testing: The TestSys Module
A dedicated test system is implemented to verify correct operation without actually spraying water:
- Test Mode Activation: GPIO pin 11 on AR3 jumpered to ground
- LED Indicator: Shows system is in test mode
- Relay Monitoring: All relay commands logged but not executed
- Sensor Simulation: Can inject simulated sensor values
- Communication Test: Verifies RS485 links
- Valve Position: Displays intended positions without moving
Test scenarios include:
- Ember trap activation sequence
- Temperature rise simulation
- Communication failure
- Low battery response
- Tank low level
- Sensor failures
Voltage surge circuit protection
The electronics are protected against voltage surges using:
- TVS Diodes: Bidirectional transient voltage suppressors on all sensor inputs
- Varistors: Metal oxide varistors on power supply inputs
- Fuses: Inline fuses on all power feeds
- Optoisolators: Isolate Arduino outputs from relay coils
- Common mode chokes: On RS485 communication lines
These protections are essential because:
- Pump starting creates voltage spikes
- Solenoid valves generate back-EMF
- Lightning strikes can induce voltages in long cables
- The shed is partially a Faraday cage (can build up static)
Parallel circuit protection
Where multiple sensors or devices share power or signal lines, protection includes:
- Individual fuses: Each device has its own fuse
- Isolation diodes: Prevent one failed device affecting others
- Pull-up/pull-down resistors: Ensure defined states
- Bypass capacitors: Filter local noise
LCD DISPLAY in shed of key parameters in real time
A 20x4 character LCD display mounted in the pump shed shows real-time system status:
Line 1: Pump state, Mode, Battery voltage Line 2: External temp, Internal temp, Flow rate Line 3: Tank level (%), Ember traps status Line 4: Communication status, Autonomous/Manual mode
Example display:
PUMP:ON HI-V 12.8V ExtT:58C In:42C 145L Tank:67% Emb:-- -- WiFi:OK MANUAL
The display updates every 2 seconds and provides valuable local monitoring without needing to access the dashboard.
Protection against voltage surge and spikes
Additional protection measures beyond those already mentioned:
- Input filtering: RC low-pass filters on all analog inputs
- Ground plane: PCB with solid ground plane
- Star grounding: Single point ground for all electronics
- Shielded cables: For sensors exposed to electromagnetic interference
- Ferrite beads: On power and communication cables
Protection of electronic components from water spray incident
Although the pump shed is designed to be cooled by water spray, the electronics must be protected:
- Waterproof enclosures: IP65 rated boxes for all electronics
- Cable glands: Sealed entries for all cables
- Elevated mounting: Electronics mounted high in the shed
- Drainage: Enclosures have drain holes at bottom
- Desiccant packs: Inside enclosures to absorb moisture
- Conformal coating: PCBs coated with protective lacquer
The Arduino modules are in separate enclosures from the high-voltage relay boards to minimize risk.
Pump Control Module setup
The commercial pump control module (from pump supplier) includes:
- LTE modem (G4) with SIM card
- Relay outputs for remote START/STOP
- SMS command interface
- Input terminals for external control
- Battery voltage monitoring
- Run-time hour meter
Integration with our system:
- Our relay module (AR2) connects to the external control terminals
- Pump status is read back via a voltage sense line
- SMS commands provide backup control if RS485 fails
- Hour meter data is logged for maintenance scheduling
SMS Commands:
- START - Starts the pump
- STOP - Stops the pump
- STATUS - Returns pump state, runtime, battery voltage
Electronically controlled Valves
The system uses two types of electronically controlled valves:
Motorised 3-way Valves (2 units):
- Type: Ball valve with electric actuator
- Power: 240VAC (via relay)
- Travel time: 15 seconds
- Positions: A-AB-B (3 positions)
- Feedback: Limit switches at each end position
- Used for: Low/High pressure, Spray/Recirculation
Solenoid Valves (1 unit):
- Type: Normally Closed (NC)
- Power: 12VDC (via relay)
- Response time: <1 second
- Used for: Shed cooling spray
The motorised valves have internal limit switches that cut power when the valve reaches the commanded position. This prevents overdriving the motor.
Sensors
The system employs multiple sensor types:
| Sensor | Type | Range | Accuracy |
|---|---|---|---|
| External temp | DS18B20 | -55 to 125°C | ±0.5°C |
| Internal temp | DS18B20 | -55 to 125°C | ±0.5°C |
| Battery voltage | Resistor divider | 0-15V | ±0.1V |
| Flow rate | Hall effect | 1-100 L/min | ±2% |
| Tank level | Ultrasonic | 0-4m | ±3mm |
| Ember trap | Thermistor | 0-300°C | ±5°C |
| Flame | IR photodiode | 720nm | 1m range |
All sensors are read by Arduino AR3 and the data is sent to AR1 for dashboard display and to AR2 for relay decision logic.
Motorised 3-way (and 2-way on/off) valves
The motorised valves are controlled by applying 240VAC to the motor for the duration needed to move the valve to the desired position.
Valve 1: Low/High Pressure
- Position A: Low pressure (180 kPa) - bypass restrictor
- Position B: High pressure (420 kPa) - through restrictor
Valve 2: Spray/Recirculation
- Position A: Spray to sprinklers
- Position B: Recirculate to tank
The Arduino tracks the current position and only activates the relay if a change is needed. Travel time is 15 seconds, so the code waits 20 seconds between commands to the same valve.
Switching the Valves using a single Songe 2-way relay
Each motorised valve requires reversing polarity to switch direction. This is accomplished using a DPDT relay configuration:
Relay OFF: Motor + to L, Motor - to N (Position A) Relay ON: Motor + to N, Motor - to L (Position B)
The limit switches in the valve cut power when the valve reaches the end of travel, so the relay can remain energized without damaging the motor.
Programming the microcomputers
All three Arduino modules (AR1, AR2, AR3) are programmed in C++ using the Arduino IDE. The programs include:
AR1 - Remote Control Module (House):
- Blynk library for dashboard
- RS485 communication library
- Watchdog timer
- ~1800 lines of code
AR2 - Relay Module (Shed):
- Relay control functions
- Inter-module communication
- SD card logging
- ~1300 lines of code
AR3 - Autonomous Module (Shed):
- Sensor reading and filtering
- Decision logic
- Failover handling
- ~2100 lines of code
Key libraries used:
- OneWire and DallasTemperature (for DS18B20 sensors)
- SoftwareSerial or HardwareSerial (for RS485)
- SD (for logging)
- Blynk (for AR1 dashboard)
Example sensor reading code:
// Read external temperature sensors.requestTemperatures(); float extTemp = sensors.getTempCByIndex(0); // Apply simple averaging filter extTempFiltered = (extTempFiltered * 0.9) + (extTemp * 0.1);
Bench Testing the Programmes
Before installation, all programmes were extensively tested on a bench setup:
- Hardware simulation: Potentiometers to simulate sensors
- LED indicators: Show relay states without connecting valves
- Serial monitor: Display all variables and logic states
- Simulated inputs: Inject test conditions (high temp, low battery, etc.)
- Communication test: Two Arduinos connected via RS485
Test scenarios validated:
- Normal operation sequences
- Sensor failure detection
- Communication loss and recovery
- Autonomous mode activation
- Battery low response
- Emergency shutdown
- Mode transitions
Only after passing all bench tests was the code deployed to the actual hardware in the shed.
Return to: Part A? | Part B | Main Index?
