Saturday, 28 April 2018

Smart fuel measurement using arduino uno


The fuel gauge in every bike has the resistance as output,

the variable resistance is connect as pull up and the 1 k resistor is connected as pull down

the variable resistance which is connected to the 1 k resistor is connected  to the A0  pin of  arduino






int analogPin = 0;
int raw = 0;
int Vin = 5;
float Vout = 0;
float value;
float per;
float km;
float pet;
float R1 = 1000;
float R2 = 0;
float buffer = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  raw = analogRead(analogPin);
  if (raw)
  {
    buffer = raw * Vin;
    Vout = (buffer) / 1024.0;
    buffer = (Vin / Vout) - 1;
    R2 = R1 * buffer;
    Serial.print("Vout: ");
    Serial.println(Vout);
    Serial.print("R2: ");
    Serial.println(R2);
    value = 154.5 - R2; ////////////////varies depending upon the bike
    Serial.print("Resistance: ");
    Serial.println(value);
    per = (value / 120) * 100; ////////////////varies depending upon the bike
    Serial.print("Petrol %: ");
    Serial.println(per);
    pet = 0.115384 * per; ////////////////varies depending upon the bike
    Serial.print("Petrol in liters:");
    Serial.println(pet);
    km = 40 * pet; ////////////////varies depending upon the bike
    Serial.print("Kilometers Available:");
    Serial.println(km);
    Serial.println("");
    delay(2000);
  }
}

No comments:

Post a Comment

Own IOT website and Hardware Using Node MCU (cyber thinks)

NODE MCU code -- website link  Cyberthinks google drive link  cyberthinks website files #include <ESP8266WiFi.h> #include <ArduinoJ...