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

Moderator: igrr

User avatar
By pomelo
#40102
trackerj wrote: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:


Hi, thanks for your input into this.

Why do i go with LOW instead of HIGH to enabe the ILED ? Is this ESP specific?

I will try this code as soon as i get my new NODEMCU - i odered another 3 to test it out.

Nevertheless
here is what the spec says, they say that OPERATING VOLTAGE STARTS at 2.5 - ~5.5V, i suspect this means i can power the Dust sensor from 3.3V Port on ESP

Image
Image



Let me plug it into ARDUINO and see what MAX readAnalog value i can get if the Sensor is MAXEd out.
User avatar
By pomelo
#40104 Here are the results on ARDUINO:

Code (taken from waveshare0
Code: Select all/*********************************************************************************************************
*
* File                : DustSensor
* Hardware Environment:
* Build Environment   : Arduino
* Version             : V1.0.5-r2
* By                  : WaveShare
*
*                                  (c) Copyright 2005-2011, WaveShare
*                                       http://www.waveshare.net
*                                       http://www.waveshare.com   
*                                          All Rights Reserved
*
*********************************************************************************************************/
#define        COV_RATIO                       0.2            //ug/mmm / mv
#define        NO_DUST_VOLTAGE                 400            //mv
#define        SYS_VOLTAGE                     5000           


/*
I/O define
*/
const int iled = 12;                                            //drive the led of sensor
const int vout = A0;                                            //analog input

/*
variable
*/
float density, voltage;
int   adcvalue;


void setup(void)
{
  pinMode(iled, OUTPUT);
  digitalWrite(iled, LOW);                                     //iled default closed
 
  Serial.begin(9600);                                         //send and receive at 9600 baud
  Serial.print("*********************************** WaveShare ***********************************\n");
}

void 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);
}




Output:
The current dust concentration is: 586.02 ug/m3 ADC: 62
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 586.02 ug/m3 ADC: 62
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 586.02 ug/m3 ADC: 62
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63
The current dust concentration is: 596.76 ug/m3 ADC: 63



Still i see ADC is not 1024 ..
User avatar
By trackerj
#40113
pomelo wrote:
trackerj wrote: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:


Hi, thanks for your input into this.

Why do i go with LOW instead of HIGH to enabe the ILED ? Is this ESP specific?

I will try this code as soon as i get my new NODEMCU - i odered another 3 to test it out.

Nevertheless here is what the spec says, they say that OPERATING VOLTAGE STARTS at 2.5 - ~5.5V, i suspect this means i can power the Dust sensor from 3.3V Port on ESP

Let me plug it into ARDUINO and see what MAX readAnalog value i can get if the Sensor is MAXEd out.


I was just telling you how is working that sensor, it is active LOW, check datasheet, is not ESP specific, is Sensor specific. How is working (or not) your waveshare adapter board on top of the sensor I have no idea as never used such a board. I suppose it has some sort of DC boost converter to give the +5Vcc to the Sensor. Sensor itself is NOT working properly at 3.3V. And also as it looks from your software example also has some active hight circuit for the Sensor.

Why are you not trying to directly connect the sensor to the Arduino, with proper 5V and as in Datasheet?