Interfacing of Voltage Sensor With Arduino

Hello friends ,

    I am Cyberautics , and In this project, we will learn how to measure voltages using Arduino by interfacing a Voltage Sensor with Arduino. Using this Arduino Voltage Sensor interface, you can measure voltages up to 25V.

BASICS

  • The Voltage Sensor is a simple module that can used with Arduino (or any other microcontroller with input tolerance of 5V) to measure external voltages that are greater than its maximum acceptable value i.e. 5V in case of Arduino.
  • Basically, a 25V Voltage Sensor, like the one used here, has 5 pins in total. Two of them are on the two-pin screw terminal and three are male header pins.
  • The header terminal pins are marked VCC and GND and they must be connected to the external source of voltage i.e. the voltage that needs to be measured.
  • Coming to the three male headers, they are marked as S, + and –. The S pin is the “Sense” pin and it must be connected to the Analog Input of the Arduino. The “–” pin must be connected to the GND of the Arduino. The pin marked as “+” is not connected to anything (it is an N/C Pin).
  • After interfacing the Voltage Sensor with Arduino, you can either view the results on the serial monitor of the Arduino IDE or on a 16×2 LCD Display. I have gone with the Serial Monitor.

COMPONENTS

  1. Arduino Uno
  2. Voltage Sensor(<25 v)
  3. Connecting Wires
  4. Breadboard

CIRCUIT DIAGRAM 



This is the basic diagram of the voltage sensor interface and you have to implement .

VCC: Positive terminal of the voltage to be measured (0-25V).
GND: Negative terminal of the voltage to be measured.
S: Analog Input of Arduino.
+: Not connected (N/C).
–: GND of Arduino.

MAKE OWN VOLTAGE SENSOR
  • Voltage Sensor is basically a Voltage Divider consisting of two resistors with resistances of 30KΩ and 7.5KΩ i.e. a 5 to 1 voltage divider.
  • The following image shows the schematic of the Voltage Sensor Module with an input voltage limit of 25V.


  • Using a pre-built voltage sensor module is very easy and if you don’t have one then you can easily build one yourself. All you need are two resistors.

  • If you want to make your own voltage sensor that can measure voltages up to 25V like this Voltage Sensor Module, then you have to get a 30KΩ and a 7.5KΩ resistor.

CODE
int voltagesensor=A1; //declare A1 as analog input pin
float vout,vin; 
float R1=30000.0, R2=7500.0; //set resistor value
int value;
void setup() {
  pinMode(A1,INPUT); //make A1 input value
  Serial.begin(9600);
}

void loop() {
  value=analogRead(A1); //fetch the   input value
  vout=(value*5)/1024.0;  //fetch the output value
  vin=vout(R1/(R1+R2)); //apply voltage divider rule
  Serial.println(vin); //output on serial monitor
}

EXPLANATION
  • Basically the Voltage Sensor module is basically a voltage divider circuit, you can calculate input voltage using the formula.

  • Here R1 = 30000, R2 = 7500 and Vout can be calculated from Analog Input of Arduino by using Vout = (analogvalue * 5 / 1024).
  • Vin = Vout * (R2/(R1+R2)) This formula is the formula of the voltage divider rule
  • Interfacing Voltage Sensor with Arduino Image 2.
  • I have implemented the same in the code. When I connected a 9V external supply as input to the Voltage Sensor, the calculated voltage is 1.94V, which is accurate enough.



This is the output image of voltage sensor and monitor it in serial monitor .

So Friends I have this Blog is useful for you, If you have any questions or doubts you can contact me.

Comments

Post a Comment