Measure voltage with the Arduino
FunduinoLast updated on
Bis zu 25 Volt Gleichspannung mit dem Spannungssensor messen
You need this
0-25 V Voltage Sensor - 0-5 V analog output, optocoupler
1,11 € *Item no. F23106636About the product — 0-25 V Voltage Sensor - 0-5 V analog output, optocoupler
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard cables male-female - 40 pieces, 20 cm
1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm
All 4 parts together 16,87 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
What a voltage sensor is used for
Connect the sensor
Read voltage
Measure the voltage and display it in the serial monitor.
float reading;
float voltage;
void setup()
{
// Start the serial connection. This is necessary to send the results later to the
// serial monitor using the Serial.println command.
Serial.begin(9600);
}
void loop()
{
// Read the voltage value at analog input 1
reading = analogRead(1);
// Convert the sensor value using the map command. Since map does not return decimal places,
// larger numbers are used here for now.
voltage = map(reading, 0, 1023, 0, 250);
// Divide the result by 10 so it can be output as a correct value with one
// decimal place.
voltage = voltage / 10;
// Display the final voltage value in the serial monitor. The number 2 in parentheses
// ensures that the result is displayed with two decimal places. A 1
// would give one decimal place.
Serial.println(voltage, 2);
// Wait one second so that too much data does not arrive in the serial monitor.
delay(1000);
}Check result
Rate the instructions