Reply to topic  [ 9 posts ] 
GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS0024) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 669
Post GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS0024)
Image




The GP2Y1010AU/GP2Y1014AU (HCSENS0024) from Sharp is an optical air quality sensor, designed to sense dust particles. An infrared emitting diode (IRED) and a phototransistor are diagonally arranged into this device, which allows it to detect the reflected light of dust in air. It is very effective in detecting very fine particles like the cigarette smoke.

The sensor has a very low consumption current of only 20mA (MAX) (11mA Typical) whilst the sensor is taking a measurement. The output of the sensor is an analogue voltage proportional to the measured dust density, with a sensitivity of 0.5V/0.1mg/m3.

This sensor comes complete with a connection cable (connector already attached), a 150 Ohm current limiting resistor for use with the IR LED, and a 220uF 16V capacitor. Please see diagram for how to use these components.

Image



Overall Dimensions: 46mm x 33mm x 18mm
Product code: HCSENS0024


Please note: This sensor has been calibrated by the factory. Adjusting the sensitivity potentiometer situated on the back of the module will cause the module to give inaccurate readings.

A suitable capacitor and resistor are supplied with this kit. Do not omit these components as it will cause damage and/or inaccurate reading from the sensor





Image Image




Pinout:

GP2Y1010AU
Pin 1 (WHT)......IR LED power (5V via supplied 150 Ohm resistor)
Pin 2 (BLU).......GND
Pin 3 (GRN).......IR LED control (HIGH = IR LED off, LOW = IR LED on)
Pin 4 (YEL)........GND (connected to case)
Pin 5 (BLK)........Sensors analogue output
Pin 6 (RED).......5V power

GP2Y1014AU
Pin 1 (BLU).......IR LED power (5V via supplied 150 Ohm resistor)
Pin 2 (GRN).......GND
Pin 3 (WHT).......IR LED control (HIGH = IR LED off, LOW = IR LED on)
Pin 4 (YEL).......GND (connected to case)
Pin 5 (BLK).......Sensors analogue output
Pin 6 (RED).......5V power


Example sketch:
Code:
/* FILE:    GP2Y1010AU0F_Dust_Sensor_Example
   DATE:    24/08/17
   VERSION: 0.2
   AUTHOR:  Andrew Davies

   15/08/16: V0.1 initial version.
   24/10/17: V0.2 reduce ADC sampling delay from 320us to 280us

This example Arduino sketch will read the analogue voltage from the dust senors output
pin and convert it into a mg/m^3 value. To keep the sketch simple the result is based
on an approximation of the linear part of the output v dust density graph in the
datasheet.

You will need to connect the sensor to your Arduino as follows:

GP2Y1010AU............Arduino
Pin 1 (WHT).......5V via 150 Ohm resistor
Pin 2 (GRN).......GND
Pin 3 (WHT).......D2
Pin 4 (YEL).......GND
Pin 5 (BLK).......A0
Pin 6 (RED).......5V

GP2Y1014AU............Arduino
Pin 1 (BLU).......5V via 150 Ohm resistor
Pin 2 (GRN).......GND
Pin 3 (WHT).......D2
Pin 4 (YEL).......GND
Pin 5 (BLK).......A0
Pin 6 (RED).......5V

Additionally a 220uF capacitor should be connected across the sensors Pin 5 and GND

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER. */


/* The following values are a rough approximation taken from the datasheet graph.
 * To simplify the sketch, calculations are based on the liner operating range
 * of the sensor. */

/* Sensor voltage at 0mg/m^3 */
#define VOLTAGE_AT_0_MG_M3    0.6
/* Sensor voltage at 0.5mg/m^3 */
#define VOLTAGE_AT_0_5_MG_M3    3.6
/* As the ADC and the sensor outputs are both linear we can simply scale the output
*  voltage of the sensor to convert from volts to mg/m^3. */
#define SCALLING_FACTOR 0.5 / (VOLTAGE_AT_0_5_MG_M3 - VOLTAGE_AT_0_MG_M3)

/* Control pin for sensors IR-LED */
#define LED_PIN 2
/* Sensors output pin */
#define SENSOR_PIN A0

void setup()
{
  /* Set up serial interface and configure the LED pin */
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
}

void loop()
{
  int Result;
  float SensorVoltage;
  float DustDensity;

  /* Turn the sensors IR LED on for 320us */
  digitalWrite(LED_PIN, LOW);
  delayMicroseconds(280);

  /* Read the sensors analogue output */
  Result = analogRead(SENSOR_PIN);

  /* Turn the IR LED off */
  digitalWrite(LED_PIN, HIGH);

  /* Show the result in volts */
  Serial.print("Sensor voltage: ");
  SensorVoltage = Result * (5.00 / 1024);
  Serial.println(SensorVoltage);

  /* Show the result in mg/m^3 */
  DustDensity =  (SensorVoltage - VOLTAGE_AT_0_MG_M3) * SCALLING_FACTOR;
  Serial.print("Dust density: ");
  Serial.println(DustDensity);
  Serial.println();
  delay(1000);
}




Image

Datasheet:
Attachment:
HCSENS0024_Datasheet.pdf




Disclaimer: Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.


You do not have the required permissions to view the files attached to this post.


Mon Aug 15, 2016 9:34 am
Profile

Joined: Mon Sep 16, 2013 6:38 pm
Posts: 3
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Hi

The wire colours on my detector I've just received are in a different order to the ones shown here.

I have a connector wired as follows

Red (5V)
Black (Output)
Yellow (GND)
White (LED Control - Green on your diagram)
Green (GND - Blue on your diagram)
Blue (LED Anode - White on your diagram)

Can I assume the positions of the wires are correct on the picture and go by them and ignore the colours?
Thanks


Sat Sep 16, 2017 9:03 am
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 697
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Yest that's correct. The manufacturer has discontinued the GP2Y1010AU and replace it with the GP2Y1014AU which is functionally identical. However it seems the colour coding on the supplied cable has changed but the pinout on the module is the same. I've updated the information in the first post and also added an additional diagram to clear this up. Sorry for the confusion.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Mon Sep 18, 2017 9:07 am
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 49
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Just found a few errors in the Arduino example sketch code and wiring colours for the GP2Y1014AU only.
Should be:

GP2Y1014AU............Arduino
Pin 1 (BLU).......5V via 150 Ohm resistor, positive capacitor
Pin 2 (GRN).......GND. negative capacitor
Pin 3 (WHT).......D2
Pin 4 (YEL).......GND
Pin 5 (BLK).......A0
Pin 6 (RED).......5V

Additionally the 220uF capacitor should be connected across the sensor Pin 1 and Pin 2

The initial mention of 320 uS should be the actual maximum time the LED is activated, not a delay.

The A/D conversion takes about 100 microseconds (0.0001 s) to read an analog input according to the Arduino website, and the read point should be at 280 uS. Close? This is not croquet but computing, dammit!

My scope shows a waveform bump and 280 uS appears to be over the crest.
Sharp should get with the 10's and put the external resistor and capacitor and an 8 pin STM8S001 microcontroller (or even better a 6 pin Microchip PIC10F320 - 2 to 4 uS for A/D conversion) inside and allow I2C or serial access to a block of digital readings. The external trigger should be a single pulse or command and all of the timing and A/D conversion should be in Sharps domain. My last analog computer kit was a Christmas present in 1961 - GE Project Analog Computer. Analog is dead! and for good reason as demonstrated here.

So it may be best to turn on the LED (low logic 0) and delay about 80 uS and then read the analog. Analog to Digital conversion can take a longer time depending on the design of an ancient Arduino ATmega chip.
Further testing of the analog function timing should be tested before a device is put into service.
The final delay should be tuned to turn off the LED at 320 uS +- 20 uS, according to the specs.


Mon Oct 23, 2017 2:57 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 697
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Quote:
Just found a few errors in the Arduino example sketch code and wiring colours for the GP2Y1014AU only.


Ah yes, I've just updated the sketch to include the new colour coding. Looks like I made a cut and paste error. I've corrected it now thanks.


Quote:
Additionally the 220uF capacitor should be connected across the sensor Pin 1 and Pin 2


I don't see anything wrong here. Where do you see the problem?


Quote:
The initial mention of 320 uS should be the actual maximum time the LED is activated, not a delay.


Looking at datasheet I agree, I think the time should be reduced to 280us. 320us (+/- 20us) is the 'recommended' on time. Note that no maximum on time is specified. I'll reduce the delay in the sketch a little.


Quote:
The A/D conversion takes about 100 microseconds (0.0001 s) to read an analog input according to the Arduino website, and the read point should be at 280 uS. Close? This is not croquet but computing, dammit!



This is my interpretation so is open to debate but remember that the ADC is a sample and hold circuit so it's not the ACD conversion time that matters but rather the sampling time. Assuming the output impedance of the sensor is < 10K the sampling time for the ADC (according to the datasheet) is not significant. Therefore the sampling should start at 280us.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Tue Oct 24, 2017 9:16 am
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 49
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Quote:
Additionally the 220uF capacitor should be connected across the sensor Pin 1 and Pin 2
I don't see anything wrong here. Where do you see the problem?

There's no problem as that was my suggested correction :lol: see next as it still appears.

Quote:
Additionally a 220uF capacitor should be connected across the sensors Pin 5 and GND
should be:
Additionally a 220uF capacitor should be connected across the sensors Pin 2 LED-GND and Pin 1 V-LED + capacitor

Quote:
/* Turn the sensors IR LED on for 320us */

/* Turn the sensors IR LED on for 280us */

The 320uS LED pulse width is a spec in the datasheet, however ridiculous it sounds. I am going to get this working with an STM8S, 11 clock cycles at 16 MHz for AD conversion.

One last thing, missing Ts in OUPUT in graphics.

Many thanks, my passion and enthusiasm often gets mistaken for criticism, but I seriously put a little humour in it to make it interesting.


Tue Oct 24, 2017 2:59 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 49
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Quote:
24/08/17: V0.2 reduce ADC sampling delay from 320us to 280us
should be:
24/10/17: V0.2 reduce ADC sampling delay from 320us to 280us


Tue Oct 24, 2017 3:12 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 697
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Probably my subconscious trying to deny we're so close to Christmas ;-)

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Tue Oct 24, 2017 3:38 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 49
Post Re: GP2Y1010AU0F Compact Optical Dust/Smoke Sensor (HCSENS00
Wow, less than two months to buy the latest components with overnight delivery and superb product support and most informative forums.


Tue Oct 24, 2017 8:32 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD