How to best count pulses on a sleepy boron

So what I want to do sounds super easy but struggling with the best approach. I could use some guidance.

I want to simply count pulses on a hall effect flow meter. sounds easy right? I want a totalizer for the total volume of water over a period of time. But I want to do this on a battery operated sleepy Particle Boron.

When the boron is sleeping it should use minimal power but still continue to count pulses. Then let’s say every 1 hour it should wake up, connect, read the totalized count value and publish the result and fall back asleep.

I’d assume the leading option is to use an interrupt on the MCU. There are lots of examples of this approach on an always on device. But in my case I need to wake up the MCU from sleep, count up in the interrupt service routine, and then put the MCU back to sleep every single time. Just seems less than ideal to do this on a sleepy boron.

Is this really the best way to do it? Is there an external IC that can be used for this? I’d much rather just let an external ultra low power IC do the simple counting and then I just poll it for the current totalized count via I2C. I am struggling to find a IC that does this simple task.

I was thinking something simple like this:

But oddly enough that chips standby current is a whopping 13.2 mA. It has a sleep mode with only 131 uA but it doesn’t even count when it’s sleeping.

There has to be a simple way to do this as there is all sorts of battery operated totalizer water meters out there with simple eInk displays. I basically want to do that same thing but have it internet connected via Particle.

Can I use some sort of external RTC but instead of a crystal I wire in the pulse signal? Is there an IC chip that does this?

Any guidance would be appreciated!

This should do the trick: https://www.analog.com/media/en/technical-documentation/data-sheets/ds1682.pdf

The event counter is what you need, and the consumption is <10uA.

2 Likes

@no1089 - Good stuff. Thanks for sharing. That might work.

Looking at that spec sheet I had a few observations.

The EEPROM array for the ETC and the event counter is
made up of three banks. Each bank can be written a maximum of 50k times.

When the EVENT pin goes low, the event counter
increments, the oscillator stops, and the ETC and
event counter are transferred to EEPROM.

Since this device writes the count to EEPROM at the end of every "event" and an event is very short/frequent (i.e. counting pulses). I wonder if this would cause EEPROM wear. Not exactly sure what happens when EEPROM is worn out. I assume it'll just not return the right data when I attempt to read it? I think I'm OK with the count being lost during power cycles (removal of a battery) but I think I do need to count well in excess of 50K due to high frequency counts.

I also am not 100% sure how many pulses a flow meter will generate but I'm skeptical if this is fast enough. I think this one from Seeq Studio is about 275 Hz at full flow rate.

This is about 3-4 ms per cycle. However, the chip Event timing is this:
image

Functionally, it's what I want I'm just not 100% sure how well it'll work for counting pulses from a meter. Maybe something like this instead?

@jgskarda, depending on the total number of pulses you expect in a one hour interval, you could use a simple binary counter like this dual 16-bit unit from TI which can be cascaded for a total of 32bits. The catch is that you need 8 GPIO (plus extra controls lines) to read the total count.

The S35770 seems better suited since it has an I2C interface, can work at 5V (matching the flow sensors min voltage) and can handle a 5V pulse on its CLK pin. I'm not sure if a library already exists for this chip but it wouldn't be much work to implement.

BTW, there is a library for the S35770, licensed under Creative Commons (Give Credit, NonCommercial, ShareAlike) that you could use.

1 Like

@peekay123 - Yeah, I think I poked at that one too. I suppose I could always use that and a I2C GPIO expander but if I'm reading it over I2C I will first try the S35770.

Thanks for pointing out the library! That saves a ton of development time. Should be seamless to port that over to Particle.

I just ordered some of those S35770 ICs to play with along with a 5V Boost converter as many flow meters indicated 5V minimum. I'll post my results here as I do testing in the next week or so.

@jgskarda, given the low power nature of the flow sensor and the S35770, you can get away with a 5v charge pump (no coil) like an RT9361.

2 Likes

Nice! I didn’t even know these existed. I learn something new everyday!

1 Like

Alright, so quick update.... the S35770 works very well paired with a simple 5V boost pump. I love the simplicity of it over tying to implement interrupts and waking a sleeping MCU for the sole fact of counting. For testing I got out the old bread board and then the protoboard and it works great. Now that it's working I'll spin up a new host PCB with these components on it:

However, I'm still struggling to get a low power sleepy version of this. What I'm finding is that not all turbine flow meters are built for low power battery operation. This one that I randomly ordered from Amazon for some quick proof of concept testing is still consuming ~3 mA at 5V when connected directly to a 5V power source even with the signal wire "open/disconnected". So the hall effect sensor in the water turbine meter must have some power draw or non-optimized circuit that consumes some power. It's not clear if this is all hall effect style flow meters or just the random one I tried.

Has anyone out there found a very low power draw turbine flow meter? Obviously they exist as I see lots of digital water meters out there that use the turbine style. I think my options are:

  1. Identifying a turbine style flow meter with a hall effect sensor that consumes very little power (ideally less than 100 uA if not less).

  2. Identifying a turbine style flow meter that uses a reed switch instead of a hall effect sensor. A 2 wire reed switch should be an open circuit majority of the time and thus consume no power the majority of the time. Maybe something like this?

  3. Go with a more "traditional" style water meter like this, that typically has a reed switch that counts one of the dials when it rotates around. Similarly above a 2 wire reed switch should be an open circuit and consume no power the majority of the time.

1 Like

Jeff, I cant offer much help except encouragement. I like where you are going.

I've previously used simple 5V turbine meters on 3.3V with Battery powered Borons via ISR only with crude SW debounce .
The cheap little meters were sourced from a supplier that's no longer in business :upside_down_face:

Does your "expected" flowrate have a significate range ?

Flow velocity in the pipe becomes important if you are chasing accuracy, as these devices assume a Positive Displacement scenario through the turbine.

1 Like

Sometimes a little encouragement helps keep me making progress so just encouragement is fine as well. :raised_hands:

Yeah, I have some concerns of how accurate this will be. The use case is basically measuring the volume of maple sap at 2% sugar content. It looks, tastes and flows just like water. The most typical scenario is a well pump that turns on/off every 10 minutes or so and pumps the sap through a 1.5" diameter PVC pipe. The pump turns on/off from a float switch. Given this scenario it's either "Full Flow" or "Off". Once it turns off a check valve prevents any flow back. I'm not expecting it to be perfect initially but once you say fill a 1,000 gallon tank, I could see how many counts that took and then adjust the counts per gallon conversion constant to be accurate enough. Since the flow doesn't vary much, my thought is it should be fairly accurate. I am planning on testing it out on my sump pump in my basement initially. Although I don't have a good way to calibrate it as that's just pumping outside it'll be fun to try. I'd really want this to be battery operated long term so thus the need to find a low power flow meter. Basically I'm building a low power/battery operated cellular connected water meter.

My thought is build the hardware/programming as just a simple "pulse counter" if someone already has a water meter, they can just hook it up and enter their units of measure and pulses per unit of measure. We will see where it evolves to from there.

Jeff, didn't you get pretty deep in the LoRa deployment for the maple tree farms?

I have seen LoRa Modules specifically for water meters w/ typ pulse outputs.

1 Like

Haha, yup. This development is for both a Particle based water meter as well as a LoRa based water meter. I could potentially go buy a LoRa water meter but the advantage of building one is I can then make it part of a multi purpose single cellular device (measure vacuum, tank level, turn relays on/off, measure temperature, measure water volume). Same thing with the LoRa end node can be multi purpose. This keeps cost down.

I also use my own LoRa point to point communication protocol and not LoRaWAN so thus naturally requires my own firmware/hardware.

1 Like

I'm making some assumptions here:
I think most of these cheap meters are open collector output.
You might be able to reduce the power consumption with appropriate sized resistor on your pullup ?
I'm guessing it's a balancing act between that and preventing noise over the 3-wire.

The Automated Meter Reading (AMR) Water Meters in the Potable Water Market apparently take a different approach, as those have a 15-20 year battery life. I'm not sure what magic VooDoo AMR uses to count pulses in a low powered manner.

1 Like

Good thoughts...

I'm using a 470K ohm resister as a pull up on the pulsed output from the meter. Even with that wire "open" it still draws the same.

My perception is most if not all of the long battery life automated meter readers use a two wire magnetically activated reed switch therefore the power draw on the meter itself is zero. It's just a switch that closes via magnetic field. One of the dials that turn has a magnet on it and the magnetic reed switch is then activated once per turn (i.e. once per gallon as an example). I might end up going that route as I think it would be much more accurate than a turbine style.

I've used something like this the last 2 years. It's a turbine style sensor with an e-ink display and battery operated, just not internet/cellular connected. So a low powered turbine sensor has to exist. I just need to find one. :slight_smile:

Sounds like the $75 Stainless Steel meter (2-wire dry contacts) that you linked to already would be hard to beat.

1 Like

Hey Ryan, do you have by any chance a link to any of those sensors?
I'm curious.

EDIT: forget that, I ran a search on what you typed and got few hits:

Thanks

1 Like

Hey Jeff, why did you discard that option? Did you find an example or a measure of how much the sleepy boron would consume when awoken 300 times per second?
thanks

1 Like

Those are some awesome links on AMR. Thanks for sharing @gusgonnet Good stuff! I'm learning more and more in this space every day. For my particular use I need closer to real time data. Ideally every 5 maybe 30 minutes and the locations are remote, middle of the woods, the middle of a farm field, etc. and finally the water meter is just one of several sensors/actuators I need in close proximity so thus trying to build my own version with Particle as the backhaul. And besides... it's a fun challenge and a good way to learn new things. :slight_smile:

I actually programmed it originally using interrupts. I'm currently using a Current Ranger as my low cost sleepy current measurement device. I didn't take some average over time or measure the precise duration of the interrupt but I just know it spiked to around 9mA just momentarily as part of the interrupt. The 1.5" flow meter is something like 20 pulses per gallon so to fill a 1,000 gallon tank would be 20,000 interrupts in this use case, maybe the duration is so tiny it is inconsequential/would work it just doesn't feel as "clean".

I plan to eventually apply this learning to a LoRa end node device as well. For those LoRa end nodes, I use an AB1805 RTC as well as a LoRa Radio communication to also wake the device up upon interrupts. So it just gets clunky to figure out why the device woke up and based on that what action to take. I even attempted to use "Timer 4" on a SAMD21 MCU per this blog post

alternatively route the pulses through the SAMD21's External Interrupt Controller (EIC) and on to a TC timer using the Event System. The TC timer is configured to count the incoming pulses. The Event System is a 12-channel highway for peripheral-to-peripheral communications without CPU intervention. The latter option has the advantage that it isn't necessary to call the ISR each time a pulse is received; the whole process occurs without any CPU intervention, apart from reading the timer's COUNT register.

Likewise it worked but I still couldn't figure out how to make it work when sleeping. Ultimately, my goal is to keep things as simple and straightforward as possible to get the job done. Adding the extra S35770 I2C counter chip just seems like the simplest/most straight forward solution. It's just might not be as elegant as interrupts.

2 Likes

And how long would an average tank take to fill up 1,000 gallons?

I personally have a 3K gallon tank. On a good day we can fill that tank completely from about 1500 maple tree taps. Producers will have a few hundred to beyond 10K taps in a woods. So in my case about 8 hours per 1,000 gallons. But could be as little as 1 hour for other producers.

Fun fact of the day… maple syrup is about 40 gallons sap to 1 gallon of maple syrup so the full 3,000 gallon tank will make roughly 75 gallons of pure maple syrup. Pancakes anyone??? :maple_leaf::rofl:

1 Like