Sagarraj1
Published

RFID Based LIQUID Vending Machine

Defined amount of liquid dispense after RFID authentication form Vending machine.

IntermediateFull instructions provided4,407
RFID Based LIQUID Vending Machine

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Flow Sensor, Analog Output
Flow Sensor, Analog Output
×1
12V DC 1/2″ Electric Solenoid Water Air Valve Switch (Normally Closed)
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1
Signal Relay, 5 VDC
Signal Relay, 5 VDC
×1
Test Accessory, AC Power Adaptor
Test Accessory, AC Power Adaptor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

ciircuit_th3lGVClSM.png

Code

code

C/C++
#include <LiquidCrystal.h>
LiquidCrystal lcd(4, 5, 6, 7, 8, 9); //(RS, EN, D4, D5, D6, D7)

//you can add multiple tags no.
String tag1 = "430077CECB31"; //you can change tag no.
String tag2 = "3B004D93C025";

byte statusLed    = 13;
byte sensorInterrupt = 0;  // 0 = digital pin 2
byte sensorPin       = 2;

int tap = 3; //relay is connected which triger solenoid

float calibrationFactor = 4.5;

volatile byte pulseCount;

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long quantity = 1000; //1000ml-you can change as per your requirment
unsigned long flow_reading = 0;
unsigned long oldTime;

void setup()
{

  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.setCursor(5, 0);
  lcd.print("welcome");
  lcd.setCursor(0, 1);
  lcd.print("swipe tag");

  pinMode(statusLed, OUTPUT);
  pinMode(tap, OUTPUT);
  digitalWrite(statusLed, HIGH);
  Serial.println("cheked");
  while (!Serial.available()) {
    delay(1000);
  }

  digitalWrite(tap, HIGH);
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop()
{
  Serial.print("hi");
  String tagdata = Serial.readString();
  if (tagdata == tag1) //person1 tag match if match he/she will get 1litre of liquid
  {
    lcd.clear();
    lcd.setCursor(2, 0);
    lcd.print("put pot");
    lcd.setCursor(4, 1);
    lcd.print("person1");
    digitalWrite(tap, 1);
    Serial.print("ok");
    while (flow_reading < quantity) {
      flow_reading = getFlowData();
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Flow Amount ");
      lcd.setCursor(0, 1);
      lcd.print(flow_reading);

      delay(1000);

    }

    //solenoid  to close via relay
    digitalWrite(tap, LOW);

  }

  else if (tagdata == tag2) //person2 tag match if match he/she will get 1litre of liquid
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("put pot");
    lcd.setCursor(0, 1);
    lcd.print("person 2");
    digitalWrite(tap, 1);
    while (flow_reading < quantity) {
      flow_reading = getFlowData();
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Flow Amount ");
      lcd.setCursor(0, 1);
      lcd.print(flow_reading);

      delay(1000);

    }

    //solenoid  to close via relay
    digitalWrite(tap, LOW);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Remove Pot");
  }
}
unsigned long getFlowData() {

  detachInterrupt(sensorInterrupt);

  flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;

  oldTime = millis();

  flowMilliLitres = (flowRate / 60) * 1000;
  totalMilliLitres += flowMilliLitres;

  unsigned int frac;


  pulseCount = 0;
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

  return totalMilliLitres;

}

void pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

Arduino

Credits

Sagarraj1
1 project • 2 followers

Comments