Components and supplies
Arduino UNO
current sensor module ACS712 30A
Relay (generic)
Project description
Code
arduino-shop-vac.ino
arduino
shop vac automation
1/* =========================================================== 2 3SHOP VAC AUTOMATION 4 5->> CONNECT RELAYS IN TO DIGITAL OUTPUT 02 + VCC + GROUND 6 RELAY INTERRUPTS SHOP VAC POWER CORD 7->> CONNECT ACS712 30A TO ANALOG INPUT A0 + VCC + GROUND 8 ACS712 MUST SENSE ON THE MAIN FUSE BOX 9==============================================================*/ 10const int analogIn = A0; 11int mVperAmp = 66; // use 185 for 5A, 100 for 20A Module and 66 for 30A Module 12int RawValue= 0; 13int ACSoffset = 2500; 14double Voltage = 0; 15double Amps = 0; 16 17const int pinRelay = 2; 18 19 20double Amps1 = 0; 21double Amps2 = 0; 22double Amps3 = 0; 23double Amps4 = 0; 24double Amps5 = 0; 25 26 27void setup(){ 28 Serial.begin(9600); 29 pinMode (pinRelay, OUTPUT); 30} 31 32void loop(){ 33 34 RawValue = analogRead(analogIn); 35 Voltage = (RawValue / 1024.0) * 5000; // Gets you mV 36 Amps1 = abs((Voltage - ACSoffset) / mVperAmp); 37 38 Amps5 = Amps4; // that's just for the timing to turn off, aproximately 20 sec. 39 Amps4 = Amps3; 40 Amps3 = Amps2; 41 Amps2 = Amps1; 42 Amps = max(Amps1, Amps2); 43 Amps = max(Amps, Amps3); 44 Amps = max(Amps, Amps4); 45 Amps = max(Amps, Amps5); 46 47 Serial.print("Raw Value = " ); // shows pre-scaled value 48 Serial.print(RawValue); 49 Serial.print("\ mV = "); // shows the voltage measured 50 Serial.print(Voltage,2); // the '2' after voltage allows you to display 3 digits after decimal point 51 Serial.print("\ Amps = "); // shows the voltage measured 52 Serial.print(Amps,2); // the '2' after voltage allows you to display 3 digits after decimal point 53 54 55 if ( Amps > 6.8 ) // change value here whit the value of the machine you want to use for ( for more than one, use the lower value) 56 { digitalWrite( pinRelay, HIGH); // over 6.8 Amp activates the relay 57 Serial.println(" High"); 58 delay (5000); // wait 5 seconds 59 } 60 61if ( Amps < 6.8 ) 62 {digitalWrite( pinRelay, LOW); // under 6.8 Amp the relay turns off 63 Serial.println(" Low"); 64 } 65 delay(500); 66} 67
arduino-shop-vac.ino
arduino
shop vac automation
1/* =========================================================== 2 3SHOP VAC AUTOMATION 4 5->> CONNECT RELAYS IN TO DIGITAL OUTPUT 02 + VCC + GROUND 6 RELAY INTERRUPTS SHOP VAC POWER CORD 7->> CONNECT ACS712 30A TO ANALOG INPUT A0 + VCC + GROUND 8 ACS712 MUST SENSE ON THE MAIN FUSE BOX 9==============================================================*/ 10const int analogIn = A0; 11int mVperAmp = 66; // use 185 for 5A, 100 for 20A Module and 66 for 30A Module 12int RawValue= 0; 13int ACSoffset = 2500; 14double Voltage = 0; 15double Amps = 0; 16 17const int pinRelay = 2; 18 19 20double Amps1 = 0; 21double Amps2 = 0; 22double Amps3 = 0; 23double Amps4 = 0; 24double Amps5 = 0; 25 26 27void setup(){ 28 Serial.begin(9600); 29 pinMode (pinRelay, OUTPUT); 30} 31 32void loop(){ 33 34 RawValue = analogRead(analogIn); 35 Voltage = (RawValue / 1024.0) * 5000; // Gets you mV 36 Amps1 = abs((Voltage - ACSoffset) / mVperAmp); 37 38 Amps5 = Amps4; // that's just for the timing to turn off, aproximately 20 sec. 39 Amps4 = Amps3; 40 Amps3 = Amps2; 41 Amps2 = Amps1; 42 Amps = max(Amps1, Amps2); 43 Amps = max(Amps, Amps3); 44 Amps = max(Amps, Amps4); 45 Amps = max(Amps, Amps5); 46 47 Serial.print("Raw Value = " ); // shows pre-scaled value 48 Serial.print(RawValue); 49 Serial.print("\ mV = "); // shows the voltage measured 50 Serial.print(Voltage,2); // the '2' after voltage allows you to display 3 digits after decimal point 51 Serial.print("\ Amps = "); // shows the voltage measured 52 Serial.print(Amps,2); // the '2' after voltage allows you to display 3 digits after decimal point 53 54 55 if ( Amps > 6.8 ) // change value here whit the value of the machine you want to use for ( for more than one, use the lower value) 56 { digitalWrite( pinRelay, HIGH); // over 6.8 Amp activates the relay 57 Serial.println(" High"); 58 delay (5000); // wait 5 seconds 59 } 60 61if ( Amps < 6.8 ) 62 {digitalWrite( pinRelay, LOW); // under 6.8 Amp the relay turns off 63 Serial.println(" Low"); 64 } 65 delay(500); 66} 67
Downloadable files
untitled
untitled
Comments
Only logged in users can leave comments
FranzVicenzi
0 Followers
•0 Projects
+2
Work attribution
Table of contents
Intro
2
0