Ks0275 keyestudio Voltage Detection Module Voltage Sensor

From Keyestudio Wiki
Jump to: navigation, search


Since the electronic products are various, the voltage of the power supply is also different. It is indeed necessary to detect it with a suitable voltage detection module or controller.
The maximum input voltage of the controller’s analog interface is 5V, which means that the voltage greater than 5V will not be detected.
However, this voltage detection module can achieve to detect the voltage greater than 5V. It is designed on the basis of resistive voltage divider principle, which can make the input voltage of bindingpost interface narrow 5 times, and the analog input voltage is up to 5V, thus the input voltage of voltage detection module is not greater than 5V * 5 = 25V (if using 3.3V system, the input voltage is not greater than 3.3V*5 = 16.5V).
The AVR chip is 10-bit AD, so the analog resolution of this module is 0.00489V (5V / 1023), and the minimum input voltage is 0.00489V * 5 = 0.02445V.
When connect this sensor to expansion board using 3Pin wire, it can not only easily detect the magnitude of the voltage power and monitor the electric quantity of battery for interactive media works or robot, but also can combine with IIC LCD1602 LCD module to display the voltage or make a voltage monitor.



  • Working voltage:0V-25V DC
  • Signal type: analog signal

Connection Diagram


Sample Code

int analogpin=0;     // Define analogpin as analog port 0               
int val,val5;       //Define variables val,val5
int val2=0;      //Define variables val2
int val3=0;     //Define variables val3
int val4=0;    //Define variables val4

void setup()
    Serial.begin(9600);     //Set baud rate of 9600
void loop()
    int val,val5;
    float val1;
    val=analogRead(analogpin);     //Read the value of the analog port and assign it to the variable val
    Serial.print("$CLEAR\r\n");      //clear the screen
    Serial.print("$GO 1 1\r\n");                 
    Serial.print("$PRINT Voltage:\r\n");         
    Serial.print("$GO 1 9\r\n"); 
    Serial.print("$PRINT ");         
Serial.print(val3);        //The serial port prints the value of the variable val3
Serial.print(val2);      //The serial port prints the value of the variable val2
    Serial.print(".");               //The serial port prints out a point"."
    Serial.print(val4);         //The serial port prints the value of the variable val4
    Serial.println("V");          //The serial port prints out capital “ V”
    delay(100);      //delay 0.1 second


Done as the above wiring, compile and upload the code, powered-on, then open the serial monitor, it will print out the detected voltage value shown below.



  • PDF File:


  • Code:


  • VIDEO:


Get One Now