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
The CXAIN command defines a two-point conversion curve over the voltage read on each input. It lets you express the reading in any unit you need (liters, percent, °C, mV, etc.) and clamp the output to a safe range.
The full syntax is:
SCXAINaa<BOTTOM><TOP><XA><XB><YA><YB>Where each numeric block carries a sign and 4 digits, and the voltages XA/XB are expressed in hundredths of a volt (0500 = 5.00 V).
Example: Fuel sensor 0–5 V → 0–100 %
>SCXAIN01+0000+0100+0000+0500+0000+0100<BOTTOM= 0 %,TOP= 100 % (output clamp)XA= 0.00 V →YA= 0 %XB= 5.00 V →YB= 100 %
Reading:
>QAIN01<
>RAIN01+0075;ID=1234;*2A<Interpretation: 75 % fuel.
Example: Temperature sensor 0–5 V → −40 °C to +150 °C
>SCXAIN07-0040+0150+0000+0500-0040+0150<BOTTOM= −40 °C,TOP= +150 °CXA= 0.00 V →YA= −40 °CXB= 5.00 V →YB= +150 °C
Reading:
>QAIN07<
>RAIN07-0115;ID=1234;*1B<Interpretation: −11.5 °C ambient.
Use Cases
Auxiliary battery monitoring
>QAIN00<
>RAIN00+1340;ID=1234;*3A<Auxiliary battery at 13.4V → Charging correctly
Tank level sensor
// Configure 0-5V → 0-100%
>SCXAIN01+0000+0100+0000+0500+0000+0100<
// 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