Count pulses for flow meter

i would use a attiny as iic slave for that.
Let the attiny count the pulses and the cubecell only reads the data with iic.

The attiny can trigger the cubecell with an interrupt if needed

when you say iic mind i2c ?

Yes i mean iic = i2c

Why not doing direct using DIO ports of the cubecell ?

you can use the gpio ports of the cubecell.
i like it modular and all my sensors are using i2c and for correct count you have to run the cubecell for a long time to count. thats why i think using a little attiny would be more power efficent

Thanks for your explanation. It makes a lot of sense to me. Yesterday we were discussing it with the team and we reached a similar conclusion.

Would the attiny stay permanently on?
Cubecell would go to sleep and report every certain time?

Thats up to you.
if you need continuous measurement of the flow let the attiny permanently on and the cubecell will sleep and only gets the data via i2c and send it every certain time

OK. Will work with this.
Can you recomned some attiny hardware ?

i think a attiny25 should do it.

1 Like

Take a CubeCell-board directly (wake up by interrupt)!

but you need to count pulses all the time to calculate the flow.
only wake up by interrupt would only send that there is a flow but not how strong.
you have to count for some time after wake up, and the cubecell takes much more power than a attiny which is counting only.

but there is now wrong or right way.
it is up to the author of this post to decide how he would like to solve it.

Possible solution: Count per Interrupt (wake up per interrup), then wake up per timer
every minute, calculate the flow and send the result. But when the task is time-sensitive, a second controller would be a better solution. :slightly_smiling_face:

1 Like

do you want to measure the flow value or only if there is a flow?
can you tell us more about the flow sensor you are using?

perhaps i can help more if i know these things

I will choose the option of a secondary processor since the application is very sensitive. I must totalize the fuel consumption in a pipeline. No pulse should be missed.

Can you share schematic to connect attiny85 to cube cell board pls

please look in te datasheet. There is a sda and scl pin these and 3.3v and ground needed to be connected to the cubecell and use a free interrupt enables pin for your sensor.

Ok. So no external components. Pin to pin connection.

would recommend a pullup or pulldown resistor for the interrupt enabled pin.
it depends if you look for a rising or falling signal

this is a test file for a attiny85

#include <TinyWireS.h>
#include <PinChangeInterrupt.h>

#define PCINT_PIN 1
#define PCINT_MODE FALLING
#define PCINT_FUNCTION pulseCounter

int long counter = 0;

void setup()
{
  TinyWireS.begin(4);
  
  pinMode(PCINT_PIN, INPUT_PULLUP);
  attachPinChangeInterrupt(digitalPinToPCINT(PCINT_PIN), PCINT_FUNCTION, PCINT_MODE) ;
}

void loop()
{
  if (TinyWireS.available() > 0) {
    TinyWireS.send(readCount());
  }
}

void pulseCounter(){ 
  counter++;
}

unsigned long readCount()
{
 unsigned long sample = counter ;
 unsigned long sample2 = counter ;
 while (sample != sample2)
 {
   sample = sample2 ;
   sample2 = counter ;
 }
 return sample ;
}
1 Like

you can try this shematics:
**

**

1 Like