Hello,
I am working on a project that calculates consumtion of an outboard engine for my boat using a flow sensor. It is this sensor and the OF05ZAT-AO in paricular.
I have a sketch that is used to calibrate the sensor. I pass one liter of water through it and see how many pulses it registers using interrupts.
However, although the datasheet mentions that the pulse rate is 0,46mL/P which means 2174 Pulses per Liter, when I run the sketch I only register 180 every time. x12 times less than normal.
I am unsing an old Arduino Duemilanove with a ATMega 328.
Here is the code, can you see something wrong with it?
//******************************************************
// BT Fuel Manager Sensor Calibration Arduino
// sketch by MaleBuffy
// 21/6/2014
//******************************************************
//
// Pin D4 for +5V for the Sensor 1
// Pin D6 for GND for the Sensor 1
// Pin D2 for Sensor 1 cable
#include <SoftwareSerial.h>// import the Arduino serial library
volatile float PulseSensor=0; // Measuring the pulse from the sensor 1
int hall = 2; // Sensor 1 Pin should be connected to Pin 2 of the Arduino
void incementpulse () //This is the function that incements the pulse counter. PulseSensor 1
{
PulseSensor++; // Equals PulseSensor = PulseSensor + 1
}
// Begin of Code. Setting pins up.
void setup()
{
pinMode(hall, INPUT); // Init Pin 2 to receive data from the Sensor
digitalWrite(hall, HIGH); // Using Internal Pull up resistor to pin 2
pinMode(4, OUTPUT); // Initializes digital pin 4 as an OUTPUT
digitalWrite(4, HIGH); // 5V to pin 4 (Flow Sensor)
pinMode(6, OUTPUT); // Initializes digital pin 6 as an OUTPUT
digitalWrite(6, LOW); // GND to pin 6 (Flow Sensor)
attachInterrupt(0, incementpulse, RISING); // attaching the interupt
sei(); // Enabling interrupts
Serial.begin(9600);
}
// Loop measuring pulses from Sensor
void loop ()
{
Serial.print("PulseSensor: ");
Serial.println(PulseSensor);
}
//cli(); // Disabling interrupts