two analogue sensors?

hi all,

I have been trying to get the below code working with an analogue sensor connected to both A0 and A2 with no luck, I have tried various bits of code but nothing seems to allow them to read separately, could anyone help with this?

thank you in advance

  #include "DHT.h"
  #include <sd.h>


  File myFile;
  int pinCS = 10;                                       
                                                        
                                                        
 

  const int RED_PIN = 7;                                
  const int BLUE_PIN = 8;                                .      
  const int GREEN_PIN = 9;                              
  
  int DISPLAY_TIME = 10;  // In milliseconds
  int temt6000Pin = 0;
  int airquality = 2;


  #define DHTPIN 2                                      

                                                       
                                                      
  #define DHTTYPE DHT22                                
                                                      
  DHT dht(DHTPIN, DHTTYPE);



  void setup() {
 


  pinMode(RED_PIN, OUTPUT);                         
  pinMode(GREEN_PIN, OUTPUT);                       
  pinMode(BLUE_PIN, OUTPUT);                        
  
  Serial.begin(9600);                               
  
  pinMode(pinCS, OUTPUT);                           
                                                    
  if (SD.begin())
   {
    Serial.println("SD card is ready to use.");     
    
    digitalWrite(BLUE_PIN, HIGH);                   
    delay(500);                                     
    digitalWrite(BLUE_PIN, LOW);                    
    delay(500);                                     
    digitalWrite(BLUE_PIN, HIGH);                   
    delay(500);                                     
    digitalWrite(BLUE_PIN, LOW);                    
    delay(500);                                     
    } else

   {
   Serial.println("SD card initialization failed");  
    
   digitalWrite(GREEN_PIN, HIGH);                    
   delay(500);                                       
   digitalWrite(GREEN_PIN, LOW);                     
   delay(500);                                      
   digitalWrite(GREEN_PIN, HIGH);                    
   delay(500);                                      
   digitalWrite(GREEN_PIN, LOW);                     
   delay(500);                                       
    
    
   return;
  } 
  dht.begin();
   
  
  }



                                                      
  void loop() {

  delay(3000);                                    


  int value = analogRead(temt6000Pin);
  Serial.print("Light is: ");                       
  Serial.println(value);                            


  int sensorValue = analogRead(A0);
  Serial.print("Air Quality = ");                   
  Serial.print(sensorValue);                        
  Serial.println(" PPM ");                          
                                                  
                                                   
  float h = dht.readHumidity();
                                                    
  float f = dht.readTemperature();                  
  
                                                    
  if (isnan(h)||isnan(f)) {
  return;
  }
                                                    
  myFile = SD.open("Logger.txt", FILE_WRITE);
                                                    
  if (myFile) {

  Serial.print("Temperature: ");                            
  Serial.print(f);                                             
  Serial.println(" *C ");                                                  
  
  Serial.print("humidity: ");                                            
  Serial.print(h);                                                          
  Serial.println(" % ");                                                    
      

  myFile.print("Light level = ");                   
  myFile.println(value);                            
                                                     
  myFile.print("Air Quality = ");                   
  myFile.print(sensorValue);                        
  myFile.println(" PPM ");                          
  
  myFile.print("Temperature = ");                   
  myFile.print(f);                                  
  myFile.println(" *C ");                           
 
  myFile.print("humidity = ");                      
  myFile.print(h);                                 
  myFile.println(" % ");                            
  
  myFile.println("DONE");                           
  myFile.println();                                
  myFile.close();                                   
 
  Serial.println("Done.");                          

  
  digitalWrite(RED_PIN, HIGH);                      
  delay(1000);                                      
  digitalWrite(RED_PIN, LOW);                       
  delay(1000);                                      
   
    
  }                                                 
  else {
    Serial.println("error opening Logger.txt");     
  }
  }

Should "#define DHTPIN 2" not have been ""#define DHTPIN A2"?

I have been using the dht11 connected to D2

This makes no sense, since you are apparently reading the same pin..

int value = analogRead(temt6000Pin);
...
int sensorValue = analogRead(A0);

thanks you for pointing that out, I have managed to make the pin correction and the logger now works :smiley: :smiley: