Connecting multiple sensors to arduino

Hello

I need help!

I am monitoring temp, humidity, N02 and CO2 via sensors. Each sensor individually gives perfect results, but when I connect them all, the results are not correct.

I’m assuming that the voltage across each sensor decreases. Does the voltage across the output pin and ground also decrease OR does this stay the same as when the sensor was on its own?

Also, can I create a modifying factor in my code to get perfect results for when all 4 sensors are connected?

Code:

// Humidity sensor (HIH 4030)
const float Hm = 32.65; //gradient of graph in data sheet
const float Hc = -25.3; //y-intercept value from the graph

//NO2 sensor (MiCs 2714)

const float R0 = 56252.2;



int Tinput = A2;
int Hinput = A3;
int Ninput = A1;  
int Cinput = A4;
void setup()
{
Serial.begin(9600);
}
void loop()
{
float T0 = (analogRead(Tinput));
delay(50);
float H0 = (analogRead(Hinput));
delay(50);
float N0 = (analogRead(Ninput));
delay(50);
float C0 = (analogRead(Cinput));
delay(50);
float T1 = (analogRead(Tinput));
delay(50);
float H1 = (analogRead(Hinput));
delay(50);
float N1 = (analogRead(Ninput));
delay(50);
float C1 = (analogRead(Cinput));
delay(50);
float T2 = (analogRead(Tinput));
delay(50);
float H2 = (analogRead(Hinput));
delay(50);
float N2 = (analogRead(Ninput));
delay(50);
float C2 = (analogRead(Cinput));
delay(50);
float T3 = (analogRead(Tinput));
delay(50);
float H3 = (analogRead(Hinput));
delay(50);
float N3 = (analogRead(Ninput));
delay(50);
float C3 = (analogRead(Cinput));
delay(50);
float T4 = (analogRead(Tinput));
delay(50);
float H4 = (analogRead(Hinput));
delay(50);
float N4 = (analogRead(Ninput));
delay(50);
float C4 = (analogRead(Cinput));
delay(50);
float Tavg = ((T0+T1+T2+T3+T4)/5);
delay(50);
float Tread = (((Tavg*5.0)/1023)-0.53375)/(9.33/1000); 
delay(50);
float Havg = ((H0+H1+H2+H3+H4)/5);
delay(50);
float Hread = ((Hm*5000*Havg)/1023000)+Hc;
delay(50);
float Navg = ((N0+N1+N2+N3+N4)/5);
delay(50);
float Nread = (170687550/(R0*Navg))-(166850/R0)-18.22;
delay(50);
float Cavg = (C0+C1+C2+C3+C4)/5;
delay(50);
float Cread = (4.0*Cavg*2000)/1023;
if (Nread < 0) {
  Nread = 0;
}

delay(50);
//
Serial.print(Tread);
Serial.print("deg C, ");
Serial.print(Hread);
Serial.print(" RH %, ");
Serial.print(Nread);
Serial.print(" ppb, ");
Serial.print(Cread);
Serial.println(" ppm");


delay(960);
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Can you also post wiring diagram and details of the power supply you are using? Maybe the power supply cant power all the sensors at once?

A couple of things:

  1. Why are you declaring new variables in you void loop? Correct me if I am wrong but shouldn’t the deceleration of variables be done not in the loop so it only happens once.
  2. I might have missed something but why delay(960);? why not delay(1000);?
  3. Just to be lazy but with your temperature calculation you divide by 5 then times by 5. I see why you are doing it but with this you know what will happen and there are no rules so why do unnecessary calculations? You can just write:
float Tavg = ((T0+T1+T2+T3+T4));
delay(50);
float Tread = ((Tavg/1023)-0.53375)/(9.33/1000);