user38769: I try to make a weather station, but I don't understand why it doesn't work. I had tried to read a lot of the sensors but I doesn't find my errors.

The code:
  
 #include "DHT.h"
 #include "SFE_BMP180.h"
 #include "Wire.h"
 #include "MQ135.h"
 #include "SPI.h"
 #include "Adafruit_GFX.h"
 #include "Adafruit_ILI9341.h"

#define DHTPIN 2
 #define DHTTYPE DHT11
 DHT dht(DHTPIN, DHTTYPE);

SFE_BMP180 bmp180;
 double PresionNivelMar=1013.25;

int UVOUT = A3;
 int REF_3V3 = A1;

#define PIN_MQ135 A0
 MQ135 mq135_sensor = MQ135(PIN_MQ135);

#define TFT_DC 9
 #define TFT_CS 10
 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

void setup() {
  Serial.begin(9600);
  dht.begin();
  if (bmp180.begin())
          Serial.println("BMP180 iniciado correctamenten");
        else {
          Serial.println("Error al iniciar el BMP180");
        }
  pinMode(UVOUT, INPUT);
  pinMode(REF_3V3, INPUT);

tft.begin();
  tft.setRotation(0);
  tft.fillScreen(ILI9341_BLACK); 
  tft.setTextColor(ILI9341_DARKGREEN);
  tft.setTextSize(2);
  tft.setCursor(70,20);
  tft.print("S.E.M.S.");
  tft.setTextSize(1);
  tft.setTextColor(ILI9341_WHITE);
  tft.setCursor(20,310);
  tft.print("Colegio Panamericana");
  tft.setTextSize(1.5);
}

void loop() {
  char a;
  double T,P,A;
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float rzero = mq135_sensor.getRZero();
  float correctedRZero = mq135_sensor.getCorrectedRZero(t, h);
  float resistance = mq135_sensor.getResistance();
  float correctedresistence = mq135_sensor.getCorrectedResistance(t, h);
  float ppm = mq135_sensor.getPPM();
  float correctedPPM = mq135_sensor.getCorrectedPPM(t, h);

Serial.println();
  Serial.print("Temperatura: ");
  Serial.print(t);
  Serial.print(" °C ");
  Serial.println();
  Serial.print("Humedad: ");
  Serial.print(h);
  Serial.print(" %RH");
  Serial.println();

a = bmp180.startTemperature();
  if (a != 0) {
    delay(a);
    a = bmp180.getTemperature(T);
     if (a != 0) {
         a = bmp180.startPressure(3);
        if (a != 0) {
                  delay(a);
                        a = bmp180.getPressure(P,T);
                 if (a != 0) {
                  A= bmp180.altitude(P,PresionNivelMar);
                 }
              }
           }
       }

Serial.print("Temperatura: ");
  Serial.print(T);
  Serial.print(" °C , ");
  Serial.println();
  Serial.print("Presion: ");
  Serial.print(P);
  Serial.print(" mb"); 
  Serial.println();
  Serial.print("Altitud: ");
  Serial.print(A);
  Serial.print(" m s.n.m.");
  Serial.println();

int uvLevel = averageAnalogRead(UVOUT);
  int refLevel = averageAnalogRead(REF_3V3);
  float outputVoltage = 3.3 / refLevel * uvLevel;
  float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0);

Serial.print("Output: ");
  Serial.print(refLevel);
  Serial.print(" v");
  Serial.println();
  Serial.print("ML8511 output: ");
  Serial.print(uvLevel);
  Serial.print(" v");
  Serial.println();
  Serial.print("ML8511 voltage: ");
  Serial.print(outputVoltage);
  Serial.print(" v");
  Serial.println();
  Serial.print("UV Intensity (mW/cm^2): ");
  Serial.print(uvIntensity);
  Serial.println();
  Serial.print("MQ135 RZero: ");
  Serial.print(rzero);
  Serial.println();
  Serial.print("Corregido RZero: ");
  Serial.print(correctedRZero);
  Serial.println();
  Serial.print("Resistance: ");
  Serial.print(resistance);
  Serial.println();
  Serial.print("Corregido Resistencia: ");
  Serial.print(correctedresistence);
  Serial.println();
  Serial.print("PPM: ");
  Serial.print(ppm);
  Serial.println();
  Serial.print("Corregido PPM: ");
  Serial.print(correctedPPM);
  Serial.println("ppm");
  Serial.println();

escribir(14,40,1,"ILI9341_GREEN","Temperatura");
  escribir(14,60,0.6,"ILI9341_RED",String(t));
  escribir(14,60,0.6,"ILI9341_RED","°C");
  escribir(14,80,1,"ILI9341_GREEN","Humedad");
  escribir(14,100,0.6,"ILI9341_BLUE",String(h));
  escribir(14,100,0.6,"ILI9341_BLUE","%RH");
  escribir(14,120,1,"ILI9341_GREEN","Presión");
  escribir(14,140,0.6,"ILI9341_LIGHTGREY",String(P));
  escribir(14,140,0.6,"ILI9341_LIGHTGREY","psi");
  escribir(14,160,1,"ILI9341_GREEN","Calidad del Aire");
  escribir(14,180,0.6,"ILI9341_CYAN",String(correctedPPM));
  escribir(14,180,0.6,"ILI9341_CYAN","ppm");
  escribir(14,200,1,"ILI9341_GREEN","Radiación UV");
  escribir(14,220,0.6,"ILI9341_MAGENTA",String(uvIntensity));
  escribir(14,220,0.6,"ILI9341_MAGENTA","mW/cm^2");
}

int averageAnalogRead(int pinToRead) {
  byte numberOfReadings = 8;
  unsigned int runningValue = 0; 
  for(int x = 0 ; x < numberOfReadings ; x++)
          runningValue += analogRead(pinToRead);
          runningValue /= numberOfReadings;
    return(runningValue);
}

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

void escribir(int X,int Y, int tam, short color, String mensaje){
  tft.setCursor(X,Y);
  tft.setTextSize(tam);
  tft.setTextColor(color);
  tft.print(mensaje);
}
Also I adds a little screen.
I make this:

Sorry for the size, the original image was too heavy to upload, in addition to the disorder.
I bought on: naylampmechatronics.com . 
And I used his information.
And I read a bit of adafruit.com

user1576: The method for troubleshooting is:

Disconnect everything.
Add one sensor.
Verify if the sensor works.
If it works repeat step 2 for next sensor.
If it doesn't work, why? is it the connections correct?


38769: <p>I try to make a weather station, but I don't understand why it doesn't work. I had tried to read a lot of the sensors but I doesn't find my errors.</p>

<p><a href="https://i.stack.imgur.com/GOeUo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GOeUo.png" alt="enter image description here"></a></p>

<p>The code:
  <pre><code>
 #include "DHT.h"
 #include "SFE_BMP180.h"
 #include "Wire.h"
 #include "MQ135.h"
 #include "SPI.h"
 #include "Adafruit_GFX.h"
 #include "Adafruit_ILI9341.h"</p>

<p>#define DHTPIN 2
 #define DHTTYPE DHT11
 DHT dht(DHTPIN, DHTTYPE);</p>

<p>SFE_BMP180 bmp180;
 double PresionNivelMar=1013.25;</p>

<p>int UVOUT = A3;
 int REF_3V3 = A1;</p>

<p>#define PIN_MQ135 A0
 MQ135 mq135_sensor = MQ135(PIN_MQ135);</p>

<p>#define TFT_DC 9
 #define TFT_CS 10
 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);</p>

<p>void setup() {
  Serial.begin(9600);
  dht.begin();
  if (bmp180.begin())
          Serial.println("BMP180 iniciado correctamenten");
        else {
          Serial.println("Error al iniciar el BMP180");
        }
  pinMode(UVOUT, INPUT);
  pinMode(REF_3V3, INPUT);</p>

<p>tft.begin();
  tft.setRotation(0);
  tft.fillScreen(ILI9341_BLACK); 
  tft.setTextColor(ILI9341_DARKGREEN);
  tft.setTextSize(2);
  tft.setCursor(70,20);
  tft.print("S.E.M.S.");
  tft.setTextSize(1);
  tft.setTextColor(ILI9341_WHITE);
  tft.setCursor(20,310);
  tft.print("Colegio Panamericana");
  tft.setTextSize(1.5);
}</p>

<p>void loop() {
  char a;
  double T,P,A;
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float rzero = mq135_sensor.getRZero();
  float correctedRZero = mq135_sensor.getCorrectedRZero(t, h);
  float resistance = mq135_sensor.getResistance();
  float correctedresistence = mq135_sensor.getCorrectedResistance(t, h);
  float ppm = mq135_sensor.getPPM();
  float correctedPPM = mq135_sensor.getCorrectedPPM(t, h);</p>

<p>Serial.println();
  Serial.print("Temperatura: ");
  Serial.print(t);
  Serial.print(" °C ");
  Serial.println();
  Serial.print("Humedad: ");
  Serial.print(h);
  Serial.print(" %RH");
  Serial.println();</p>

<p>a = bmp180.startTemperature();
  if (a != 0) {<br>
    delay(a);
    a = bmp180.getTemperature(T);
     if (a != 0) {
         a = bmp180.startPressure(3);
        if (a != 0) {<br>
                  delay(a);<br>
                        a = bmp180.getPressure(P,T);
                 if (a != 0) {<br>
                  A= bmp180.altitude(P,PresionNivelMar);
                 }<br>
              }<br>
           }<br>
       }</p>

<p>Serial.print("Temperatura: ");
  Serial.print(T);
  Serial.print(" °C , ");
  Serial.println();
  Serial.print("Presion: ");
  Serial.print(P);
  Serial.print(" mb"); 
  Serial.println();
  Serial.print("Altitud: ");
  Serial.print(A);
  Serial.print(" m s.n.m.");<br>
  Serial.println();</p>

<p>int uvLevel = averageAnalogRead(UVOUT);
  int refLevel = averageAnalogRead(REF_3V3);
  float outputVoltage = 3.3 / refLevel * uvLevel;
  float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0);</p>

<p>Serial.print("Output: ");
  Serial.print(refLevel);
  Serial.print(" v");
  Serial.println();
  Serial.print("ML8511 output: ");
  Serial.print(uvLevel);
  Serial.print(" v");
  Serial.println();
  Serial.print("ML8511 voltage: ");
  Serial.print(outputVoltage);
  Serial.print(" v");
  Serial.println();
  Serial.print("UV Intensity (mW/cm^2): ");
  Serial.print(uvIntensity);
  Serial.println();
  Serial.print("MQ135 RZero: ");
  Serial.print(rzero);
  Serial.println();
  Serial.print("Corregido RZero: ");
  Serial.print(correctedRZero);
  Serial.println();
  Serial.print("Resistance: ");
  Serial.print(resistance);
  Serial.println();
  Serial.print("Corregido Resistencia: ");
  Serial.print(correctedresistence);
  Serial.println();
  Serial.print("PPM: ");
  Serial.print(ppm);
  Serial.println();
  Serial.print("Corregido PPM: ");
  Serial.print(correctedPPM);
  Serial.println("ppm");
  Serial.println();</p>

<p>escribir(14,40,1,"ILI9341_GREEN","Temperatura");
  escribir(14,60,0.6,"ILI9341_RED",String(t));
  escribir(14,60,0.6,"ILI9341_RED","°C");
  escribir(14,80,1,"ILI9341_GREEN","Humedad");
  escribir(14,100,0.6,"ILI9341_BLUE",String(h));
  escribir(14,100,0.6,"ILI9341_BLUE","%RH");
  escribir(14,120,1,"ILI9341_GREEN","Presión");
  escribir(14,140,0.6,"ILI9341_LIGHTGREY",String(P));
  escribir(14,140,0.6,"ILI9341_LIGHTGREY","psi");
  escribir(14,160,1,"ILI9341_GREEN","Calidad del Aire");
  escribir(14,180,0.6,"ILI9341_CYAN",String(correctedPPM));
  escribir(14,180,0.6,"ILI9341_CYAN","ppm");
  escribir(14,200,1,"ILI9341_GREEN","Radiación UV");
  escribir(14,220,0.6,"ILI9341_MAGENTA",String(uvIntensity));
  escribir(14,220,0.6,"ILI9341_MAGENTA","mW/cm^2");
}</p>

<p>int averageAnalogRead(int pinToRead) {
  byte numberOfReadings = 8;
  unsigned int runningValue = 0; 
  for(int x = 0 ; x &lt; numberOfReadings ; x++)
          runningValue += analogRead(pinToRead);
          runningValue /= numberOfReadings;
    return(runningValue);<br>
}</p>

<p>float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}</p>

<p>void escribir(int X,int Y, int tam, short color, String mensaje){
  tft.setCursor(X,Y);
  tft.setTextSize(tam);
  tft.setTextColor(color);
  tft.print(mensaje);
}</pre></code></p>

<p>Also I adds a little screen.</p>

<p>I make this:</p>

<p><a href="https://i.stack.imgur.com/GogiK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GogiK.jpg" alt="enter image description here"></a></p>

<p>Sorry for the size, the original image was too heavy to upload, in addition to the disorder.</p>

<p>I bought on: naylampmechatronics.com . 
And I used his information.
And I read a bit of adafruit.com</p>
 1576: <p>The method for troubleshooting is:</p>

<ol>
<li><p>Disconnect everything.</p></li>
<li><p>Add one sensor.</p></li>
<li><p>Verify if the sensor works.</p></li>
<li><p>If it works repeat step 2 for next sensor.</p></li>
<li><p>If it doesn't work, why? is it the connections correct?</p></li>
</ol>
