Sunday, April 27, 2014

BT Fuel Manager/Gauge [no solder]

DISCLAIMER: This Project involves components that are attached to the fuel line. Fuel is explosive and you have to be very careful when modifying such parts of your boat. Please do so at your own risk.

I bought a used RIB Boat this year, a Scanner 590 with a TOHATSU 140 HP 2-Stroke Outboard. Since prices of gasoline are quite high where I live (1,60-165 Euros per Liter), I was looking to buy a Flowscan to measure my Fuel consumption. Well these babies start from 250 Euros and up. That is a lot of Fuel to burn. So I decided that I would make my own.

Since I dont have enough room in the console like you see in the Image below, I realised that I had to find another way to display my data. Something that didn't involve making holes in my new (used) boat. You guessed it. I am going to use my Bluetooth capable phone and an Android application.



So lets start with the project. We are going to make a Bluetooth Fuel Manager aka Flowscan for my TOHATSU 140 HP 2-Stroke Outboard.

The components



  • An Arduino Board. I am using an Arduino Duemilanove from an old project. Buy one here. Cost: about $13.79 or EUR 9,95

  • A HC-05 Bluetooth module. Buy one here Cost: about $6.99 or EUR 5.04
























  • A Waterproof enclosure from here. Cost about $6.00 or EUR 4,33

















    • A Waterproof DC/DC Converter 12V Step down to 9V 3A 15W Power supply from here. Cost: about $4.80 or EUR 3,46. This will be used after testing for final installation.


        • A 3-clone cable for the Sensor
        • A 2-clone Power cable for Powering the Arduino from the battery (or any other way you like)
        • A 4-pin JST connector and cable (can be 6-pin when you want to be able to reprogramm your HC-05)
        • Some screw terminal blocks (I use 5 double terminal blocks)

        The Software (Arduino Sketch)


        So in order for our Arduino to start behaving and reading/sending data as we want, we have to programm it first to do stuff. Go to the Arduino site by clicking here and download the Arduino IDE for your Operating system. Installation is pretty straight forward, so no problems here. 

        Connect your board via USB, run the Arduino IDE  and wait for for it to recognize your board. If it doesnt, then select it manually from the Tools menu.

        Copy and paste the following code and send it to the Arduino.



        //******************************************************
        //     BT Fuel Manager Arduino sketch by MaleBuffy
        //            for Single 2 Stroke Outboard
        //         and BT Fuel Manager / BT Fuel Gauge
        //                21/4/2014
        //******************************************************
        //
        //     Pin 9 of Arduino to RX on the HC-05
        //     Pin 11 of Arduino to TX on the HC-05
        //     Pin 3v3 for +3.3V for the HC-05
        //     Pin Gnd for Ground for the HC-05
        //     Pin D4 for +5V for the Sensor
        //     Pin D6 for GND for the Sensor
        //     Pin D2 for Sensor cable



        #include <SoftwareSerial.h> // import the Arduino serial library 
        SoftwareSerial BTFuel(11, 9); // Define the Pins of the HC-05 Bluetooth device. RX, TX

        volatile float PulseSensor; // Measuring the pulse from the sensor
        float literspersecond;  // Holds the Serial output to the BT Device. Its the liters per second
        int hall = 2;    // Sensor Pin should be connected to Pin 2 of the Arduino
        int pulses = 1818; // // Define Sensor Pulse per Liter for 2500 FCH-M-POM-LC 6 MM / 950 for FCH-midi-POM / 1818 for FS-3400AH

        void incementpulse ()     //This is the function that incements the pulse counter. PulseSensor
        {
          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)

          BTFuel.begin(9600); // Initiate serial connection to Bluetooth device
          attachInterrupt(0, incementpulse, RISING); // attaching the interupt
        }



        // Loop measuring pulses from Sensor

        void loop ()  
        {
          PulseSensor = 0;   // Resetting PulseSensor
          sei();      // Enabling interrupts
          delay (1000);   // Delay 1 second (1000 milliseconds)
          cli();      // Disabling interrupts
          literspersecond = (PulseSensor/pulses); // Flowsensor used, makes X Pulses ever Liter.
          BTFuel.println(literspersecond,4); // Sends liters per second to Bluetooth

        }

        Final code with twin outboard setup option here

        Connecting the sensors and Bluetooth module


        If you notice, there are some comments in the first part of the code. 


        //     Pin 11,9 RX TX on the HC-05
        //     Pin 3v3 for +3.3V for the HC-05
        //     Pin Gnd for Ground for the HC-05
        //     Pin 4 for +5V for the Sensor
        //     Pin 6 for GND for the Sensor
        //     Pin 2 for Sensor cable

        It tells you how you have to connect each sensor to the board.


        Preparing the Arduino

        Here is the Arduino without anything connected. You can also see the terminals that are going to be connected to the Arduino female headers.


        We are first going to use the 2 terminal block with the 4 connectors and put them in the Pins 3v3, Gnd, Vin and A0 (A0 is not used)




        The HC-05



        Although the HC-05 Module has 6 Pins, we only use the 4. The other two are when you want to name your HC-05 something else, or change baudrates and stuff. We don't need to do that but you can anytime. We are using a JST 4-pin cable assembly to make things easy.



        We connect the RX   pin of the HC-05 to Pin  9 of the Arduino.
                           the TX    pin of the HC-05 to Pin 11 of the Arduino.
                           the VCC pin of the HC-05 to the 3v3 Pin of the Arduino.
           and finally the GND pin of the HC-05 to the GND Pin of the Arduino.


        The Flow Sensor




        Our flow sensor has 3 pins. 2 for Power (V+ and Gnd) and one for the Pulse. The one I am using sends 2500 Pulses/every liter. By counting the Pulses it sends in 1 second, we know the consumtion of Fuel at any given moment.



        We connect the +V   pin of the sensor to Pin D4 of the Arduino.
                            the  Gnd pin of the sensor to Pin D6 of the Arduino.
                     and the Pulse pin of the sensor to |Pin D2 of the Arduino.


        Powering the Arduino with the 2 core cable



        Since I am going to use my BT Flow Manager on my boat, I have to find a way to power it. I could use a 9V battery, but the device will go to a place that is not easy to reach. So I want to power it from one of the two 12V batteries. I advise you not to connect it directly to the battery, but use a 12V Regulator of some sorts.


        We connect the +V cable to the Vin Pin of the Arduino.
                     and the Gnd cable to the Gnd Pin of the Arduino (which already has a black cable stuck in).

        +V goes to the Positive Pole of the Battery and the Gnd goes to, u guessed it, the negative pole.

        The result schould be something like this. Ugly huh! Don't worry. Its going to be pretty once it gets into that Waterproof case (which I am still waiting to come from China...)



        Now that we have everything connected, lets get to the Android part.


        The Android Application(s)

        I have made two applications, that basicaly do the same thing. They display Speed in mph, in knots and the fuel consumption data. I firstly thought I make it simple with just numbers etc.


        However, I soon realised that it is not as fun as a real gauge. So I made an artificial one. By touching the screen you change the type of fuel consumption displayed.



        You can download both apps from BTFuelMan.rar.
        Changed hosting site from Zippyshare to Google Drive.






        18 comments:

        1. Malebuffy,

          Do you have a minute to chat about this project? You can reach me at parkwestnh@gmail.com.

          Thanks,

          Nathan

          ReplyDelete
        2. Nice work! Very interesting project!
          I guess you use the phone's GPS to get speed for calculation of litres/nm ?

          BR //Lars

          ReplyDelete
          Replies
          1. Hi, Thanks!
            Yes the Phones GPS is used! That keeps the cost at minimum!

            Delete
        3. Great job! I'm waiting for the arduino board and accessories from China and can't wait to put it together.

          ReplyDelete
        4. Great job!Can you send app source code : munkaido@apaczainyh.hu

          Thanks!

          ReplyDelete
        5. Is it posible to change the speed to Kilometer per hour and the usage to Liter per Kilometer?

          ReplyDelete
          Replies
          1. 1 nautical mile is 1.852km. Multiply it in the Android code to get liters per KM

            Delete
        6. This comment has been removed by the author.

          ReplyDelete
          Replies
          1. Did you try an old Arduino IDE...probably before 1.0 ? Its an old project.

            Delete
          2. I did'nt see your reaction when i removed my comment sorry. I got it working! I copied the code to wordpad and then to IDE. After that is was no problem.
            Thank you for sharing all this info, it really helped me!
            Greetings from the Netherlands

            Delete
        7. Hi,
          It seems that all pictures (from photobucket.com) are no more available on your blog. Could you repost your pictures please ?
          Many thanks.

          ReplyDelete
        8. Hi is very good work! i buy more object for this project. but on my boat the diameter of tube is 8 mm and sensor use only 6 mm! problem? thank you
          ps how is possible to download the app!?!? thank u

          ReplyDelete
          Replies
          1. App Link: https://drive.google.com/file/d/0BxCLDhLwTh8HRWNmTnBmV2R2Nmc/view?usp=sharing

            Is your tube 8mm inner Diameter?

            Delete
        9. Hello,
          What is wrong, I'm not able to see some pictures from your project like this one : http://i942.photobucket.com/albums/ad264/MaleBuffy/_MG_5565_zpsb08a6923.jpg.
          Is there a way to see or obtain all pictures because it's more easy to understand.
          Many thanks and congratulations for such interesting project.
          Rob

          ReplyDelete
          Replies
          1. Photobucket turned from free to paid. I have trouble downloading files. They are working on it. In the mean time I am stuck.

            Delete
          2. I think they aren't working on it....:-)

            Delete
        10. Hi,
          Awesome project!
          I'm thinking about copy your project but i wonder if you can send me The pics from your guide, that would be amazing! Fredricklarsson2@gmail.com

          Have a Great day!

          ReplyDelete