DEEPAK AGARWAL 1560450GEET JETHWANI 1560508Geet ji
Published © GPL3+

Carousel Trackers Using RFID

This project aims to replace traditional bar code scanners with RFID sensors and implementing a graphical interface to make things easier.

IntermediateFull instructions provided14 days586
Carousel Trackers Using RFID

Things used in this project

Hardware components

WIZwiki-W7500
WIZnet WIZwiki-W7500
×1
WIZ750SR
WIZnet WIZ750SR
×1
WIZ750SR-TTL-EVB Kit
WIZnet WIZ750SR-TTL-EVB Kit
×1
RFID reader (generic)
×1
RFID Module (Generic)
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
TP-Link TL-WR841N 300Mbps Wireless-N Router
×1
RJ45 Patch Cord CAT5 Ethernet LAN Network Patch Cable
×1

Software apps and online services

ThingSpeak API
ThingSpeak API
MQTT
MQTT
Mbed Compiler
PostgreSQL Database

Story

Read more

Schematics

Circuit Diagram for WizWiki-W7500, RFID readers, WIZ750SR

Code

Code for RFID tags

C/C++
This code is for detecting the carousels with RFID tags and if any misplacing happens it will inform the authorities. It sends the read data serially to WIZ750SR. This code can be run on https://os.mbed.com
#include "mbed.h"
#include "MFRC522.h"
#define MF_RESET    D8
static int count=0,count1=0;
Serial pc(USBTX,USBRX);
Serial device(D1,D0);
MFRC522    RfChip   (D11, D12, D13, D10, D9);

int main(void) {
  pc.printf("starting...\n");
 pc.baud(115200);
  RfChip.PCD_Init();
 
  while (true) {
   
    if ( ! RfChip.PICC_IsNewCardPresent())
    {
      wait_ms(500);
      continue;
    }
    
    if ( ! RfChip.PICC_ReadCardSerial())
    {
      wait_ms(500);
      continue;
    }

    pc.printf("Card UID: ");
    for (uint8_t i = 0; i < RfChip.uid.size; i++)
    {
      pc.printf(" %d", RfChip.uid.uidByte[i]);
    }
    pc.printf("\n\r");
    
    uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
    pc.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
    if(RfChip.uid.uidByte[0]==97 || RfChip.uid.uidByte[1]==102 || RfChip.uid.uidByte[2]== 176 || RfChip.uid.uidByte[3]== 171)
    {
        count=1000;
        count1=905;
    }
    else if(RfChip.uid.uidByte[0]==0 || RfChip.uid.uidByte[1]==235 || RfChip.uid.uidByte[2]== 240 || RfChip.uid.uidByte[3]== 176)
    {
        count=2000;  
        count1=910;     
    }
    pc.printf("count_value is =%d  \n",count1);
    device.putc(count);
    //count=count+10;
    wait_ms(1000);
    
    
    //RfChip.PCD_WriteRegister();
    }
    }
    
    
    
 

Code for WIZ750SR

C/C++
Takes the serial input from RFID taps on WizWiki-W7500 and sends the ouput to the ThingSpeak cloud. It can be run on https://os.mbed.com
#include "mbed.h"
#include "EthernetInterface.h"
#include "Adafruit_SSD1306.h"
#include "HTTPClient.h"
#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x53, 0xAE, 0x90};
#endif
// W7500 onboard LED & Init
DigitalOut rled(LED1,1);
DigitalOut gled(LED2,0);
DigitalOut bled(LED3,1);

// I2C Class
I2C i2c(PA_10,PA_9);

// OLED Class   
Adafruit_SSD1306_I2c gOled(i2c,NC,0x78,64,128);

Serial pc(USBTX, USBRX);
Serial device(D1,D0);
EthernetInterface eth;

// Declare TCP Connection Class
TCPSocketConnection sock;

DigitalOut myled(D1);



int main() {
   
pc.baud(115200);
    int received_data=0;
    printf("Wait a second...\r\n");

   eth.init(mac_addr);     //Use DHCP
eth.connect();
    
      printf("IP Address is %s\r\n\r\n", eth.getIPAddress());
        printf("MASK Address is %s\r\n\r\n", eth.getNetworkMask());
        printf("GATEWAY Address is %s\r\n\r\n", eth.getGateway());
        printf("MAC Address is %s\r\n\r\n", eth.getMACAddress());
    char str[512];
    char msg[128]= "";
   // char nameYouWant[] = "dpaknov20";
         while(1){
             
        while(pc.readable()) 
        {
            device.putc(pc.getc());
        }
        while(device.readable())
        {
            if(device.readable()) 
            {
                received_data = device.getc();
                printf("received_data = %d", received_data);
            }
        }
        // TCP socket connect to openweather server 
        //TCPSocketConnection sock;
        //char send_data[1024];
        received_data = device.getc();
        if(received_data==232)
        {
            received_data=905;
            }
            else {
                received_data=910;
                }
        pc.printf("received_data = %d\n", received_data);
        /*char *p="api.thingspeak.com";
           int a=sock.connect(p,80);
          while(1){
                if(a!=0) {
                    printf("\r\n could not connect to socket : error = %d\r\n", p);
                    
                    a = sock.connect(p, 80);
                } else {
                    printf("socket connected\r\n");
                                break;
                }
             } 
        //sock.connect("api.thingspeak.com", 80);
        sprintf((char *)send_data,"GET /update?api_key=GR1IFBYTK5NKNIV6&field1=%d HTTP 1.0\n\n",received_data); 
           
        sock.send_all(send_data, sizeof(send_data));
        char buffer[2048];
        int ret;
        while (true) {
            ret = sock.receive_all(buffer, sizeof(buffer));
            if (ret <= 0)
                break;
            buffer[ret] = '\0';
            printf("Received %d chars from server: %s\n", ret, buffer);     
        }*/
        printf("\r\n\r\n");
        sprintf(msg,"https://api.thingspeak.com/update?api_key=GR1IFBYTK5NKNIV6&field1=%d",received_data);
        HTTPClient http;
        
        pc.printf("Send post message to thingspeak\r\n");
        pc.printf("msg : %s\r\n",msg);
       int ret = http.get(msg, str, sizeof(str));
        if(!ret)
        {
          pc.printf("\r\nPage fetched successfully - read %d characters\r\n", strlen(str));
          pc.printf("Result: %s\r\n", str);
        }
        else
        {
          pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
        }
    }

}

Sample code for Carousel Tracking Website

JavaScript
This code is written in node.js and it gives the details and the current status of where the baggage is.
app.get('/customer/:bookingid', function (req, res) {
  pool.query('SELECT * FROM customer WHERE tagid = ($1)', [req.session.auth.tagid], function (err, result) {
    if (err) {
        res.status(500).send(err.toString());
    } else {
        if (result.rows.length === 0) {
            res.status(404).send('customer tagid_id not found');
        } else {
            var custData = result.rows[0];
            res.send(makeTemplate(custData));
        }
    }
  });
});

app.get('/customer/baggage/:tagid', function (req, res) {
  pool.query('SELECT * FROM customer_tags WHERE tagid = ($1)', [req.session.auth.tagid], function (err, result) {
    if (err) {
        res.status(500).send(err.toString());
    } else {
        if (result.rows.length === 0) {
            res.status(404).send('customer tagid_id not found');
        } else {
            var metdata=result.rows[0];
            res.send(statusTemplate(metdata));
        }
    }
  });
});

function statusTemplate(statusdata) {
    var tagid=statusdata.tagid;
    var stat1=statusdata.status1;
    var stat2=statusdata.status2;
    var stat3=statusdata.status3;
        var statTemplate = `
        <!DOCTYPE html>
        <html>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="ui/style2.css">
        <body>
        
        <div class="w3-container w3-orange">
          <h2>This is the baggage status page!</h2>      
          <p>Baggage Tag ID :- ${tagid}</p>      
        </div>
        
        <div class="w3-row-padding">
        
        <div class="w3-third">
          <h2>Status-1</h2>
          <p>${stat1}</p>
        </div>
        
        <div class="w3-third">
          <h2>Status-2</h2>
          <p>${stat2}</p>
        </div>
        
        <div class="w3-third">
          <h2>Status-3</h2>
          <p>${stat3}</p>
        </div>
        <a href="/myapp"><button>HOME</button></a>
        <a href="/myapp/logout"><button>LOGOUT</button></a>
        </div>
        
        </body>
        </html>`
        ;
        return statTemplate;
}

function makeTemplate(data) {
    var name=data.name;
    var email=data.email;
    var contact=data.contact;
    var flight=data.flight;
    var fromcity=data.fromcity;
    var tocity=data.tocity;
    var date=data.date;
    var booking=data.booking;
    var pnr=data.pnr;
    var tagid=data.tagid;
    var fcitylink=data.fcitylink;
    var tcitylink=data.tcitylink;
        var bookTemplate = `
        <html>
            <head>  
                <title>
                    ${name}
                </title>
               
            </head>
            <body>
                <div align="center" style="padding-top : 5">
                <div style="position: relative;">
                    <div style="position: absolute; top: 0; right: 0; padding-top: 10; padding-right: 10">
                        ${fcitylink}
                            <h4>DEPARTURE AIRPORT</h4>
                         ${tcitylink}
                            <h4>ARRIVAL AIRPORT</h4>   
                    </div>
                </div>
                <h1>Passenger Details</h1>
                    <h3>BOOKING ID : </h3>
                    <p>${booking}<p>
                    <h3>PNR NO. : </h3>
                    <p>${pnr}<p>
                    <h3>TAG ID : </h3>
                    <p>${tagid}<p>
                    <h3>Passenger Name : </h3>
                    <p>${name}<p>
                    <h3>Passenger Contact : </h3>
                    <p>${contact}<p>
                    <h3>Flight no. : </h3>
                    <p>${flight}<p>
                    <h3>From : </h3>
                    <p>${fromcity}<p>
                    <h3>DESTINATION : </h3>
                    <p>${tocity}<p>
                    <h3>ON date : </h3>
                    <p>${date}<p>
                    <hr/>
                    <a href="/myapp/logout"><button>LOGOUT</button></a>
                </div>
            </body>
        </html>`
        ;
        return bookTemplate;
}

Credits

DEEPAK AGARWAL 1560450

DEEPAK AGARWAL 1560450

1 project • 0 followers
GEET JETHWANI 1560508

GEET JETHWANI 1560508

1 project • 0 followers
Geet ji

Geet ji

2 projects • 4 followers

Comments