รู้จักสินค้านี้
Voltage detection module 0 - 25 Volt โมดูลวัดแรงดันไฟฟ้า 0 - 25 โวลต์
Module introduction:
This module is designed based on the principle of resistor divider to reduce the input voltage of the terminal interface by 5 times and the analog input voltage to 5V at most. The input voltage of the voltage detection module cannot be greater than 5V 5 = 25V (if a 3.3V system is used) The input voltage cannot be greater than 3.3Vx5=16.5V). Because the AVR chip used by A is a 10-bit AD, the analog resolution of this module is 0.00489V (5V/1023), so the voltage detection module detects that the input minimum voltage is 0.00489V5=0.02445V.
Parameters:
Voltage input range: DC 0-25V
Voltage detection range: DC0.02445V-25V
Voltage analog resolution: 0.00489V
DC input interface: terminal positive terminal is connected to VCC, negative terminal is connected to GND
output interface: "+" is connected to 5/3.3V, - "Connect GND," s" to Arduino's AD pin
Code :
int analogInput = A1;
int LED = 2;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; //30k
float R2 = 7500.0; //7500 ohm resistor
int value = 0;
void setup()
{
pinMode(analogInput, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600);
Serial.println("BASIC DC VOLTMETER");
}
void loop()
{
// read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
Serial.print("Voltage = ");
Serial.println(vin,2);
delay(500);
if (vin > 12 ){
digitalWrite(LED, HIGH);
}
if (vin
digitalWrite(LED, LOW);
}
}
https://www.electronicshub.org/interfacing-voltage-sensor-with-arduino/