I wanted to detect particles in the air. So I bought a dust sensor. (GP2Y1010AU0F, http://www.waveshare.com/wiki/Dust_Sensor 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.
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?
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.
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.
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
printf("aio : %f\n",a);
I didn't apply equation.
Most of your code looks good but I have a doubt with the line:
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.