Hi guys,
I have a serial data string of analogue voltage in which writes every 1 second viewable in terminal, I would also like to write this same drink to the SD card once every 5 mins if possible but have had no luck figuring out how to do it.
void setup() {
Serial.begin(9600);
void loop() {
// read the voltage input on analog pins A0 and A4 through potential divider:
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);
int sensorValue4 = analogRead(A3);
int sensorValue5 = analogRead(A4);
// Convert the analog readings (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltageA0 = sensorValue1 * (5.0 / 1023.0);
float voltageA1 = sensorValue2 * (5.0 / 1023.0);
float voltageA2 = sensorValue3 * (5.0 / 1023.0);
float voltageA3 = sensorValue4 * (5.0 / 1023.0);
float voltageA4 = sensorValue5 * (5.0 / 1023.0);
// print out the value you read. Be aware that println adds a carriage return:
Serial.print("HEHSxxxxxxxx");
Serial.print(",");
Serial.print("S:0001");
Serial.print(",");
Serial.print("A0 12V");
Serial.print(",");
Serial.print(voltageA0 * 4.03); //12V line including true voltage multiplier:
Serial.print(",");
Serial.print("A1 5.5V");
Serial.print(",");
Serial.print(voltageA1 * 4.03); //5.5V line including true voltage multiplier:
Serial.print(",");
Serial.print("A2 8.0V");
Serial.print(",");
Serial.print(voltageA2 * 4.03); //8.0V line including true voltage multiplier:
Serial.print(",");
Serial.print("A3");
Serial.print(",");
Serial.print(voltageA3 * 10.096); //30V 30k - 3.3k PD input A3 line including true voltage multiplier:
Serial.print(",");
Serial.print("A4");
Serial.print(",");
Serial.print(voltageA4 * 4.03); //SPARE LINE A4 including true voltage multiplier:
Serial.print(",");
Serial.print("RED-LED");
Serial.print(",");
Serial.print("ORA-LED");
Serial.print(",");
Serial.print("BLU-LED");
Serial.print(",");
Serial.println("Err-Code");
// sampling rate if you are reading of a monitor:
delay(1000);
}
It outputs a string like this in serial
HEHSxxxxxxxx,S:0001,A0 12V,12.00,A1 5.5V,5.50,A2 8.0V,8.00,A3,30.00,A4,5.00,RED-LED,ORA-LED,BLU-LED,Err-Code
The other led status codes and err-Code will be added in later.