To measure AV voltage you will need to have a zmpt101b module. All you have to do is connect vcc of the module to 5v of the Arduino GND to ground of the Arduino and vout to analogue pin 0 of the Arduino. Once all the connections are made you just need to upload the code to the Arduino and open the serial monitor and the voltage will be displayed. You can measure up to 300v with this module.
To measure DC voltage you will need to have a 100k resistor and connect it between ground and analogue pin 0 and then you will want to connect the 1m resistor to analogue pin 0 and then connect the other side of this resistor the voltage you would like to test. Once all the connections are made you just need to upload the code to the Arduino and open the serial monitor and the voltage will be displayed. With these resistor values you can measure up to 50v.
void setup()
{
Serial.begin(9600);
}
void loop() {
int Input = analogRead(A0); // Read the analog value
double voltage = Input * (5.0 / 1024.0) * 10; //convert the value to volts
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.println(" V");
delay(2500);
}
CurrentTo measure current you will need to have a ACS712 hall effect current sensor module. All you have to do is connect vcc of the module to 5v of the Arduino GND to ground of the Arduino and vout to analogue pin 0 of the Arduino. Once all the connections are made you just need to upload the code to the Arduino and open the serial monitor and the current will be displayed. I used the 20amp version so the mv/amp value is 100 but if you have a different version you will need to change this.
const int analogIn = A0; //the pin the sensor is connected to
double Value= 0;
double ACSoffset = 2500; // ofset for the ACS712
double mVAmp = 100;// mv per amp for your sensor you can find this on its data sheet
double Amps = 0;
double Voltage = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
Value = analogRead(analogIn);
Voltage = (Value / 1024) * 5000; // converts the signal in to mA
Amps = ((Voltage - ACSoffset) / mVAmp);
Serial.print("\t Amps = "); // displays the current measured
Serial.println(Amps,3); // sets the number of digits displayed after the decimal point
delay(2500); // waits 2.5 seconds then repeats the process
ResistanceTo measure resistance you will need to have a 1k resistor and connect it between ground and analogue pin 0 and then you will want to connect the resistor you would like to test to analogue pin 0 and 5v. Once all the connections are made you just need to upload the code to the Arduino and open the serial monitor and the resistance will be displayed.
const int analogIn= 0; // //the pin the center of the voltage devider is connected to
int Value= 0;
int Vin= 5;
double buffer= 0;
double Vout= 0;
double Rtest= 0;
double R1= 1000;
void setup()
{
Serial.begin(9600);
}
void loop()
{
Value= analogRead(analogIn);
if(Value)
buffer= Value * Vin;
Vout= (buffer)/1024.0;
buffer= (Vin/Vout) -1;
Rtest= R1 * buffer;
Serial.print("Resisor value: ");//displays the resistance
Serial.println(Rtest);//displays the value of the resistor
delay(2500);
AcknowledgementI thank PCBWay & LCSC Electronics for the partnership.
PCBWay Is a cheap reliable service where you can get your PCBs manufactured. All the PCBs are high quality and the engineers are very helpful and will resolve any problems you may have quickly. Sign up today and get a $5 welcome bonus. Check Out PCBWay Hackster page. Check out PCBWay's new online Gerber viewer
LCSC Electronics Is China's leading Electronic Components Distributor. LCSC sells a wide variety of high quality electronic components at low prices. With over 150, 000 parts in stock they should have the components you need for your next project. Sign up today and get $8 off on your first order.
WebsiteCheck out more of my other projects on my website.
Comments
Please log in or sign up to comment.