Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By pomelo
#40074
LATER UPDATE:

Found my notes abut this sensor:

- worked OK only with 5V, didn't try that time to use it with 3.3V because the designed system was 5V one.
- min Vout is about 0.7V
- max Vout about 3.7V -> max dust level =0.53mg/m3
- be sure you properly identified the pinout, in my case, don't know how it's yours,with socket on the left side (1 - > 6)
- be sure that you used the 150 ohm resistor for Vled (from what you say looks more like the LED is dead already)
- you need also a 220uF cap as in datasheet
- be sure that your Pulse-driven wave form is giving you tha right ratio for sampling/sleep time

As you said you have many, don't think all can be defective. Used more than 500 of them, never found one DOA.

I hope it helps. Good luck!
[/quote]

Thanks for a brief reply.

I hooked it up to ESP (NODE MCU V3) as follows:
ILED -> PIN 12
AOUT -> AD0
GND -> GND
VCC -> 3.3V

The analogRead(...) values are in range : 0 - 115 (when i max it out by putting a pencil into the hole), never seen 1024 in my analogRead in NODEMCU for this Sensor ( i have couple of these, all return the same MAX value: 115 ).

However when the same sensor is used on Arduino, it works like a charm.

Can't understand what might be the problem, is it the case with 3.3V supplied to Sensor, or the problem is that the AD0 is onlly 1V ?
User avatar
By pomelo
#40076
pomelo wrote:
LATER UPDATE:

Found my notes abut this sensor:

- worked OK only with 5V, didn't try that time to use it with 3.3V because the designed system was 5V one.
- min Vout is about 0.7V
- max Vout about 3.7V -> max dust level =0.53mg/m3
- be sure you properly identified the pinout, in my case, don't know how it's yours,with socket on the left side (1 - > 6)
- be sure that you used the 150 ohm resistor for Vled (from what you say looks more like the LED is dead already)
- you need also a 220uF cap as in datasheet
- be sure that your Pulse-driven wave form is giving you tha right ratio for sampling/sleep time

As you said you have many, don't think all can be defective. Used more than 500 of them, never found one DOA.

I hope it helps. Good luck!


Thanks for a brief reply.

I hooked it up to ESP (NODE MCU V3) as follows:
ILED -> PIN 12
AOUT -> AD0
GND -> GND
VCC -> 3.3V

The analogRead(...) values are in range : 0 - 115 (when i max it out by putting a pencil into the hole), never seen 1024 in my analogRead in NODEMCU for this Sensor ( i have couple of these, all return the same MAX value: 115 ).

However when the same sensor is used on Arduino, it works like a charm.

Can't understand what might be the problem, is it the case with 3.3V supplied to Sensor, or the problem is that the AD0 is onlly 1V ?[/quote]



Code: Select allvoid loop(void)
{
  /*
  get adcvalue
  */
  digitalWrite(iled, HIGH);
  delayMicroseconds(280);
  adcvalue = analogRead(vout);
  digitalWrite(iled, LOW);
   
  /*
  covert voltage (mv)
  */
  voltage = (SYS_VOLTAGE / 1024.0) * adcvalue * 11;
 
  /*
  voltage to density
  */
  if(voltage >= NO_DUST_VOLTAGE)
  {
    voltage -= NO_DUST_VOLTAGE;
   
    density = voltage * COV_RATIO;
  }
  else
    density = 0;
   
  /*
  display the result
  */
  Serial.print("The current dust concentration is: ");
  Serial.print(density);
  Serial.print(" ug/m3 ADC: " + String(adcvalue)+"\n"); 
 
  delay(1000);
}


Am i correctly displaying the adcvalue ?
User avatar
By trackerj
#40085 1. As I said, don't know if this sensor is working at 3.3V!
2. Your code is also wrong

you need :
digitalWrite(ledPower,LOW); // power on the ILED - LOW not HIGH because ... read datasheet, PNP, etc etc

try this one:

Code: Select allint measurePin = 0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2;   //Connect 3 led driver pins of dust sensor to Arduino D2
 
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
 
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
 
void setup(){
  Serial.begin(9600);
  pinMode(ledPower,OUTPUT);
}
 
void loop(){
  digitalWrite(ledPower,LOW); // power on the LED
  delayMicroseconds(samplingTime);
 
  voMeasured = analogRead(measurePin); // read the dust value
 
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
 
  // 0 - 5V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (5.0 / 1024.0);
 
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 0.1;
 
  Serial.print("Raw Signal Value (0-1023): ");
  Serial.print(voMeasured);
 
  Serial.print(" - Voltage: ");
  Serial.print(calcVoltage);
 
  Serial.print(" - Dust Density: ");
  Serial.println(dustDensity); // unit: mg/m3
 
  delay(1000);
}