# Interfacing a flow control sensor with a microcontroller

How can I interface this sensor with a microcontroller? It has a normally open output and it will work @ 24V. If I feed the BK contact from the sensor to a pin of the microcontroller through a voltage divider, would that be a good design?

• Wouldn't the input be floating if it's normally open? – NickHalden Jul 20 '11 at 14:40
• @JGord - Yes, and that's why you need a pull-down resistor, just like you would need a pull-up for the more common NPN open-collector. – stevenvh Jul 20 '11 at 14:47

If you place two resistors in series here, you'll have the voltage divider you need to reduce the 24V signal to e.g. 5V. For a 5V microcontroller the top resistor can be 18k$\Omega$ and the lower 4.7k$\Omega$ (that's the ratio anyway).
If you want isolation between the flow sensor and your microcontroller you'll have to use an optocoupler, like the CNY17. Make one of the resistors a 1k$\Omega$, and replace the other one by the optocoupler's LED. It doesn't matter which one goes where, but pay attention to the LED's orientation.
The collector of optocoupler's output transistor goes to your microcontroller, with a 10k$\Omega$ pull-up resistor to the microcontroller's power supply. The emitter goes to ground.