Overview

We have all waited in line for payment in shopping malls and other places, it is very exhausting and a lot of time is wasted in the billing process. Today we will create a smart shopping cart with an automatic checkout system that reduces waiting time and makes the process very smooth and easy.

Here we use RFID cards and RFID readers with Arduino to build the Smart Shopping Cart project. The cart information and the total value will be displayed on the web page and on the LCD screen.

Components required table

S.NoCOMPONENTSDESCRIPTIONQUANTITYlink
1ArduinoArduino Uno1Arduino Uno
2Em-18 Rfid ModuleEM-18 RFID Reader – TTL1Em-18 Rfid Module
316×2 Lcd DisplayCD 16×2 Alphanumeric Display116×2 Lcd Display
4connection wiresJumper Wires40Jumper Wires

EM18 RFID Reader and its Working

RFID stands for Radio Frequency Identification. It refers to a technology in which digital data is encoded on RFID tags and decoded by an RFID reader using radio waves. RFID is similar to a barcode in that data on a label is decoded by an RFID reader. RFID technology is used in various applications such as inventory management, attendance system, door locking system, access to restricted areas, etc.

EM18 Reader is a very popular RFID module that can read the identification information stored in RFID tags. RFID tags store a unique 12-digit number that can be decoded by an EM18 reader module when the tag comes into range of the Reader. This module has a built-in antenna that operates at a frequency of 125kHz and a 5v DC power supply is required to power it up.

It gives a serial data output and has a range of 8-12 cm. The serial communication parameters are 8 data bits, 1 stop bit, and 9600 baud.

EM18 RFID Reader Features:

  • Operating voltage: +4.5V to +5.5V DC
  • Current consumption:50mA
  • Operating frequency:125KHZ
  • Operating temperature: 0-80 degrees C
  • Communication Baud Rate:9600
  • Reading distance: 8-12 cm
  • Antenna: Inbuilt

EM18 RFID Reader Pinout:

EM18 RFID Reader Pin description:

VCC: 4.5- 5V DC voltage input

GND: Ground pin

Buzzer: Buzzer or LED pin

TX: Serial data Transmitter pin of EM18 for RS232 (Output)

SEL: This must be HIGH for using RS232 (LOW if using WEIGAND)

Data 0: WEIGAND data 0

Data 1: WEIGAND data 1

Find out a Unique 12 digit Code for RFID Tag

Before programming the NodeMCU for the smart shopping cart project, we must first find out the unique code of the 12-digit RFID tag. As discussed above, RFID tags contain a unique 12-digit code and can be decoded through the use of an RFID reader. When the RFID card is swiped close to the Reader, the Reader will provide the unique codes through the output serial port when connected to NodeMCU. First, connect the NodeMCU to the RFID reader according to the circuit diagram, and then upload the code below to the NodeMCU.

After successfully uploading the code, open the serial monitor and set the baud rate to 9600. Then swipe the card close to the reader, and now you can see the 12-digit code on the serial monitor, as shown in the picture next. Do this process for all used RFID tags and write it down for future reference.

int count = 0;
char card_no[12];
void setup()
{
   Serial.begin(9600);
}

void loop()
{
   if(Serial.available())
   {
      count = 0;
      while(Serial.available() && count < 12)
      {
         card_no[count] = Serial.read();
         count++;
         delay(5);
      }
      Serial.print(card_no);
   }
}

Final Code

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

#include <string.h>
#define rxPin 8
#define txPin 9
SoftwareSerial RFID( rxPin, txPin );
// Set up outputs
#define ledPin 13
int i,j=0,k=0,l=0,total=0;
char s1[12] = "2100209E3DA2";
char s2[12] = "2000F587E0B2";
char s3[12] = "2000F5B28FE8";

int vaseline_cream=100,five_star_chocolate=50,Ice_cream=200;
String buf1;//stringTwo;

const int sw1= 7;
int button1;


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(14, 15, 16, 17, 18, 19);

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(sw1, INPUT);
digitalWrite(ledPin, LOW);

Serial.begin(9600); // Serial port for connection to host
RFID.begin(9600); // Serial port for connection to RFID module
Serial.println("RFID Reader Initialized");
lcd.begin(16, 4);
  // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print("Welcome Supper Markt");
  
  //lcd.print("  ");
  Serial.println("Welcome supper market ");
  //delay(2000);
  Serial.println("pick you are requide products  ");

}


void loop() {

  button1 = digitalRead(sw1);
  //Serial.println("pick you are requide products  ");
  if(button1 == LOW)
  {
   //Serial.println("pick you are requide products  ");
  if(RFID.available())
  {
     //Serial.println("pick you are requide products  ");
    delay(100);
    buf1 = String(RFID.readString());
    Serial.println(buf1);
    for(i=0;i<12;i++)
    {
     //Serial.println("pick you are requide products  "); 
      if(buf1[i]==s1[i])j++;if(buf1[i]==s2[i])k++;if(buf1[i]==s3[i])l++;
      delay(5);
    }
    if((j>0)&&(j<9))j=0;if((k>0)&&(k<9))k=0;if((l>0)&&(l<9))l=0;
   //Serial.println("pick you are requide products  ");
    if(j>=11)
    {
  
      j++;
      total+= vaseline_cream;
      lcd.setCursor(0, 1);
      lcd.print("vaseline_cream = ");lcd.print(vaseline_cream);
      
      lcd.setCursor(4, 2);
      lcd.print("total          = ");lcd.print(total);
      lcd.setCursor(4, 3);
      lcd.print("Thankq  ....... ");



      Serial.print("vaseline_cream = ");Serial.print(vaseline_cream);
      Serial.println("   ");
      Serial.print("total  = ");Serial.print(total);
      Serial.println("   ");
      Serial.println("Thankq  ....... ");

      

      j=0;
    }
    if(k>=11)
    {
//list();
      k++;
    total+=five_star_chocolate;
    
      lcd.setCursor(0, 1);
      lcd.print("five_star     =   ");lcd.print(five_star_chocolate);
      
      lcd.setCursor(4, 2);
      lcd.print("total         =  ");lcd.print(total);
      lcd.setCursor(4, 3);
      lcd.print("Thankq  ....... ");



      Serial.print("five_star_chocolate = ");Serial.print(five_star_chocolate);
      Serial.println("   ");
      Serial.print("total  = ");Serial.print(total);
      Serial.println("   ");
      Serial.println("Thankq  ....... ");
      k=0;
    }
    if(l>=11)
    {
      //list();
    l++;
    total+=Ice_cream;
    
      lcd.setCursor(0, 1);
      lcd.print("Ice_cream    =   ");lcd.print(Ice_cream);
      
      lcd.setCursor(4, 2);
      lcd.print("total        =   ");lcd.print(total);
      lcd.setCursor(4, 3);
      lcd.print("Thankq  ....... ");



      Serial.print("Ice_cream = ");Serial.print(Ice_cream);
      Serial.println("   ");
      Serial.print("total  = ");Serial.print(total);
      Serial.println("   ");
      Serial.println("Thankq  ....... ");
     l=0;
    }
    
  }
  
  }

      if(button1 == HIGH)
  {
  if(RFID.available())
  {
    delay(100);
    buf1 = String(RFID.readString());
    Serial.println(buf1);
    for(i=0;i<12;i++)
    {
      if(buf1[i]==s1[i])j++;if(buf1[i]==s2[i])k++;if(buf1[i]==s3[i])l++;
      delay(5);
    }
    if((j>0)&&(j<9))j=0;if((k>0)&&(k<9))k=0;if((l>0)&&(l<9))l=0;
    
    if(j>=11)
    {
  //    list();
      j--;
      total-= vaseline_cream;
      lcd.setCursor(0, 1);
      lcd.print("vaseline rmd  =  ");lcd.print(vaseline_cream);
      
      lcd.setCursor(4, 2);
      lcd.print("total         =  ");lcd.print(total);
      lcd.setCursor(4, 3);
      lcd.print("Thankq  ....... ");



      Serial.print("vaseline_cream     =   ");Serial.print(vaseline_cream);
      Serial.println("   ");
      Serial.print("total  = ");Serial.print(total);
      Serial.println("   ");
      Serial.println("Thankq  ....... ");


      j=0;
    }
    if(k>=11)
    {
//list();
      k--;
    total-= five_star_chocolate;
    
     lcd.setCursor(0, 1);
      lcd.print("five star rmd =   ");lcd.print(five_star_chocolate);
      
      lcd.setCursor(4, 2);
      lcd.print("total           =");lcd.print(total);
      lcd.setCursor(4, 3);
      lcd.print("Thankq  ....... ");
      Serial.print("five_star_chocolate = ");Serial.print(five_star_chocolate);
      Serial.println("   ");
      Serial.print("total   = ");Serial.print(total);
      Serial.println("   ");
      Serial.println("Thankq  ....... ");

      k=0;
    }
    if(l>=11)
    {
      //list();
    l--;
    total-=Ice_cream;
    
      lcd.setCursor(0, 1);
      lcd.print("Ice_crm_rmd   =  ");lcd.print(Ice_cream);
      
      lcd.setCursor(4, 2);
      lcd.print("total          = ");lcd.print(total);
      lcd.setCursor(4, 3);
      lcd.print("Thankq  ....... ");

      Serial.print("Ice_cream = ");Serial.print(Ice_cream);
      Serial.println("   ");
      Serial.print("total  = ");Serial.print(total);
      Serial.println("   ");
      Serial.println("Thankq  ....... ");

      
     l=0;
    }
    
  }
  
  }
  
}

By Admin

Leave a Reply

Your email address will not be published.

%d bloggers like this: