RFID Based LIQUID Vending Machine
Defined amount of liquid dispense after RFID authentication form Vending machine.
Components and supplies
1
Alphanumeric LCD, 16 x 2
1
12V DC 1/2″ Electric Solenoid Water Air Valve Switch (Normally Closed)
1
Flow Sensor, Analog Output
1
Test Accessory, AC Power Adaptor
1
Arduino UNO
1
Signal Relay, 5 VDC
Apps and platforms
1
Arduino IDE
Project description
Code
code
c_cpp
1#include <LiquidCrystal.h> 2LiquidCrystal lcd(4, 5, 6, 7, 8, 9); //(RS, EN, D4, D5, D6, D7) 3 4//you can add multiple tags no. 5String tag1 = "430077CECB31"; //you can change tag no. 6String tag2 = "3B004D93C025"; 7 8byte statusLed = 13; 9byte sensorInterrupt = 0; // 0 = digital pin 2 10byte sensorPin = 2; 11 12int tap = 3; //relay is connected which triger solenoid 13 14float calibrationFactor = 4.5; 15 16volatile byte pulseCount; 17 18float flowRate; 19unsigned int flowMilliLitres; 20unsigned long totalMilliLitres; 21unsigned long quantity = 1000; //1000ml-you can change as per your requirment 22unsigned long flow_reading = 0; 23unsigned long oldTime; 24 25void setup() 26{ 27 28 Serial.begin(9600); 29 lcd.begin(16, 2); 30 lcd.setCursor(5, 0); 31 lcd.print("welcome"); 32 lcd.setCursor(0, 1); 33 lcd.print("swipe tag"); 34 35 pinMode(statusLed, OUTPUT); 36 pinMode(tap, OUTPUT); 37 digitalWrite(statusLed, HIGH); 38 Serial.println("cheked"); 39 while (!Serial.available()) { 40 delay(1000); 41 } 42 43 digitalWrite(tap, HIGH); 44 pinMode(sensorPin, INPUT); 45 digitalWrite(sensorPin, HIGH); 46 47 pulseCount = 0; 48 flowRate = 0.0; 49 flowMilliLitres = 0; 50 totalMilliLitres = 0; 51 oldTime = 0; 52 attachInterrupt(sensorInterrupt, pulseCounter, FALLING); 53} 54void loop() 55{ 56 Serial.print("hi"); 57 String tagdata = Serial.readString(); 58 if (tagdata == tag1) //person1 tag match if match he/she will get 1litre of liquid 59 { 60 lcd.clear(); 61 lcd.setCursor(2, 0); 62 lcd.print("put pot"); 63 lcd.setCursor(4, 1); 64 lcd.print("person1"); 65 digitalWrite(tap, 1); 66 Serial.print("ok"); 67 while (flow_reading < quantity) { 68 flow_reading = getFlowData(); 69 lcd.clear(); 70 lcd.setCursor(0, 0); 71 lcd.print("Flow Amount "); 72 lcd.setCursor(0, 1); 73 lcd.print(flow_reading); 74 75 delay(1000); 76 77 } 78 79 //solenoid to close via relay 80 digitalWrite(tap, LOW); 81 82 } 83 84 else if (tagdata == tag2) //person2 tag match if match he/she will get 1litre of liquid 85 { 86 lcd.clear(); 87 lcd.setCursor(0, 0); 88 lcd.print("put pot"); 89 lcd.setCursor(0, 1); 90 lcd.print("person 2"); 91 digitalWrite(tap, 1); 92 while (flow_reading < quantity) { 93 flow_reading = getFlowData(); 94 lcd.clear(); 95 lcd.setCursor(0, 0); 96 lcd.print("Flow Amount "); 97 lcd.setCursor(0, 1); 98 lcd.print(flow_reading); 99 100 delay(1000); 101 102 } 103 104 //solenoid to close via relay 105 digitalWrite(tap, LOW); 106 lcd.clear(); 107 lcd.setCursor(0, 0); 108 lcd.print("Remove Pot"); 109 } 110} 111unsigned long getFlowData() { 112 113 detachInterrupt(sensorInterrupt); 114 115 flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor; 116 117 oldTime = millis(); 118 119 flowMilliLitres = (flowRate / 60) * 1000; 120 totalMilliLitres += flowMilliLitres; 121 122 unsigned int frac; 123 124 125 pulseCount = 0; 126 attachInterrupt(sensorInterrupt, pulseCounter, FALLING); 127 128 return totalMilliLitres; 129 130} 131 132void pulseCounter() 133{ 134 // Increment the pulse counter 135 pulseCount++; 136}
code
c_cpp
1#include <LiquidCrystal.h> 2LiquidCrystal lcd(4, 5, 6, 7, 8, 9); //(RS, 3 EN, D4, D5, D6, D7) 4 5//you can add multiple tags no. 6String tag1 = "430077CECB31"; 7 //you can change tag no. 8String tag2 = "3B004D93C025"; 9 10byte statusLed 11 = 13; 12byte sensorInterrupt = 0; // 0 = digital pin 2 13byte sensorPin = 14 2; 15 16int tap = 3; //relay is connected which triger solenoid 17 18float calibrationFactor 19 = 4.5; 20 21volatile byte pulseCount; 22 23float flowRate; 24unsigned int flowMilliLitres; 25unsigned 26 long totalMilliLitres; 27unsigned long quantity = 1000; //1000ml-you can change 28 as per your requirment 29unsigned long flow_reading = 0; 30unsigned long oldTime; 31 32void 33 setup() 34{ 35 36 Serial.begin(9600); 37 lcd.begin(16, 2); 38 lcd.setCursor(5, 39 0); 40 lcd.print("welcome"); 41 lcd.setCursor(0, 1); 42 lcd.print("swipe 43 tag"); 44 45 pinMode(statusLed, OUTPUT); 46 pinMode(tap, OUTPUT); 47 digitalWrite(statusLed, 48 HIGH); 49 Serial.println("cheked"); 50 while (!Serial.available()) { 51 delay(1000); 52 53 } 54 55 digitalWrite(tap, HIGH); 56 pinMode(sensorPin, INPUT); 57 digitalWrite(sensorPin, 58 HIGH); 59 60 pulseCount = 0; 61 flowRate = 0.0; 62 flowMilliLitres 63 = 0; 64 totalMilliLitres = 0; 65 oldTime = 0; 66 attachInterrupt(sensorInterrupt, 67 pulseCounter, FALLING); 68} 69void loop() 70{ 71 Serial.print("hi"); 72 73 String tagdata = Serial.readString(); 74 if (tagdata == tag1) //person1 tag 75 match if match he/she will get 1litre of liquid 76 { 77 lcd.clear(); 78 lcd.setCursor(2, 79 0); 80 lcd.print("put pot"); 81 lcd.setCursor(4, 1); 82 lcd.print("person1"); 83 84 digitalWrite(tap, 1); 85 Serial.print("ok"); 86 while (flow_reading 87 < quantity) { 88 flow_reading = getFlowData(); 89 lcd.clear(); 90 lcd.setCursor(0, 91 0); 92 lcd.print("Flow Amount "); 93 lcd.setCursor(0, 1); 94 lcd.print(flow_reading); 95 96 97 delay(1000); 98 99 } 100 101 //solenoid to close via relay 102 digitalWrite(tap, 103 LOW); 104 105 } 106 107 else if (tagdata == tag2) //person2 tag match if match 108 he/she will get 1litre of liquid 109 { 110 lcd.clear(); 111 lcd.setCursor(0, 112 0); 113 lcd.print("put pot"); 114 lcd.setCursor(0, 1); 115 lcd.print("person 116 2"); 117 digitalWrite(tap, 1); 118 while (flow_reading < quantity) { 119 120 flow_reading = getFlowData(); 121 lcd.clear(); 122 lcd.setCursor(0, 123 0); 124 lcd.print("Flow Amount "); 125 lcd.setCursor(0, 1); 126 lcd.print(flow_reading); 127 128 129 delay(1000); 130 131 } 132 133 //solenoid to close via relay 134 digitalWrite(tap, 135 LOW); 136 lcd.clear(); 137 lcd.setCursor(0, 0); 138 lcd.print("Remove 139 Pot"); 140 } 141} 142unsigned long getFlowData() { 143 144 detachInterrupt(sensorInterrupt); 145 146 147 flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor; 148 149 150 oldTime = millis(); 151 152 flowMilliLitres = (flowRate / 60) * 1000; 153 totalMilliLitres 154 += flowMilliLitres; 155 156 unsigned int frac; 157 158 159 pulseCount = 0; 160 161 attachInterrupt(sensorInterrupt, pulseCounter, FALLING); 162 163 return totalMilliLitres; 164 165} 166 167void 168 pulseCounter() 169{ 170 // Increment the pulse counter 171 pulseCount++; 172}
Downloadable files
ciircuit_th3lGVClSM.png
ciircuit_th3lGVClSM.png

ciircuit_th3lGVClSM.png
ciircuit_th3lGVClSM.png

Comments
Only logged in users can leave comments