Flow sensor help

I'm gathering all the hardware pieces to start logging a new to be installed heatpump.
Temperature sensors should be easy, flow rate however not so much.

 

We have flow sensors readily available of the type SIKA VVX 25
http://www.sika.net/en/products/flow-measuring-instruments/vortex-flow-sensors/series-vvx/item/1154-vortex-flow-sensor-type-vvx-25.html
 

Looking at page 32 of the datasheet here it should provide a pulse output.
I am however not familiar with this so was wondering if anybody could look at this and tell if this sensor is easily connected to an emonpi?

Any help is highly appreciated!

 

Robert Wall's picture

Re: Flow sensor help

The centre diagram (NPN Open Collector) looks as if it should work - you'll need the pull-up resistor (RL) at 5.1 (or 4.7 or 5.6) kΩ and you'll use pins 2 (U+) and 6 (pulse) on the "temperature sensor" RJ45 connector.

However, if I've done my sums correctly, the maximum pulse rate is 250 per second, so the sketch inside the emonPi might well need tweaking to accommodate that.

Beire's picture

Re: Flow sensor help

Thx for looking.
I got a chance to look at the sensor in question today.
Turns out it's not the version with pulse output but with analoge output (see p33).

Looking aht the datasheet, is this version easily connectable?

Thx for the help!!

Robert Wall's picture

Re: Flow sensor help

It should be possible, though I've not tested it. A6 appears on pin 8 of the RJ45 connector, but that is only good to 3.3 V whereas your output possibly goes to 4 V - certainly to 3.5 V - therefore you'll need to lose a small fraction of the input voltage with a voltage divider.

And of course you'll need to modify the sketch in the emonPi to handle that input.

Beire's picture

Re: Flow sensor help

For the vvx 25 3,5v means 150 l/min.
I will be far from it.
Even the vvx15's max of 40l/min won't be hit.

So this means i don't have to adjust the voltage?

Is there a post or something describing how to adjust the sketch?
I'm totally new to rasperrby pi and arduino.

Robert Wall's picture

Re: Flow sensor help

Maybe you do not expect the voltage to rise above 3.3 V, but in the case of a fault, it is possible that the voltage will rise above 3.3 V and the ADC input of the Atmel328P could be destroyed, therefore your input circuit should protect against that possibility. As the 3.3 V supply is not available on the connector, the only practical way is to add a series resistor (say 10 kΩ) to limit the current and hope that the internal protection diodes are adequate.

There are no instructions on this site for changing the sketch, though there are very many web pages about measuring voltages with the Arduino.

In outline, you must
1. In the header, add a suitable variable to the PayloadTX struct.
2. In setup(), be sure that the No. 6 analogue port is set to be an input (this is the default).
3. In loop(), do an analogRead() of the input pin and scale the number to engineering units, copy the result into the new variable.
4. Compile the sketch and transfer the hex file to the emonPi.
5. Change the configuration of emonHub to include the new variable that you added.

Beire's picture

Re: Flow sensor help

Allright, thx!
Seems is missed your post, hence the late reply!

I'll go ahead and order everiything i need.
Where can i download the original sketch loaded in every emonpi by default?

 

 

Robert Wall's picture

Re: Flow sensor help

Github, as normal. You need all the .ino files, even though you'll only edit the one:

https://github.com/openenergymonitor/emonpi/tree/master/Atmega328/emonPi...

Beire's picture

Re: Flow sensor help

A bit has changed lately.

I have the EmonPI with connected temp. sensors and edited Vcal (thx!).
Also i have the flow sensor wired to the emonpi. I measured the voltage coming into pin 8 of the RJ45 sensors, and it seems to work fine.

However, i have been looking at your instructions for editing the sketch to accommodate the new sensor, with no real success.
The only reference to pin 8 in the sketch seems to be this line:

//const byte emonPi_RJ45_8_IO=           A6;           // RJ45 pin 8 - Analog 6 (D19) - Aux I/O

Can you explain this in a bit more detail? if possible.

 

Robert Wall's picture

Re: Flow sensor help

You need to be looking at the ISR for handling the pulses. That's in the file "emonPi_Interrupt_Pulse.ino". And it gets into the ISR via the file "emonPi_Startup.ino" for the pull-up and "emonPi_int1_pin" and the main sketch for the interrupt itself. It's "emonPi_int1_pin" that you are looking for, and it's actually pin 6 on the RJ45 (see the Wiki).

Beire's picture

Re: Flow sensor help

But, i'm using 0-3,5v.not pulses.
Isn't pin 8 the one i need for analog signal?

Robert Wall's picture

Re: Flow sensor help

Sorry, I'd forgotten that. Most flow sensors send pulses. Pin 8 is ADC 6 so it should be readable with a normal analogRead(emonPi_RJ45_8_IO).

"A6" is a predefined constant in one of the Arduino library files, so "emonPi_RJ45_8_IO" is really just giving a meaningful name to that input - after you've uncommented that line, of course.

Beire's picture

Re: Flow sensor help

I've started fiddling with the sketch, not knowing half of what i'm doing to be honest.

Is the added sketch anywhere near what i'm supposed to be doing?

Doen't compile though:

flowValue was not declred in this scope...

Beire's picture

Re: Flow sensor help

or should i just add 

  emonPi.flowValue=int(analogRead(emonPi_RJ45_8_IO)*28.5714);

to loop()

 

EDIT:

I'm getting somewhere, with this above command i'm now getting a value in emonhub!

It's not correct (bit high), but i can go from here now.

Thx for the help robert, your posts have been great! (although difficult to understand for me :) )

Beire's picture

Re: Flow sensor help

I have been playing around with this some more.
There seem to be 2 problems still.

1. The measured Voltage coming in on the input is incorrect. ( Arduino measured value is higher than manually measured with multimeter. Calculated flow is as expected also too high. 0 flow reads as 18l/min...

2. Highly fluctuating values, very unstable.
Could this be an effect of the power supply? Measured +5VDC is fluctuating between 4.82 V and 4.86 V.
Besides the fact its unstable, isn't it too low?
I'm using the PS delivered with the emonPi.

My power feed coming from the CT's also isn't very stable, i'm not sure how stable it is supposed to be actually.

Can i read the actual Vcc measured by the arduino in my calculations?
In the sketch is written i shouldn't use readvcc?

 

TrystanLea's picture

Re: Flow sensor help

Hello Beire

Looking at your code I can see a few potential problems, although by the looks of it you got a bit further as you have the data in emoncms. I would do something like this for the analog reading:

    double sum = 0; byte n = 0;
    // try increasing this for a more stable reading
    for (byte i=0; i<10; i++) {
      // calculate voltage in Volts on A6 and add to sum   
      sum += (analogRead(A6)/1023.0)*3.3;
      n++;
    }
    double flowVoltage = (sum / n);
    double flowValue = flowVoltage  * 28.5714;
    emonPi.flow = flowValue * 10;

if you add that just above the line
    send_emonpi_serial();

The above lines calculates an average which might help with stability a little, the result is also multiplied by 10 in order to make it possible to send it as an integer and then divide by 10 to obtain L/min to one decimal place in emoncms.

The power feed does look quite noisy, what are you measuring with it? do you have an ACAC voltage sensor for realpower measurement? I've attached an screenshot of my emonpi at ~30W load, the standard deviation measured in emoncms is 1.9W over that period, Im using an ACAC adapter for voltage measurement.

borpin123's picture

Re: Flow sensor help

Hello Beire,

I wonder where you got these from - I have been looking for a flow meter for a while.  Are you in the UK (I'm guessing not)?

Cheers, Brian

Beire's picture

Re: Flow sensor help

Hey Trystan,

Thank you for taking the time looking at my problem!

You mention multiplying by 10 to send as an integer. Up until now i sent the value as a float:

Payload:

float flow;
float flowVoltage;

Is it better to send as an integer?

I have edited and attached the sketch. Is it correct this way? I changed the value * 28.5714.
This value was a prelimenary test value. The calculation should now be correct with that formula and correspond to the output graph of the sensor.

Exactly what value should i change to have a more stable reading?

I'm having a bit delay now, as the sensor i placed in the system seems to be defective (wasn't new). So i'm now waiting for the time to go over there and change with a new model.

As far as the instable value's are concerned...
I'm measuring the power draw from the heat pump compressor. BUT as this is the first heatpump of this brand / model we are logging, i'm not sure how it compares to other brands we are logging.
Could just be the compressor load. Don't know. I'm having the electrical resistance also logged, i'll try forcing that one on as a test and look at that output.

I am using an AC-AC adapter btw (from the store EU model). I had to change the value of calibration in the sketch to 244 to correspond to the actual voltage.
This is far off the "default" recommended setting for the EU adapter no?

 

Beire's picture

Re: Flow sensor help

Hi borpin123,

I'm not from the UK now, i'm located in belgium.

I'm an installer of heatpumps (stiebel eltron and daikin).
These sensors are used in Daikin's models. BUT grundfoss sensors have a habit of dying after a while due to bad resistance to poorer water quality.
Daikin have issued an RMA procedure for al these sensors to change them with SIKA VVX sensors.

That is why i have quite a lot of them at my disposal.

Now as this is only temporary as a test case, i will be needing to source them elsewhere also.
I'll keep an eye out for them and let you know where i can buy them from. 

TrystanLea's picture

Re: Flow sensor help

Great looks good, you can increase the 10 here: for (byte i=0; i<10; i++) { to say 100 to average over 100 samples.

Sending as an integer uses 2 bytes rather than the 4 needed for a float which reduces the packet size helping with low power operation but if the node is powered from a usb supply it shouldn't really matter.

Yes the calibration can be different due to component and 1.1v reference tolerance, I recently fine tuned a test emontx to 260.4 to get closer results, there's a bit on voltage adapter calibration here: http://openenergymonitor.org/emon/buildingblocks/ct-and-ac-power-adaptor...

 

Robert Wall's picture

Re: Flow sensor help

"I had to change the value of calibration in the sketch to 244 to correspond to the actual voltage. This is far off the "default" recommended setting for the EU adapter no?"

Actually, it is just inside the tolerance band. The calculated coefficient is 260, with a 6% tolerance for the adapter, and divider resistor chain tolerances. Adding those in, the lower limit is 244.4. Then you must add the tolerance on the 3.3 V power supply, which is "typical" 0.4% (you are using an emonPi?), and that takes you below your value of 244. At the regulator limit tolerance of 3%, that takes the worst possible calibration factor well outside your value.

Beire's picture

Re: Flow sensor help

Thx for verifying trystan!

Robert,
Good to know it's not abnormal.
I wasn't worrying too much about it, just wondering if it's still within 'normal' spec :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.