Jump to content

Counting pulses via Analog In


Recommended Posts

I'd love to be able to track our water/gas/electricity usage via a mechanism similar to that developed by http://www.bwired.nl/How_rfxcom.asp


This chap hooked a plain, cheap sensor to a commercial pulse-counter. With my TF stack now living happily in our cellar, I'd like to try to hook up a Vishay CNY70 Optical Reflective Sensor to an Analog In bricklet and replicate the bwired design.


I've got no electronics experience, so am wondering whether this setup can work? Looking at the Analog In, I see that it has a single In line, and two 3.3/5V lines.. so I'm assuming I can just hook up the sensor with no additional electronics..? The rest would be down to the software.


Does anyone have experience of Analog In for pulse counting?



Link to comment
Share on other sites

Sure. I did this with a LDR and a few resistors on an arduino. With the TF hardware you could set a threshold value on the analogue bricklet and get the callback to increment a counter in your software. Should work the same way. Google the theory for setting up the resistors. You are essentially creating a light dependant potentiometer and then measuring the voltage changes.


It is of course better to use some electronics to create a voltage pulse that the digital i/o can process as this will be considerably cheaper

Link to comment
Share on other sites

@CD108: I'm not very into electronics. So my questions:

When using the analogue in bricklet you should add a resistor in serial to the LDR as voltage divider? Is this correct or would it be enough to just use the LDR without any resistor?


Could you also elaborate what should be done when you want to use digital IO for such kind of sensors?


Link to comment
Share on other sites

I'm not looking at aggressively minimizing costs, my project is a one-off anyway. But I understand that using a IO-4 or IO-16 instead of numerous Analog In bricklets is a far superior approach, if only because it saves precious Bricklet connectors on the Masters (I've just got 3 unused connectors left on my 2-Master stack).


I'll have to get hold of the sensor, an IO-16 and an Analog In for good measure (pardon the pun)... and experiment.


Thx for the tips guys !


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...