I'm not sure if this is a power issue or if it's a programming issue.
The program works correctly when no load is applied to it.
(Well most of the program ;), the current is not displaying via the serial monitor but the delay times work for the right amount of time).
However, when I hook up my 8 solenoids to each relay and 8 ACS712 sensors,
the Toff delay time only works for 1 second. It's supposed to be off for 15 minutes.
Schematic and code are below:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
/****************************************************************************/
unsigned long TOn = 1800000; // Adjust delay time in milliseconds to turn relay on/off (60,000 ms = 1 minute)
unsigned long TOff = 900000;
/* Measuring DC Current Using ACS712 */
double mVperAmp = 185; // use 185 for 5A Module, 100 for 20A Module, and 66 for 30A Module
float ACSoffset = 2423.6;
double RawValue1 = 0;
double RawValue2 = 0;
double RawValue3 = 0;
double RawValue4 = 0;
double RawValue5 = 0;
double RawValue6 = 0;
double RawValue7 = 0;
double RawValue8 = 0;
double V1 = 0;
double V2 = 0;
double V3 = 0;
double V4 = 0;
double V5 = 0;
double V6 = 0;
double V7 = 0;
double V8 = 0;
double Amps1 = 0;
double Amps2 = 0;
double Amps3 = 0;
double Amps4 = 0;
double Amps5 = 0;
double Amps6 = 0;
double Amps7 = 0;
double Amps8 = 0;
const int S1 = A0; // Analog input pin that sensor is attached to
const int S2 = A1;
const int S3 = A2;
const int S4 = A3;
const int S5 = A4;
const int S6 = A5;
const int S7 = A6;
const int S8 = A7;
void setup () {
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.setCursor(0, 0); // set printing position on lcd screen, currently that is column 0, row 0)
Serial.begin(9600);
DDRA = B11111111; // set PORTA (digital 22-29) to outputs
int maxnumber = 2; // set cycle count
for (int count = 0; count < maxnumber;) //Counter will stop counting after certain amount of cycles
{
PORTA = B00000000;
delay(TOn); //delay between turning on each relay
PORTA = B11111111;
delay(TOff); //delay between turning off each relay
RawValue1 = analogRead(S1);
RawValue2 = analogRead(S2);
RawValue3 = analogRead(S3);
RawValue4 = analogRead(S4);
RawValue5 = analogRead(S5);
RawValue6 = analogRead(S6);
RawValue7 = analogRead(S7);
RawValue8 = analogRead(S8);
V1 = (RawValue1 / 1023.0) * 5000; // Gets you mV
V2 = (RawValue2 / 1023.0) * 5000;
V3 = (RawValue3 / 1023.0) * 5000;
V4 = (RawValue4 / 1023.0) * 5000;
V5 = (RawValue5 / 1023.0) * 5000;
V6 = (RawValue6 / 1023.0) * 5000;
V7 = (RawValue7 / 1023.0) * 5000;
V8 = (RawValue8 / 1023.0) * 5000;
Amps1 = ((V1 - ACSoffset) / mVperAmp);
Amps2 = ((V2 - ACSoffset) / mVperAmp);
Amps3 = ((V3 - ACSoffset) / mVperAmp);
Amps4 = ((V4 - ACSoffset) / mVperAmp);
Amps5 = ((V5 - ACSoffset) / mVperAmp);
Amps6 = ((V6 - ACSoffset) / mVperAmp);
Amps7 = ((V7 - ACSoffset) / mVperAmp);
Amps8 = ((V8 - ACSoffset) / mVperAmp);
Serial.print("Amps1 = "); // shows the voltage measured
Serial.println(Amps1, 3); // the '3' after voltage allows you to display 3 digits after decimal point
Serial.print("Amps2 = ");
Serial.println(Amps2, 3);
Serial.print("Amps3 = ");
Serial.println(Amps3, 3);
Serial.print("Amps4 = ");
Serial.println(Amps4, 3);
Serial.print("Amps5 = ");
Serial.println(Amps5, 3);
Serial.print("Amps6 = ");
Serial.println(Amps6, 3);
Serial.print("Amps7 = ");
Serial.println(Amps7, 3);
Serial.print("Amps8 = ");
Serial.println(Amps8, 3);
Serial.println("");
lcd.clear(); //clears lcd before incrementing to next number
count++;
lcd.print(count);
lcd.setCursor(0, 1);
lcd.println(TOn/60000);
lcd.print("minutes");
}
DDRA = B00000000;
}
void loop() {
}




