Raspberry Pi Asked on December 5, 2020
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
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.
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.
Answered by Carl Piper on December 5, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP