1

I'm having a bit of difficulty locating a specific example, however I have found people referencing that they have accomplished what I am looking for.

At a basic level, I have a webpage being served through Chromium and I have my RC522 RFID module. What I'd like to do is be able to scan an RFID card and to submit the ID of the RFID either through an AJAX script or pull the ID into an input field.

I'm fine with the web side and the page itself, but I am still learning Raspberry Pi, and this is a bit beyond what the little DIY books discuss haha.

There are cases like these where they pull the RFID through Python:

https://rickyventrella.com/2017/05/08/raspberryrfid/

http://helloraspberrypi.blogspot.com/2015/10/raspberry-pi-2-mfrc522-python-dump-rfid.html

https://www.electromaker.io/blog/article/launch-applications-using-an-rfid-card-reader-and-raspberry-pi

And then there is a case like this one where I get close, but it doesn't seem to quite get there:

http://www.blog.emmeshop.eu/node/48

If anyone can give me any leads or suggestions, I'd greatly appreciate it. Our little museum is trying to update ourselves for grants and some things are doable and others are a stretch.

Thank you so very much - Matt

//-----UPDATE-----//

My issue is the connection of the two. I'm in new territory here and not sure how I would pass the data from the RFID reader to the Chromium browser. If I use the basics through this python GIT - https://github.com/mxgxw/MFRC522-python - and use the read.py file through the console, I can easily pull the ID from the RFID chip/card. But I'm not sure how I'd be using the script in the background and passing the RFID ID to the Chromium browser.

I've continued to browse around the internet and found that some people have suggested using node.js instead to pass the data from the RFID Card and Reader to the Chromium browser.

I'm open to any suggestions, some of these posts I'm sifting through are older and I'm not sure if one suggestion is better off than the other for recent updates of Raspberry Pi and its operating system. Even the python I mentioned above, which is widely used, states that their haven't been any large overhauls to the code and at some point, might become unusable as Raspberry Pi progresses.

  • 2
    It looks like the tutorials you've linked should get you on the right track. You say you got close with the last one, but what's the problem you're having? It might be helpful if you could edit to explain which bit you're having trouble with rather than us guiding you from scratch again. If you get any error messages, definitely include those, and describe any steps you're struggling with. – Aurora0001 Apr 14 '18 at 9:19
  • @Aurora0001 - I've made an edit and will continue to edit throughout the night. If you need anything else if I haven't posted it yet, just let me know and I'll be happy to respond :) thanks again for checking out the question. – Matthew Apr 15 '18 at 2:28
0

We achieved this using php.

using python to load the site with ?id=(your id variable).

then in the php using $_GET['id'].

Edit as requested:

Python:

import RPi.GPIO as GPIO
import SimpleMFRC522
import time
import urllib
import pygame
reader = SimpleMFRC522.SimpleMFRC522()

while True:

    try:
            id, text = reader.read()
        print(id)
            url =("https://our.url.com/rfid.php?card_id={}&card_value={}".format(id,text))
        print(text)
        print (url)
        urllib.urlopen(url)
        pygame.mixer.init()
        pygame.mixer.music.load("/home/pi/Music/Beep.wav")
        pygame.mixer.music.play()
        while pygame.mixer.music.get_busy() == True:
             continue   
        time.sleep(1)

    finally:
            GPIO.cleanup()

Php:

<?php
date_default_timezone_set('Europe/London');
$card_id = $_GET['card_id'];
$card_value = $_GET['card_value'];
$time_out = date('Y-m-d H:i:s.ms ', time());
include ($_SERVER['DOCUMENT_ROOT']."/_includes/pdo_intranet.php");

try {
        $sql = "INSERT INTO `rfid` (`card_id`, `card_value`) VALUES ('".$card_id."', '".$card_value."')";
        $pallet = $conn->query($sql);
    }
catch(PDOException $e) {
    echo "DB ERROR: " . $e->getMessage();
}

?>

Ignore some of our weird variable names, I hope this can help point you in the right direction.

This stores the id and name into a database, i suppose you can then use ajax to do what you want.

  • Can you please show the code more completely? – SDsolar Jun 28 '18 at 22:37
  • Ive edited my answer – Carl Piper Jun 29 '18 at 10:27
  • This bit of python code might help you aswell. import os os.system('chromium-browser --app=our.url.com/mjpg/video.mjpg --kiosk &') – Carl Piper Jun 29 '18 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.