int sensor_input = A0; // Analog input of the Arduino
int relay_pin = 12; // any digital pin will do
int sensor_data;
int sensor_addition;
int sensor_data_avg;
int number_of_sample = 10;
unsigned long reading_time = 2000;
int threshold = 154;
int scaleval;
void setup()
{
Serial.begin(9600);
pinMode(relay_pin, OUTPUT);
digitalWrite(relay_pin, LOW);
}
void loop()
{
sensor_addition = 0;
for (int x=0;x<number_of_sample;x++)
{
sensor_data = analogRead(sensor_input);
sensor_addition = sensor_addition + sensor_data;
delay(reading_time);
}
sensor_data_avg = sensor_addition / number_of_sample;
Serial.print("Rawvalue from Analog input =");
Serial.print(sensor_data_avg);
// For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675
scaleval = map(sensor_data_avg, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(scaleval);
if (sensor_data_avg > threshold)
{
digitalWrite(relay_pin, HIGH);
}
else
{
digitalWrite(relay_pin, LOW);
}
}
Is that code suitable for
Or,
That code is suitable -
int analogPin = A3;
int Rawval ; // variable to store the value read
int Scaleval ;
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
// For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(Scaleval);
}
Control and regulation used in the same sentence seems to be contradiction. Do you want to control or do you want to regulate? Either will need a sensor to measure pressure or flow.
The video shows an Arduino turning on a CO2 valve when the CO2 sensor detects less than 5% CO2 concentration. Is that what you want to do? Are you having trouble doing that? Have you purchased any of the components?
If you have seen it carefully. You might have seen that The CO2 Sensor is different. Do need full for my CO2 sensor as an alternative of video demonstrated CO2 sensor
Do I have a code for relay operation? Using this calibrated data from the Analogous sensor
int analogPin = A3;
int Rawval ; // variable to store the value read
int Scaleval ;
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
// For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(Scaleval);
}
int analogPin = A3;
int Rawval ; // variable to store the value read
int Scaleval ;
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
// For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(Scaleval);
}
Do I have a code for relay operation for CO2 regulation?
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
@anon45799003,
I have stopped you from posting for 2 days because of your repeated pointless flags to the moderators despite being warned about doing this.