Voltage sensor, 0 to 25 V
A 30 k and 7.5 k divider on a red board: S is a fifth of the voltage on the screw terminal, so 25 V reads 5 V.
- 5 pins
- In 1 project
- In 1 lesson
The Voltage sensor, 0 to 25 V in brief
What it is, and where it sits on the bench.
The 0 to 25 V voltage sensor is the small red kit board with a screw terminal, VCC and GND for the voltage to measure, and a header of S, + and -. There is no chip: 30 k from VCC to S and 7.5 k from S to GND make S a fifth of the input, and the header’s + is not connected to anything. Wire S to A0 and - to the board’s GND. On an Uno 5 V at S is the 25 V of the listing; on an ESP32 the 3.3 V converter tops out at 16.5 V. Mokxi puts the two resistors really in the circuit, so the source sees 37.5 k of load and one with a few kilohms behind it reads low, as on a bench. An Uno’s 10-bit step is 24.4 mV on the terminal, and 12 V reads as 491 counts. The terminal’s GND and the header’s - are one trace, so the measured circuit shares the Arduino’s ground. The classic mistake is putting the voltage on the header’s +, which goes nowhere. Resistor tolerance, power rating, the clamping above 25 V and any isolation are not modeled.
- Family
- Sensors
- Pins
- 5
5 pins
Named as the editor names them, so a wire lands where you expect it.
GND. To the Arduino's GND.How to use the 0-25 V voltage sensor with an Arduino
The voltage to measure goes in the screw terminal, plus on VCC and minus on GND. On the header, S goes to A0 and minus to the Uno’s GND; the header’s plus is not connected to anything. The terminal’s GND and the header’s minus are one trace, so wiring minus to the Uno also grounds the measured circuit.
The board is a 30 k and 7.5 k divider, so S is a fifth of the input: read A0, scale to volts and multiply by 5. 12 V reads as 491 counts, and one count is 24.4 mV on the terminal. The example averages 16 readings and shows the bench supply’s voltage on an I2C LCD; press the supply’s buttons and the reading follows.
On an ESP32 or any 3.3 V board the same module reads at most 3.3 x 5 = 16.5 V, not 25, and a 12-bit reading scales as raw * 3.3 / 4095 before the times 5.
long sum = 0;
for (int i = 0; i < 16; i++) sum += analogRead(A0);
int raw = (sum + 8) / 16;
float atS = raw * 5.0 / 1023.0; // the voltage at S
float volts = atS * 5.0; // the divider is 5 to 1What is true about the Voltage sensor, 0 to 25 V, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
There is no datasheet for this board; the numbers are the ones every listing and tutorial gives (for example the components101 "Voltage Sensor Module" page):
The ratio. 30 k and 7.5 k make S = VIN / 5. 12 V on the terminal is 2.4 V on
S, which an Uno reads as 491.
The 25 V limit is the ADC's. On a 5 V Uno, S can go up to 5 V, which is 25 V
on the terminal. On a 3.3 V board (an ESP32, a Pico, an Arduino Due) the same board
reads at most 3.3 x 5 = 16.5 V. The resistors do not change.
The resolution. One step of a 5 V, 10-bit converter is 4.9 mV at S, so 24.4 mV
on the terminal. 9 V reads as 8.99 V on an Uno, and that is the converter, not the
board.
The shared ground. The terminal's GND and the header's - are one trace, so
wiring - to the Arduino puts the measured circuit's minus on the Arduino's ground.
That is how a bench supply's minus gets to ground in the DC voltmeter template.
Not modeled
The resistors' tolerance (1% or 5% on real boards; here the ratio is exactly 5, so a
real board may need a calibration factor), their power rating, and what happens past
25 V on a 5 V board: on a real one S goes over the converter's supply and the
microcontroller's input protection diode conducts through the 30 kohm. Nothing on the
board isolates the measured circuit, so it cannot measure mains or anything that must
not share a ground with the Arduino.
From Voltage sensor module, in full.
See the Voltage sensor, 0 to 25 V in a project
One built-in project uses it. It opens in the editor, already wired.
Where it turns up in a lesson
One lesson places it in its own circuit.
The boards it is shown on
This board has a built-in project with the Voltage sensor, 0 to 25 V in it.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Voltage sensor, 0 to 25 V
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.