The mass production first of automobiles, and now of smartphones, has resulted in a surplus of inexpensive sensor modules. Devices are trickling down rapidly into the hobbyist market, with industrial surface-mount components installed on breakout boards for easy soldering. I’m in the process of researching the sensors section for my new book, Make: More Electronics, but wanted to take a break and share a few of my most interesting finds.
The Open-Collector System
Many all-in-one sensor modules operate on the principle of open-collector output. The detecting element in the sensor connects with the base of an internal transistor whose collector is “open,” meaning you can access it via one of the external leads.A typical arrangement is shown in Figure A. The positive side of the power supply sinks current through an external pull-up resistor, through the transistor, to negative ground. When the detecting element switches on the transistor, its effective internal resistance falls, and the collector voltage drops. When the transistor turns off, the voltage rises to near the power supply value (provided the collector isn’t connected with a low-impedance device that takes too much current). Instead of the meter in Figure A, you could substitute an input pin to a microcontroller, or the base of another transistor. A PNP transistor will give a positive output from a sensor whose effective internal resistance drops when triggered. The datasheet for a sensor should tell you its operating voltage and the maximum current it can sink, but won’t necessarily reveal the appropriate value of the pull-up resistor. You can find out by starting with 100K and working downward, while checking the voltage (as in
Figure A) and the current (as in Figure B). The current should not exceed the limit stated by the manufacturer.