Hello all,
I'm having trouble with my current sensor. I have acs712 30A current sensor. And after uploading the code the serial monitor & serial plotter only shows a no and doesn't change at all after turning on the power and the motor runs fine. I'm trying to measure switched reluctance motor phase current, but it doesn't seem as though the sensor is recognizing the motor current (~12Amps). I also have tried 2 other codes and the same type of thing happens where the serial plotter doesn't change values after turning on power. Im also using the ground, 5v, and A0 pins of an Arduino Uno.
/*
*
* Arduino Sketch for Allegro ACS712 Current Sensor
* this sensor can measure current at range of up to 30A
* It operates with 5V
* Please watch video instruction and explanation for this code.
*
* Written by Ahmad Shamshiri on Sunday Jun 17, 2018 at 22:06 at Ajax, Ontario, Canada
* for Robojax.com
* View the video instruction at https://youtu.be/DVp9k3xu9IQ
* This code has been downloaded from Robojax.com
*/
#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const float VCC = 5.0;// supply voltage is from 4.5 to 5.5V. Normally 5V.
const int model = 2; // enter the model number (see below)
float cutOffLimit = 1.01;// set the current which below that value, doesn't matter. Or set 0.5
/*
"ACS712ELCTR-05B-T",// for model use 0
"ACS712ELCTR-20A-T",// for model use 1
"ACS712ELCTR-30A-T"// for model use 2
sensitivity array is holding the sensitivy of the ACS712
current sensors. Do not change. All values are from page 5 of data sheet
*/
float sensitivity[] ={
0.185,// for ACS712ELCTR-05B-T
0.100,// for ACS712ELCTR-20A-T
0.066// for ACS712ELCTR-30A-T
};
const float QOV = 0.5 * VCC;// set quiescent Output voltage of 0.5V
float voltage;// internal variable for voltage
void setup() {
// put your setup code here, to run once:
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
//Robojax.com ACS712 Current Sensor
Serial.begin(9600);// initialize serial monitor
Serial.println("Robojax Tutorial");
Serial.println("ACS712 Current Sensor");
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
delay(3000);
digitalWrite(6, LOW);
digitalWrite(5,LOW);
delay(1000);
//Robojax.com ACS712 Current Sensor
float voltage_raw = (5.0 / 1023.0)* analogRead(VIN);// Read the voltage from sensor
voltage = voltage_raw - QOV + 0.012 ;// 0.000 is a value to make voltage zero when there is no current
float current = voltage / sensitivity[model];
if(abs(current) > cutOffLimit ){
Serial.print("V: ");
Serial.println(voltage,3);// print voltage with 3 decimal places
Serial.print("V, I: ");
Serial.println(current,2); // print the current with 2 decimal places
Serial.println("A");
}else{
Serial.println("No Current");
}
delay(500);
}