AIN Command — Analog Input Reading
The AIN command allows reading the conditioned voltage value at the AD (Analog-to-Digital) inputs independently.
What is it used for?
🔌 Voltage monitoring — Reads main battery, auxiliary battery, or sensor voltages
⛽ Fuel sensors — Measures tank level with resistive sensors
🌡️ Analog sensors — Connects pressure, temperature sensors, etc.
📊 Custom calibration — Adjusts scale and offset for each input
Values can be customized using calibration factors and offset with the CXAIN command.
Syntax
| Operation | Command | Description |
|---|---|---|
| Query | QAINindex | Reads analog input value |
Parameters
| Field | Description | Values |
|---|---|---|
index | AD input number | 00, 01, 02, 07 |
Response
RAINindex sign value| Field | Description |
|---|---|
sign | + (positive) or - (negative) |
value | Conditioned value 0000-9999 |
Examples
Reading AD0 input
>QAIN00<
>RAIN00+1250;ID=1234;*3A<
// Result: +12.50 V (main battery)Reading AD1 input
>QAIN01<
>RAIN01+0850;ID=1234;*2B<
// Result: +8.50 V (fuel sensor)Reading AD2 input
>QAIN02<
>RAIN02+2400;ID=1234;*1C<
// Result: +24.00 V (truck battery)Reading with negative value
>QAIN07<
>RAIN07-0150;ID=1234;*4D<
// Result: -1.50 (temperature sensor with offset)Input Indexes
| Index | Input | Typical Application |
|---|---|---|
| 00 | AD0 | Battery voltage |
| 01 | AD1 | Fuel sensor |
| 02 | AD2 | Pressure sensor |
| 07 | AD7 | Temperature sensor |
Maximum admissible voltage: 30.00 VDC. Do not exceed this value to avoid permanent damage.
Conditioning with CXAIN
Customize scale and offset for each input:
>SCXAIN00 0100 0000<Parameters:
- Scale factor: 0100 (factor 100 = 1.00, no change)
- Offset: 0000 (no offset)
Example: Fuel sensor 0-100%
>SCXAIN01 0033 0000<- Factor: 0.33 (converts 0-3000 mV to 0-990 ≈ 0-100%)
- Offset: 0
Reading:
>QAIN01<
>RAIN01+0075;ID=1234;*2A<Interpretation: 75% fuel
Example: Temperature sensor -40C to +125C
>SCXAIN07 0100 -4000<- Factor: 1.00
- Offset: -40.00C
Reading:
>QAIN07<
>RAIN07+0285;ID=1234;*1B<Interpretation: 28.5C - 40 = -11.5C ambient
Use Cases
Auxiliary battery monitoring
>QAIN00<
>RAIN00+1340;ID=1234;*3A<Auxiliary battery at 13.4V → Charging correctly
Tank level sensor
// Configure for 0-100%
>SCXAIN01 0033 0000<
// Read level
>QAIN01<
>RAIN01+0082;ID=1234;*2B<Tank at 82%
Multi-sensor system
>QAIN00< # Main battery
>RAIN00+1270;ID=1234;*3A< # 12.7V
>QAIN01< # Fuel level
>RAIN01+0065;ID=1234;*2B< # 65%
>QAIN02< # Oil pressure
>RAIN02+0350;ID=1234;*1C< # 3.5 barIntegration with Reports
AD report (analog readings)
>QAD<Returns all AD inputs in a single report.
AE report (extended)
>QAE<Includes conditioned values and status flags.
Events with thresholds
>SRL03E;TRG=AIN00>1400;ACC={GBR00L}<Generates report when battery exceeds 14.0V (high charge).
Technical Specifications
| Parameter | Value |
|---|---|
| Input range | 0 - 30 VDC |
| ADC resolution | 12 bits |
| Accuracy | 0.1 V (typical) |
| Input impedance | >100 kΩ |
| Sampling frequency | Configurable |
Compatibility
See Also
- CXAIN Command - Conditioning configuration
- AD Report - Multiple voltage readings
- AE Report - Extended analog report
- DT Command - OneWire temperature