02-02-2025, 07:47 PM
Ok, well I've made some progress... the good news is that I think 12V NPN NO sensors _will_ work the way as was expected above, directly connecting the signal output to a DI pin. Have not tested with 5V yet, and I'm fairly sure that PNP won't work at all without some sort of additional transistor circuit (e.g. an 2N2222 would probably do the job).
The bad news (and the reason why it took so long to confirm the point above.....) is that there appears to be a bug in the PCF8574 library which Kincony use in their demo scripts, that causes the values returned by digitalRead() to be zero if you call it twice in quick succession (it seems related to the internal buffering it employs here: https://github.com/xreef/PCF8574_library...4.cpp#L869 )
But switching to using Rob Tillaart's library instead, I can consistently read a NPN sensor at least! https://github.com/RobTillaart/PCF8574
The bad news (and the reason why it took so long to confirm the point above.....) is that there appears to be a bug in the PCF8574 library which Kincony use in their demo scripts, that causes the values returned by digitalRead() to be zero if you call it twice in quick succession (it seems related to the internal buffering it employs here: https://github.com/xreef/PCF8574_library...4.cpp#L869 )
But switching to using Rob Tillaart's library instead, I can consistently read a NPN sensor at least! https://github.com/RobTillaart/PCF8574