10 Replies Latest reply on Jun 7, 2017 12:56 PM by Intel Corporation

    Have you used the dust sensor(GP2Y1010AU0F)?

    JINYEOL

      Hello, dear.

       

      I wanted to detect particles in the air.  So I bought a dust sensor. (GP2Y1010AU0F, Dust Sensor - Waveshare Wiki)

      I used the pin ILED(digtal) and Vout(analog) getting datas.

      I contacted with Waveshare, Manufacturer, and i got reply. They recommended using the test code with arduino. I attached code zip file below posts.

      But i don't have arduino board. So i tried C code in the file.

      However, I think the code not work on Edison.

       

      Please help us how we can solve this problem.

        • 1. Re: Have you used the dust sensor(GP2Y1010AU0F)?
          SpiderKenny

          Could you tell me, how are you connecting this dust-sensor to the Edison?

          • 2. Re: Have you used the dust sensor(GP2Y1010AU0F)?
            JINYEOL

            Thanks!

            I used 4 pins for running dust sensor. Vcc(5V), GND, ILED(Digtal pin, D2) and Vout(Analog voltage output, A0). And i direct connect pins with Edison.

            But i don't have result i expected. Also I could get the some values even though i didn't connect LED pin. That was wrong, right?

            • 3. Re: Have you used the dust sensor(GP2Y1010AU0F)?
              SpiderKenny

              What pins did you direct connect to?

              What board is edison on? (Mini breakout board? Arduino Board?)

              • 4. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                JINYEOL

                I have used IO Expansion shield for Arduino V7.1 on Edison.

                I used D2 and A0 for dust sensor.

                • 5. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hello JINYEOL,

                  Thanks for reaching out!

                  Since you are using the IO Expansion shield for Arduino V7.1, I assume that you are using the Arduino expansion board. Just to rule it out, have you tried using the sensor without the shield? Does it make any difference? 

                  I can see that you are trying to program the sensor using an Arduino sketch. Are you sure the library you are using is compatible with Edison's x86 architecture?

                  Let us know.
                  Pedro M.

                  • 6. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                    JINYEOL

                    Thank you.

                    I want to build C code. I dont want to use arduino.

                    I use this product Intel® Edison Kit for Arduino Package (주)엘레파츠

                    Could i run the sensor with my device?

                    • 7. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      I understand, for further tests please try using the Arduino expansion board (this board http://eleparts.co.kr/EPXDPTPY) without any shields, this is just to make sure that if there is an issue is not due to the shield. 

                      I was checking the GP2Y1010AU0F's datasheet (https://www.sparkfun.com/datasheets/Sensors/gp2y1010au_e.pdf), and I noted a few things, which I will note below. I also checked the site you shared on your original post http://www.waveshare.com/wiki/Dust_Sensor and visited the user manual (http://www.waveshare.com/w/upload/0/0a/Dust-Sensor-User-Manual-EN.pdf) and schematic (http://www.waveshare.com/w/upload/b/b8/Dust-Sensor-Schematic.pdf) of the module you are using. These are my thoughts:

                      1. Waveshare's module seems to makes things easier when trying to use the GP2Y1010AU0F, as it provides the circuit required for the sensor to work properly and lets the user worry about simply providing power, on signal and output. This represents four pins on the module (VCC, GND, AOUT and ILED).
                      2. My suggestion is that you do not use the examples and instead, use mraa (https://github.com/intel-iot-devkit/mraa) and standard C to program the sensor's module.
                      3. I don't have access to a GP2Y1010AU0F or the Waveshare's module, nevertheless (and according to the user manual and datasheet), these are the specifications you have to take in consideration:

                      -To enable the internal infrared emitting diode, you need to set the pin ILED to HIGH.
                      -Wait for 0.28ms (280us) in order for the external controller to start sampling the voltage from the AOUT pin. 
                      -The next 0.04ms (40us) you will receive the actual data on the AOUT pin. After these 0.04ms set the ILED to LOW in order to disable the infrared emitting diode. 
                      -Either check the user manual or the datasheet to see the Output Voltage vs. Dust Concentration graph in order to interpret the AOUT signal as the actual dust concentration.

                      4. If you'd like more details about how the GP2Y1010AU0F or Waveshare's module, then I'd suggest you to check in detail the user manual or the datasheet.

                      I hope this helps.
                      Pedro M.

                      • 8. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                        JINYEOL

                        Thanks Pedro.

                        I read your suggestion. I am building C code for the sensor.

                        After I run my code, I will let you know about result.

                        • 9. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                          JINYEOL

                          Hi Pedro.

                          I ran C code i build. I got result. But I dont know i go well.

                          So I suggest could you check my code. Are there something wrong, need to correct and i miss?

                          Also would you tell me to do  certain configuration before running my code?

                           

                          I added my code

                           

                          #include <stdio.h>

                          #include <mraa.h>

                          #include <unistd.h>

                          int main()

                          {

                                  mraa_init();

                                  mraa_aio_context aio;

                                  mraa_gpio_context gpio;

                           

                           

                                  aio=mraa_aio_init(5);

                                  gpio=mraa_gpio_init(7);

                                  mraa_gpio_dir(gpio,MRAA_GPIO_OUT);

                           

                           

                                  float a=0;

                                  float g=0;

                                  float p=0;

                           

                           

                                  mraa_aio_set_bit(aio,10);

                           

                           

                                  while(1)

                                  {

                                          mraa_gpio_write(gpio,1);

                                          g=mraa_gpio_read(gpio);

                                          if(g==1)

                                          {

                                                  usleep(280);

                                                  a=mraa_aio_read(aio);

                                                  if(a==0)

                                                  {

                                                  }

                                                  else

                                                  {

                                                          printf("aio : %f\n",a);

                                                  }

                                                  usleep(40);

                                                  mraa_gpio_write(gpio,0);

                                                  g=mraa_gpio_read(gpio);

                                                  usleep(9680);

                                          }

                                  }

                                  return 0;

                          }

                           

                          Result

                          캡처.PNG

                           

                          I didn't apply equation.

                          Thanks

                          • 10. Re: Have you used the dust sensor(GP2Y1010AU0F)?
                            Intel Corporation
                            This message was posted on behalf of Intel Corporation

                            Most of your code looks good but I have a doubt with the line:

                            usleep(40);

                            Why do you wait this 40us? If I understand your code correctly you are setting ILED high, you wait the 208us the sensor needs, then you read once and wait 40us. This way you will only read the sensors data once every active loop, is this what you're trying to do? If so, are the readings the expected?

                            Let me know.
                            Pedro M.

                            1 of 1 people found this helpful