Arduino UNO-Based RFID Inventory System with Coin Dispenser and LCD Display
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to interface an Arduino UNO with multiple RFID-RC522 modules, a 20x4 I2C LCD, a coin hopper, and a buck converter powered by a 12V 200Ah battery. The Arduino UNO reads RFID tags, updates the LCD display, and controls the coin hopper to dispense coins based on the detected RFID tags.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
RFID-RC522
- Description: A low-cost RFID reader module.
- Pins: SDA, SCK, MOSI, MISO, IRQ, GND, RST, 3.3V
Buck Converter
- Description: A DC-DC converter that steps down voltage.
- Pins: IN+, IN-, OUT+, OUT-
12V 200Ah Battery
- Description: A high-capacity battery for powering the circuit.
- Pins: GND, 12V
LCD 20x4 I2C
- Description: A 20x4 character LCD with I2C interface.
- Pins: GND, 5V, SCA, SCL
Coin Hopper
- Description: A device for dispensing coins.
- Pins: VCC, SIGNAL, GND, P, N
Wiring Details
Arduino UNO
- 3.3V: Connected to 3.3V pins of all RFID-RC522 modules.
- 5V: Connected to 5V pin of the LCD 20x4 I2C, Coin Hopper, and Buck Converter OUT+.
- GND: Connected to GND pins of all RFID-RC522 modules, LCD 20x4 I2C, Coin Hopper, and Buck Converter OUT-.
- A4: Connected to SCA pin of the LCD 20x4 I2C.
- A5: Connected to SCL pin of the LCD 20x4 I2C.
- D13: Connected to SCK pins of all RFID-RC522 modules.
- D12: Connected to MISO pins of all RFID-RC522 modules.
- D11: Connected to MOSI pins of all RFID-RC522 modules.
- D10: Connected to SDA pin of one RFID-RC522 module.
- D9: Connected to SDA pin of another RFID-RC522 module.
- D8: Connected to SDA pin of the third RFID-RC522 module.
- D7: Connected to RST pin of one RFID-RC522 module.
- D6: Connected to RST pin of another RFID-RC522 module.
- D5: Connected to RST pin of the third RFID-RC522 module.
- D4: Connected to SIGNAL pin of the Coin Hopper.
RFID-RC522
- 3.3V: Connected to 3.3V pin of the Arduino UNO.
- GND: Connected to GND pin of the Arduino UNO.
- SCK: Connected to D13 pin of the Arduino UNO.
- MISO: Connected to D12 pin of the Arduino UNO.
- MOSI: Connected to D11 pin of the Arduino UNO.
- SDA: Connected to D10, D9, and D8 pins of the Arduino UNO (one for each module).
- RST: Connected to D7, D6, and D5 pins of the Arduino UNO (one for each module).
Buck Converter
- IN+: Connected to 12V pin of the 12V 200Ah Battery.
- IN-: Connected to GND pin of the 12V 200Ah Battery.
- OUT+: Connected to 5V pin of the Arduino UNO.
- OUT-: Connected to GND pin of the Arduino UNO.
12V 200Ah Battery
- 12V: Connected to IN+ pin of the Buck Converter.
- GND: Connected to IN- pin of the Buck Converter.
LCD 20x4 I2C
- 5V: Connected to 5V pin of the Arduino UNO.
- GND: Connected to GND pin of the Arduino UNO.
- SCA: Connected to A4 pin of the Arduino UNO.
- SCL: Connected to A5 pin of the Arduino UNO.
Coin Hopper
- VCC: Connected to 5V pin of the Arduino UNO.
- GND: Connected to GND pin of the Arduino UNO.
- SIGNAL: Connected to D4 pin of the Arduino UNO.
Code Documentation
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <MFRC522.h>
#define RST_PIN_1 7
#define SS_PIN_1 10
#define RST_PIN_2 6
#define SS_PIN_2 9
#define RST_PIN_3 5
#define SS_PIN_3 8
#define COIN_HOPPER_PIN 4
LiquidCrystal_I2C lcd(0x27, 20, 4);
MFRC522 rfid1(SS_PIN_1, RST_PIN_1);
MFRC522 rfid2(SS_PIN_2, RST_PIN_2);
MFRC522 rfid3(SS_PIN_3, RST_PIN_3);
int plates = 0;
int spoons = 0;
int forks = 0;
int glasses = 0;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid1.PCD_Init();
rfid2.PCD_Init();
rfid3.PCD_Init();
lcd.begin();
lcd.backlight();
pinMode(COIN_HOPPER_PIN, OUTPUT);
digitalWrite(COIN_HOPPER_PIN, LOW);
}
void loop() {
if (detectRFID(rfid1)) {
plates++;
dispenseCoin();
updateLCD("Plates", plates);
}
if (detectRFID(rfid2)) {
spoons++;
forks++;
dispenseCoin();
updateLCD("Spoons and Forks", spoons, forks);
}
if (detectRFID(rfid3)) {
glasses++;
dispenseCoin();
updateLCD("Glasses", glasses);
}
delay(1000);
}
bool detectRFID(MFRC522 &rfid) {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return false;
}
rfid.PICC_HaltA();
return true;
}
void dispenseCoin() {
digitalWrite(COIN_HOPPER_PIN, HIGH);
delay(1000); // Adjust the delay as needed to dispense one coin
digitalWrite(COIN_HOPPER_PIN, LOW);
}
void updateLCD(String utensil, int count) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(utensil + ": ");
lcd.print(count);
if (count >= 10) {
lcd.setCursor(0, 1);
lcd.print("Compartment Full");
}
}
void updateLCD(String utensil1, int count1, String utensil2, int count2) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(utensil1 + ": ");
lcd.print(count1);
lcd.setCursor(0, 1);
lcd.print(utensil2 + ": ");
lcd.print(count2);
if (count1 >= 10 || count2 >= 10) {
lcd.setCursor(0, 2);
lcd.print("Compartment Full");
}
}
This code initializes the RFID readers, LCD, and coin hopper. It continuously checks for RFID tags, updates the count of detected items, displays the count on the LCD, and dispenses a coin for each detected item.