: I have 2 sensors
Sharp optical dust sensor and gy-906 contactless temperature sensor.
I wrote their programs in 1 file and when I use the serial monitor, the values do not show up until I disconnect the analog read pin A5 which I used for the dust sensor.
The temperature sensor is connected to SCL,SDA, 5v and ground.
The circuit for the dust sensor is as shown
I tried to to test each one of them Individually and they work just fine.
The program for both sensors in 1 file :
//gy-906
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
//Dust sensor
int measurePin = A5;
int ledPower = 12;
unsigned int samplingTime = 280;
unsigned int deltaTime = 40;
unsigned int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
//gy-906
Serial.begin(9600);
Serial.println("Adafruit MLX90614 test");
mlx.begin();
//Dust sensor
pinMode(ledPower,OUTPUT);
}
void loop(){
//gy-906
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
Serial.println();
delay(500);
//optical dust sensor
digitalWrite(ledPower,LOW);
delayMicroseconds(samplingTime);
voMeasured = analogRead(measurePin);
delayMicroseconds(deltaTime);
digitalWrite(ledPower,HIGH);
delayMicroseconds(sleepTime);
calcVoltage = voMeasured*(5.0/1024);
dustDensity = 0.17*calcVoltage-0.1;
if ( dustDensity < 0)
{
dustDensity = 0.00;
}
Serial.println("Raw Signal Value (0-1023):");
Serial.println(voMeasured);
Serial.println("Voltage:");
Serial.println(calcVoltage);
Serial.println("Dust Density:");
Serial.println(dustDensity);
delay(500);
}

