First project. UNO with a SEEED, four relay shield piggyback. A humidity sensor attached to A0. The sensor is powered by 24vac transformer and generates a 0-5vdc signal proportional to. common terminal of the CO2 sensor is landed at AREF. 1.25volt signal landed at AO. analogReference(EXTERNAL) declared on line before the analogRead.
Pin AO has 1.25 vdc but the CO2 point returns a value of 1023 and not 500 as expected. Tested same configuration on A1 and get same result.
const int V1 = 4;
const int V2 = 5;
const int V3 = 6;
const int V4 = 7;
const int V5 = 8;
const int V6 = 9;
const int pump = 10;
const int fan = 11;
const int LED13 = 13;
int CO2_in = A0; //<<<<<<<<<<<<<<
int RH_in = A1; //<<<<<<<<<<<<<<
const int Sw1 = 1;
int i = 0;
long Ltime = 0;
long A = 0;
int tempvalue1 = 0; //<<<<<<<<<<<<
int CO2 = 0; //<<<<<<<<<<<
int tempvalue2 = 0; //<<<<<<<<<<<
int RH = 0; //<<<<<<<<<<<
void setup()
{pinMode(V1, OUTPUT);
pinMode(V2, OUTPUT);
pinMode(V3, OUTPUT);
pinMode(V4, OUTPUT);
pinMode(V5, OUTPUT);
pinMode(V6, OUTPUT);
pinMode(pump, OUTPUT);
pinMode(fan,OUTPUT);
pinMode(LED13, OUTPUT);
pinMode(Sw1, INPUT);
Serial.begin(9600);}
void loop(){
if (i == 0)
{(i = 1);
Ltime = millis();
digitalWrite(V1,LOW);
digitalWrite(V2,LOW);
digitalWrite(V3,LOW);
digitalWrite(V4,LOW);
digitalWrite(V5,LOW);
digitalWrite(V6,LOW);
digitalWrite(pump,LOW);
digitalWrite(fan,LOW);}
{analogReference(EXTERNAL); //<<<<<<<<<<<<<<<<<
tempvalue1 = analogRead(CO2_in); //<<<<<<<<<<<<<<<<<<
CO2 = (tempvalue1 * 1.95503);
tempvalue2 = analogRead(RH_in);
RH = (tempvalue2 * 0.097751);}