Tuesday, June 12, 2018

Arduino Capacitor tester with LCD

By this arduino project you can measure the capacity of capacitors with value between 0.1uF to 3500uF.


Here arduino calculate the capacity value by measuring the time required to charge the capacity to reach 63.2% of source voltage(According to Capacitor time constant formula), then divided this time by resistor value which is 10K to find out the capacitor value.

Arduino Capacitor tester with LCD
Parts list:
Arduino Board
LCD 16x2
Breadboard 
Connecting wire
Potentiometer 10K
Resistor 10K
Resistor 220 ohm(2pcs)

Wiring:
10K resistor used for charging the capacitor and 220 ohm used for discharging.

Capacitor under test with 47uF nominal value

Arduino Capacitor tester with LCD



Capacitor Charge and discharge curve on oscilloscope:


Arduino Capacitor tester with LCD


Code: 

#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
#define analogPin      0         
#define chargePin      13        
#define dischargePin   3       
#define resistorValue  10000.0F  //Remember, we've used a 10K resistor to charge the capacitor

unsigned long startTime;
unsigned long elapsedTime;
float microFarads;               
float nanoFarads;

void setup(){
  pinMode(chargePin, OUTPUT);    
  digitalWrite(chargePin, LOW);
  lcd.begin(16, 2);  //LCD order

}

void loop(){
  digitalWrite(chargePin, HIGH); 
  startTime = micros();
  while(analogRead(analogPin) < 648){      
  }

  elapsedTime= micros() - startTime;
  microFarads = ((float)elapsedTime / resistorValue) ;

    
 
  if (microFarads > 1){

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Capacitor = ");
    lcd.setCursor(0,1); 
    lcd.print(microFarads);
    lcd.setCursor(9,1);       
    lcd.print("uF");  
    delay(500);   
  }

  else{
    nanoFarads = microFarads * 1000.0;
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Capacitor = ");
    lcd.setCursor(0,1);      
    lcd.print(nanoFarads-11.2); 
    lcd.setCursor(9,1);      
    lcd.print("nF");         
    delay(500);
  }

 
 
  digitalWrite(chargePin, LOW);           
  pinMode(dischargePin, OUTPUT);           
  digitalWrite(dischargePin, LOW);     //discharging the capacitor    
  while(analogRead(analogPin) > 0){        
  }//This while waits till the capaccitor is discharged

  pinMode(dischargePin, INPUT);      //this sets the pin to high impedance


}

Wednesday, June 6, 2018

Arduino Spirit Level with LCD

Arduino Spirit Level with LCD

Parts list:
Arduino board
LCD 16x2
Gyroscope MPU-6050
Potentiometer 10K
Resistor 220 ohm
Breadbord
Connecting wire

Wiring:

Arduino Spirit Level with LCD
Video:




Code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

#include <Wire.h>

//Declaring some global variables
int gyro_x, gyro_y, gyro_z;
long acc_x, acc_y, acc_z, acc_total_vector;
int temperature;
long gyro_x_cal, gyro_y_cal, gyro_z_cal;
long loop_timer;
int lcd_loop_counter;
float angle_pitch, angle_roll;
int angle_pitch_buffer, angle_roll_buffer;
boolean set_gyro_angles;
float angle_roll_acc, angle_pitch_acc;
float angle_pitch_output, angle_roll_output;

//Initialize the LCD library
//LiquidCrystal_I2C lcd(0x27,16,2);


void setup() {
  Wire.begin();                                                        //Start I2C as master
  //Serial.begin(57600);                                               //Use only for debugging
  pinMode(13, OUTPUT);                                                 //Set output 13 (LED) as output
 
  setup_mpu_6050_registers();                                          //Setup the registers of the MPU-6050 (500dfs / +/-8g) and start the gyro

  digitalWrite(13, HIGH);                                              //Set digital output 13 high to indicate startup

  lcd.begin(16, 2);  //LCD order

  lcd.setCursor(0,0);                                                  //Set the LCD cursor to position to position 0,0
  lcd.print("Spirit Level");                                         //Print text to screen
  lcd.setCursor(0,1);                                                  //Set the LCD cursor to position to position 0,1
  lcd.print("     V1.0");                                              //Print text to screen

  delay(1500);                                                         //Delay 1.5 second to display the text
  lcd.clear();                                                         //Clear the LCD
 
  lcd.setCursor(0,0);                                                  //Set the LCD cursor to position to position 0,0
  lcd.print("Calibrating gyro");                                       //Print text to screen
  lcd.setCursor(0,1);                                                  //Set the LCD cursor to position to position 0,1
  for (int cal_int = 0; cal_int < 2000 ; cal_int ++){                  //Run this code 2000 times
    if(cal_int % 125 == 0)lcd.print(".");                              //Print a dot on the LCD every 125 readings
    read_mpu_6050_data();                                              //Read the raw acc and gyro data from the MPU-6050
    gyro_x_cal += gyro_x;                                              //Add the gyro x-axis offset to the gyro_x_cal variable
    gyro_y_cal += gyro_y;                                              //Add the gyro y-axis offset to the gyro_y_cal variable
    gyro_z_cal += gyro_z;                                              //Add the gyro z-axis offset to the gyro_z_cal variable
    delay(3);                                                          //Delay 3us to simulate the 250Hz program loop
  }
  gyro_x_cal /= 2000;                                                  //Divide the gyro_x_cal variable by 2000 to get the avarage offset
  gyro_y_cal /= 2000;                                                  //Divide the gyro_y_cal variable by 2000 to get the avarage offset
  gyro_z_cal /= 2000;                                                  //Divide the gyro_z_cal variable by 2000 to get the avarage offset

  lcd.clear();                                                         //Clear the LCD
 
  lcd.setCursor(0,0);                                                  //Set the LCD cursor to position to position 0,0
  lcd.print("Pitch:");                                                 //Print text to screen
  lcd.setCursor(0,1);                                                  //Set the LCD cursor to position to position 0,1
  lcd.print("Roll :");                                                 //Print text to screen
 
  digitalWrite(13, LOW);                                               //All done, turn the LED off
 
  loop_timer = micros();                                               //Reset the loop timer
}

void loop(){

  read_mpu_6050_data();                                                //Read the raw acc and gyro data from the MPU-6050

  gyro_x -= gyro_x_cal;                                                //Subtract the offset calibration value from the raw gyro_x value
  gyro_y -= gyro_y_cal;                                                //Subtract the offset calibration value from the raw gyro_y value
  gyro_z -= gyro_z_cal;                                                //Subtract the offset calibration value from the raw gyro_z value
 
  //Gyro angle calculations
  //0.0000611 = 1 / (250Hz / 65.5)
  angle_pitch += gyro_x * 0.0000611;                                   //Calculate the traveled pitch angle and add this to the angle_pitch variable
  angle_roll += gyro_y * 0.0000611;                                    //Calculate the traveled roll angle and add this to the angle_roll variable
 
  //0.000001066 = 0.0000611 * (3.142(PI) / 180degr) The Arduino sin function is in radians
  angle_pitch += angle_roll * sin(gyro_z * 0.000001066);               //If the IMU has yawed transfer the roll angle to the pitch angel
  angle_roll -= angle_pitch * sin(gyro_z * 0.000001066);               //If the IMU has yawed transfer the pitch angle to the roll angel
 
  //Accelerometer angle calculations
  acc_total_vector = sqrt((acc_x*acc_x)+(acc_y*acc_y)+(acc_z*acc_z));  //Calculate the total accelerometer vector
  //57.296 = 1 / (3.142 / 180) The Arduino asin function is in radians
  angle_pitch_acc = asin((float)acc_y/acc_total_vector)* 57.296;       //Calculate the pitch angle
  angle_roll_acc = asin((float)acc_x/acc_total_vector)* -57.296;       //Calculate the roll angle
 
  //Place the MPU-6050 spirit level and note the values in the following two lines for calibration
  angle_pitch_acc -= 0.0;                                              //Accelerometer calibration value for pitch
  angle_roll_acc -= 0.0;                                               //Accelerometer calibration value for roll

  if(set_gyro_angles){                                                 //If the IMU is already started
    angle_pitch = angle_pitch * 0.9996 + angle_pitch_acc * 0.0004;     //Correct the drift of the gyro pitch angle with the accelerometer pitch angle
    angle_roll = angle_roll * 0.9996 + angle_roll_acc * 0.0004;        //Correct the drift of the gyro roll angle with the accelerometer roll angle
  }
  else{                                                                //At first start
    angle_pitch = angle_pitch_acc;                                     //Set the gyro pitch angle equal to the accelerometer pitch angle
    angle_roll = angle_roll_acc;                                       //Set the gyro roll angle equal to the accelerometer roll angle
    set_gyro_angles = true;                                            //Set the IMU started flag
  }
 
  //To dampen the pitch and roll angles a complementary filter is used
  angle_pitch_output = angle_pitch_output * 0.9 + angle_pitch * 0.1;   //Take 90% of the output pitch value and add 10% of the raw pitch value
  angle_roll_output = angle_roll_output * 0.9 + angle_roll * 0.1;      //Take 90% of the output roll value and add 10% of the raw roll value
 
  write_LCD();                                                         //Write the roll and pitch values to the LCD display

  while(micros() - loop_timer < 4000);                                 //Wait until the loop_timer reaches 4000us (250Hz) before starting the next loop
  loop_timer = micros();                                               //Reset the loop timer
}


void read_mpu_6050_data(){                                             //Subroutine for reading the raw gyro and accelerometer data
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x3B);                                                    //Send the requested starting register
  Wire.endTransmission();                                              //End the transmission
  Wire.requestFrom(0x68,14);                                           //Request 14 bytes from the MPU-6050
  while(Wire.available() < 14);                                        //Wait until all the bytes are received
  acc_x = Wire.read()<<8|Wire.read();                                  //Add the low and high byte to the acc_x variable
  acc_y = Wire.read()<<8|Wire.read();                                  //Add the low and high byte to the acc_y variable
  acc_z = Wire.read()<<8|Wire.read();                                  //Add the low and high byte to the acc_z variable
  temperature = Wire.read()<<8|Wire.read();                            //Add the low and high byte to the temperature variable
  gyro_x = Wire.read()<<8|Wire.read();                                 //Add the low and high byte to the gyro_x variable
  gyro_y = Wire.read()<<8|Wire.read();                                 //Add the low and high byte to the gyro_y variable
  gyro_z = Wire.read()<<8|Wire.read();                                 //Add the low and high byte to the gyro_z variable

}

void write_LCD(){                                                      //Subroutine for writing the LCD
  //To get a 250Hz program loop (4us) it's only possible to write one character per loop
  //Writing multiple characters is taking to much time
  if(lcd_loop_counter == 14)lcd_loop_counter = 0;                      //Reset the counter after 14 characters
  lcd_loop_counter ++;                                                 //Increase the counter
  if(lcd_loop_counter == 1){
    angle_pitch_buffer = angle_pitch_output * 10;                      //Buffer the pitch angle because it will change
    lcd.setCursor(6,0);                                                //Set the LCD cursor to position to position 0,0
  }
  if(lcd_loop_counter == 2){
    if(angle_pitch_buffer < 0)lcd.print("-");                          //Print - if value is negative
    else lcd.print("+");                                               //Print + if value is negative
  }
  if(lcd_loop_counter == 3)lcd.print(abs(angle_pitch_buffer)/1000);    //Print first number
  if(lcd_loop_counter == 4)lcd.print((abs(angle_pitch_buffer)/100)%10);//Print second number
  if(lcd_loop_counter == 5)lcd.print((abs(angle_pitch_buffer)/10)%10); //Print third number
  if(lcd_loop_counter == 6)lcd.print(".");                             //Print decimal point
  if(lcd_loop_counter == 7)lcd.print(abs(angle_pitch_buffer)%10);      //Print decimal number

  if(lcd_loop_counter == 8){
    angle_roll_buffer = angle_roll_output * 10;
    lcd.setCursor(6,1);
  }
  if(lcd_loop_counter == 9){
    if(angle_roll_buffer < 0)lcd.print("-");                           //Print - if value is negative
    else lcd.print("+");                                               //Print + if value is negative
  }
  if(lcd_loop_counter == 10)lcd.print(abs(angle_roll_buffer)/1000);    //Print first number
  if(lcd_loop_counter == 11)lcd.print((abs(angle_roll_buffer)/100)%10);//Print second number
  if(lcd_loop_counter == 12)lcd.print((abs(angle_roll_buffer)/10)%10); //Print third number
  if(lcd_loop_counter == 13)lcd.print(".");                            //Print decimal point
  if(lcd_loop_counter == 14)lcd.print(abs(angle_roll_buffer)%10);      //Print decimal number
}

void setup_mpu_6050_registers(){
  //Activate the MPU-6050
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x6B);                                                    //Send the requested starting register
  Wire.write(0x00);                                                    //Set the requested starting register
  Wire.endTransmission();                                              //End the transmission
  //Configure the accelerometer (+/-8g)
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x1C);                                                    //Send the requested starting register
  Wire.write(0x10);                                                    //Set the requested starting register
  Wire.endTransmission();                                              //End the transmission
  //Configure the gyro (500dps full scale)
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x1B);                                                    //Send the requested starting register
  Wire.write(0x08);                                                    //Set the requested starting register
  Wire.endTransmission();                                              //End the transmission
}

Sunday, June 3, 2018

Arduino DC current & voltage meter with LCD

Arduino DC voltage and current meter
Max. voltage= 50v
Max. current = 30A (There are 3 types of ACS712 sensor, 5A, 20A, 30A)

Parts list:
Arduino board
LCD 16x2
Current sensor ACS712 (There are 3 types of ACS712 sensor, 5A, 20A, 30A)
Connecting wire
Potentiometer 10K
Resistor 10K
Resistor 100K
Resistor 220 ohm
Breadboard

Wiring:

Arduino DC current voltage meter with LCD


Video: 
Please subscribe to my YouTube channel here: 
https://www.youtube.com/c/EngMousaalkaabi?sub_confirmation=1




Code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

//Measuring Current Using ACS712 (30A)

const int analogIn = 0; //Connect current sensor with A0 of Arduino
const int analogIn2 = 1; //Connect voltage sensor with A1 of Arduino
int mVperAmp = 66; // use 100 for 20A Module and 185 for 5A Module
int RawValue= 0;
int VolValue= 0;
int ACSoffset = 2500;
double Voltage = 0; //voltage measuring
double Voltage2 = 0; //voltage measuring
double Amps = 0;// Current measuring
double Volt = 0;// voltage measuring


void setup() {
  //baud rate
  Serial.begin(9600);//baud rate at which arduino communicates with Laptop/PC
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);  //LCD order
 
}

void loop() //method to run the source code repeatedly
{

 RawValue = analogRead(analogIn);//reading the value from the analog pin
 Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 VolValue = analogRead(analogIn2);//reading the value from the analog pin
 Voltage2 = (VolValue / 1023.0) * 5000; // Gets you mV
 Volt = ((Voltage2*11)/1000);
 lcd.clear();//clears the display of LCD

 Serial.print("\t Amps = "); // shows the voltage measured
 Serial.println(Amps,3);// the '3' after voltage allows you to display 3 digits after decimal point

 lcd.setCursor(0,0);
 lcd.print("I = ");
 lcd.setCursor(4,0);
 lcd.print(Amps+0.11); //add 0.11 to calibration and show us 0.00V when no load connected
 lcd.setCursor(10,0);
 lcd.print("A"); //unit for the current to be measured
 lcd.setCursor(0,1);
 lcd.print("V = ");
 lcd.setCursor(4,1);
 lcd.print(Volt);
 lcd.setCursor(9,1);
 lcd.print("V");
 delay(1000);
}

Thursday, May 31, 2018

Arduino frequency meter

In this project i used arduino for frequency counting.
The testing signal first should connect to a "schmitt trigger" to convert that to a square wave with constant amplitude about 5v, then the output of schmitt trigger connected to pin4 of arduino board to calculating the frequency.
If your signal is square wave with amplitude not more than 5v and without noise, so you don't need to use schmitt trigger and you can connect the signal directly to pin4 of arduino.

Arduino frequency meter


Frequency calculating process is very simple by measuring High time, Low time and period time (High time+Low time), then used frequency formula which is (1 second / period time)

Arduino frequency meter
I test this project with function generator and the frequency reading was accurate within frequency range of 31Hz to 100KHz


Parts list:
Arduino board 
LCD display 16X2
Breadboard 
Connecting wires
Schmitt trigger IC 74HC14
Potentiometer 10K
Resistor 220 ohm

In following video i don't use schmitt trigger because my input signal's amplitude lower than 5v and without noise.




CODE:

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int Htime;              //integer for storing high time
int Ltime;                //integer for storing low time
float Ttime;            // integer for storing total time of a cycle
float frequency;        //storing frequency

void setup()
{
    pinMode(4,INPUT);
    lcd.begin(16, 2);
}
void loop()
{
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Frequency = ");

    Htime=pulseIn(4,HIGH);      //read high time
    Ltime=pulseIn(4,LOW);        //read low time
   
    Ttime = Htime+Ltime;

    frequency=1000000/Ttime;    //getting frequency with Ttime is in Micro seconds
    lcd.setCursor(0,1);
    lcd.print(frequency);
    lcd.print(" Hz");
    delay(500);
}

Tuesday, May 29, 2018

Arduino 220v switch using fingerprint scanner FPM10A

This arduino project used fingerprint scanner module FPM10A for turns ON/OFF some AC or DC loads by fingerprint.
In this project we should using two different codes, the first code is for saving your fingerprint on the memory of the module, and the second code used for scanning the fingerprint of people in each time to compare that with saved fingerprint on the memory.

Parts list:
Arduino board (UNO or Nano)
LCD display 16X2
Fingerprint scanner FPM10A  
One channel relay module
Breadboard
Connecting wires
Potentiometer 1K
Resistor 220 ohm


Please subscribe to my YouTube channel here: 
https://www.youtube.com/c/EngMousaalkaabi?sub_confirmation=1


Follow this steps:
1-Install the library from here
2-Connect the module and the relay as shown in this picture

Arduino fingerprint FPM10A
3-Go to Example and upload the enroll code to arduino

Arduino 220v switch using fingerprint scanner FPM10A

4-Open the serial monitor and insert a number between 1 to 127 then put your finger and scan it several time to saved that on the module, i saved my thumb and index finger and saved them as number 10 and number 20 because i want to turn ON the load by thumb and turn OFF that by index finger

Arduino fingerprint FPM10A

5-The code below is the second code that you should used, but insert the number that you choose in prior step and put that in place of 10 and 20, then upload the code to the arduino board :

Arduino fingerprint FPM10A


#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(2, 3);


Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup() 
{
  Serial.begin(9600);
  Serial.println("fingertest");
  pinMode(5,OUTPUT);
  lcd.begin(16, 2); // lcd rows and columns

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    lcd.setCursor(0,0);
    lcd.print("NO Sensor find ");

    while (1);
  }
  Serial.println("Waiting for valid finger...");
  lcd.setCursor(0,0);
  lcd.print("Put your finger ");
}

void loop()                     // run over and over again
{
  getFingerprintIDez();
  delay(50);            //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (finger.fingerID == 10){
      digitalWrite(5,HIGH);
      lcd.setCursor(0,0);
      lcd.print("Load ON        ");
       lcd.setCursor(0,1);
       lcd.print("Put your finger");
       return finger.fingerID;

  }
 
  else if (finger.fingerID == 20){
     
       digitalWrite(5,LOW);
       lcd.setCursor(0,0);
       lcd.print("Load OFF        ");
       lcd.setCursor(0,1);
       lcd.print("Put your finger");
       return finger.fingerID;
  }
}

NOTE:
If arduino didn't find the fingerprint scanner, first make sure your wiring is correct,
if the problem still don't solved, press on the restart button on the arduino board several time and the problem will solved, as you can see in following picture my problem solved after pressing the restart button two times.

Did not find fingerprint scanner :(


Sunday, May 20, 2018

Arduino 220V AC Power meter using PZEM004T

Arduino 220V AC Power meter using PZEM004T
Library : https://github.com/olehs/PZEM004T

Part list:
Arduino board
LCD 16x2
PZEM004T module
Resistor 220 ohm
Potentiometer 10K


Arduino 220V AC Power meter using PZEM004T

Arduino 220V AC Power meter using PZEM004T

Arduino 220V AC Power meter using PZEM004T


Video: 




CODE:

#include <SoftwareSerial.h> // Arduino IDE <1.6.6

#include <PZEM004T.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

PZEM004T pzem(2,3);  // (RX,TX) connect to TX,RX of PZEM

IPAddress ip(192,168,1,1);


void setup() {

  Serial.begin(9600);

  pzem.setAddress(ip);
  lcd.begin(16, 2); // lcd rows and columns

  
}


void loop() {
 


  float v = pzem.voltage(ip);

  if (v < 0.0) v = 0.0;

  Serial.print(v);Serial.print("V; ");
  lcd.setCursor(0,0);
  lcd.print("V= ");
  lcd.setCursor(2,0);
  lcd.print(v);


  float i = pzem.current(ip);

  if (i < 0.0) i = 0.0;

  Serial.print(i);Serial.print("A; ");

  lcd.setCursor(9,0);
  lcd.print("A= ");
  lcd.setCursor(11,0);
  lcd.print(i);




  float p = pzem.power(ip);

  if (p < 0.0) p = 0.0;


  Serial.print(p);Serial.print("W; ");
  lcd.setCursor(9,1);
  lcd.print("W= ");
  lcd.setCursor(11,1);
  lcd.print(p);




  float e = pzem.energy(ip);

  Serial.print("PF= ");Serial.print((p)/(v*i));

  lcd.setCursor(0,1);
  lcd.print("PF=");
  lcd.setCursor(3,1);
  lcd.print((p)/(v*i));

 
  Serial.println();

  delay(100);
}
 

Thursday, May 17, 2018

High voltage probe for multimeter

High voltage probe for multimeter

High voltage probe for multimeter


High voltage probe for multimeter