[SOLVED] GP2Y10 dust sensor plugin code bug?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
sgtlagrange
New user
Posts: 2
Joined: 28 Jan 2017, 11:28

[SOLVED] GP2Y10 dust sensor plugin code bug?

#1 Post by sgtlagrange » 28 Jan 2017, 11:39

I am trying to hook up the GP2Y10 dust sensor to an ESP8266 with an ESPEasy. Looking at the source code I noticed something strange in the part responsible for reading from the sensor:

Code: Select all

        {
          digitalWrite(Plugin_GP2Y10_LED_Pin, LOW);
          delayMicroseconds(280);
          value = value + analogRead(A0);
          delayMicroseconds(40);
          digitalWrite(Plugin_GP2Y10_LED_Pin, HIGH);
          delayMicroseconds(9680);
        }
So it looks like the code sets the ILED PIN LOW, then takes the measurement and then sets it high. Shouldn't it be the opposite? We need the LED to be on when taking the measurement, not off.

Is this a bug or am I totally missing something?
Last edited by sgtlagrange on 29 Jan 2017, 12:51, edited 1 time in total.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: GP2Y10 dust sensor plugin code bug?

#2 Post by Shardan » 28 Jan 2017, 16:49

Have a look at the internal circuitry of the GP2Y10

http://html.alldatasheet.com/html-pdf/4 ... 0AU0F.html

You will notice there is a PNP transistor inside the item driving the internal LED.
PNP says it needs a "Low" signal for "LED on" and a "High" signal for "LED off".

So that is quite correct this way as ESPEasy drives it directly.
If you would use an additional transistor externally for driving as shown in the datasheet it should be the other way round.

The GP2Y10 works here without issues.

Regards
Shardan
Regards
Shardan

sgtlagrange
New user
Posts: 2
Joined: 28 Jan 2017, 11:28

Re: GP2Y10 dust sensor plugin code bug?

#3 Post by sgtlagrange » 29 Jan 2017, 12:50

Thanks, Shardan, that makes a lot of sense.

My sensor came on a module board. Thought its only purpose was to simplify the wiring and voltage supply, but apparently it has the external transition which you mention. So in this particular case it works correctly when the LOW and HIGH states are switched in the source code.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: [SOLVED] GP2Y10 dust sensor plugin code bug?

#4 Post by Shardan » 29 Jan 2017, 13:45

Hello,

i've searched Google for such board-mounted GP210Y.

As far as i can see from the pictures all boards i've found have a small SOT-23 item in the circuit. I assume that's a transistor or FET so i think you're right.

Regards
Shardan
Regards
Shardan

Post Reply

Who is online

Users browsing this forum: No registered users and 85 guests