Page 1 of 1

Getting a LJ12A3-4-Z/BX-5V NPN Pulse Counter to work

Posted: 29 Jul 2019, 15:53
by bulthaup
Hi all, this is my first post. I have been reading here for a while now to find cool projects to learn from in my home automation setup. I have very poor knowledge of electronics but I would like to learn more so please spare me if I made a rookie mistake :) Hopefully others will be able to learn too from this post.

I am trying to get a NPN sensor to work to measure a watermeter. I have followed instructions here: ... j12a3-page

I have bought the 5V version of this sensor and attached a separate DC power supply (5V/600mA) to the sensor. Normally the wiring is like this:

VCC (brown)
GND (blue)

If I connect the + wire from the DC power supply to the brown wire and the - wire to blue, the sensor doesn't work. Maybe a mistake in China? :) If I connect them the other way around, I can see the red LED blink when I hold a metal object before the NPN sensor. So far so good.

I am running a NodeMCU with Git Build mega-20190630 and I have configured the device as required. The black wire (signal) is connected to D6 of the NodeMCU. The NodeMCU is powered by USB via my computer for testing for now.

daeda.PNG (29.17 KiB) Viewed 11167 times

The problem is that I'm not able to get any pulse registered whenever I hold a piece of metal in front of the NPN sensor. When I unplug the black wire from D6 sometimes a pulse is registered but not always. If I try this on D5, no pulse count is ever detected (even not when unplugging the signal wire).

When I measure the sensor it goes from +1.12V to -3.56V when I hold a piece of metal in front of it.

Any help would be much appreciated!