0

I have a PPD42NS dust sensor I'd like to hook up to an ESP8266-01 microcontroller. The ESP8266 uses 3.3v logic, but the PPD42NS uses 5v. The PPD42NS uses low pulse occupancy as output.

I'd like to use parts I have on hand, and I was wondering if a simple voltage divider built from 2 resistors can reliably shift the voltage without distorting the signal.

If not, could an NPN transistor do the job instead?

1
  • That should work. You just don't get very crisp edges on the signal. But I don't think that a problem with the PPD42NS as it probably uses relatively slow speeds.
    – Gerben
    Mar 6 '16 at 16:58
0

While the PPD42NS has a 5-pin connector, it is shown at seeedstudio.com and howmuchsnow.com connected up with three wires: +5V, Ground, and an LPO or “Low Occupancy Output” signal, which goes low when a particle occludes an LED beam path. LPO is used as an input to let sketches measure the fraction of time the beam's occluded, which correlates with number of dust particles.

Yes, a resistive voltage divider will let you use the 0-to-5V occupancy signal as an input to your 3.3V-tolerant ESP8266.

What values of resistors should be used? Because input pin capacitance is small (eg under 10 pF), signal "crispness" should be about the same over a broad range of resistances – say from a 100Ω+200Ω divider up past 1KΩ+2KΩ; even 10KΩ+20KΩ might be ok.

The Grove_-_Dust_sensor.pdf data sheet at seeedstudio.com says:

Output Method Negative Logic, Digital output,
Hi : over 4.0V(Rev.2) Lo : under 0.7V
(As Input impedance : 200kΩ) OP-Amp output, Pull-up resistor : 10kΩ

This suggests (but doesn't clearly indicate) that some sort of open-drain output might be used. If so, instead of using a voltage divider one could remove the 10kΩ pull-up on the sensor, and pull the output to 3.3 V instead of 5 V, via either an external resistor or using an INPUT_PULLUP pinmode setting (if available on the ESP8266).

Edit: Regarding the comment, “I'm considering use it in conjunction with an MCP23017 I/O expander IC. The GPIO pins on the chip appear to be rated at a max capacitance of 50 pF. Will that affect the range of resistors available? How does resistor choice affect the crispness of the signal, and how can I determine it for myself?”:

The “max capacitance of 50 pF” spec, which is parameter D101 in table 2.1 of the MCP23017 spec sheet, refers to “Capacitive Loading Specs on Output Pins”, ie, how much capacitance MCP23017 outputs can drive. It doesn't refer to input pin capacitance, so isn't relevant here.

In general, when a signal edge (a rise or fall) arrives at an input pin, the input pin's voltage doesn't change instantaneously. The input pin's capacitance needs to charge or discharge. (It charges for a rising edge, discharges for a falling edge.) The speed of change depends on the RC time constant of the circuit. A delay occurs, probably 1–3 time constants long, before the pin starts to switch. (The switch may take a few tens or hundreds of nanoseconds.)

For example, if input circuit capacitance is 10 pF and its effective resistance is 100kΩ, RC = 10 pF · 100kΩ = 10⁻¹¹·10⁵ = 10⁻⁶ seconds = 1 microsecond. Whether that's large enough to matter for your measurements depends on how many time constants have to occur before the pin starts switching, and on how narrow the LPO signals are.

In short, compute RC, and if it's more than a few microseconds, use a smaller value of R. Alternately, if you have access to an oscilloscope, attach it to the input and try various resistance values in the voltage divider, to get a feel for how the signals degrade as the resistors in the divider get bigger.

Note, using a voltage divider causes different RC values for falling edges than for rising edges. For example, suppose an actively driven 0-5V signal enters a divider with 10KΩ in series with 20KΩ, and the 0-3.3 V signal is taken from the resistors' junction. Then R is 10KΩ for a rising edge, and 20KΩ for a falling edge. If the 0-5V signal weren't actively driven high, but instead pulled up via a pullup resistor R' when a transistor turns off, then the rising edge R value would be R'+10KΩ for this example.

2
  • I'm considering use it in conjunction with an MCP23017 I/O expander IC. The GPIO pins on the chip appear to be rated at a max capacitance of 50 pF. Will that affect the range of resistors available? How does resistor choice affect the crispness of the signal, and how can I determine it for myself? Mar 7 '16 at 5:17
  • @user1569339, see edit Mar 7 '16 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.