# RFID with Raspberry Pi through Node-Red

**URL:** https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575
**Category:** General
**Created:** [24 March 2020 17:06 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575 "2020-03-24T17:06:28Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![usmanEmder](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@usmanEmder](https://discourse.nodered.org/u/usmanEmder)
#### Post date: [24 March 2020 17:06 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/1 "2020-03-24T17:06:28Z")

</div>

I want to connect RFID with Raspberry Pi Through node-red. While it is working fine with python code.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [24 March 2020 17:09 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/2 "2020-03-24T17:09:58Z")

</div>

What hardware are you using?

---

<div class="post-metadata">

### Author: ![usmanEmder](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@usmanEmder](https://discourse.nodered.org/u/usmanEmder)
#### Post date: [24 March 2020 18:17 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/3 "2020-03-24T18:17:46Z")

</div>

[rfid-rc522](https://www.conrad.de/de/p/raspberry-pi-erweiterungs-platine-schwarz-blau-sbc-rfid-rc522-raspberry-pi-raspberry-pi-2-b-raspberry-pi-3-b-ras-1503746.html?hk=SEM&WT.srch=1&WT.mc_id=google_pla&s_kwcid=AL%21222%213%21367270211499%21%21%21g%21%21&ef_id=CjwKCAjw3-bzBRBhEiwAgnnLCm6Nk0LhQCskk5k7WZKx8-cLruJfC0Mq5PwRbzphveamQlBlh0f82BoCnugQAvD_BwE%3AG%3As&gclid=CjwKCAjw3-bzBRBhEiwAgnnLCm6Nk0LhQCskk5k7WZKx8-cLruJfC0Mq5PwRbzphveamQlBlh0f82BoCnugQAvD_BwE) and raspberry pi 3 b+

---

<div class="post-metadata">

### Author: ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)
#### Post date: [24 March 2020 21:10 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/4 "2020-03-24T21:10:02Z")

</div>

Try these:

[rfidreader.py.txt](https://discourse.nodered.org/uploads/short-url/lv5yYAdbPpDo5a2bC2brQu5TI69.txt) (3.1 KB)

```auto
[{"id":"be3bb97a.4463e8","type":"daemon","z":"95c8fec3.f7779","name":"RFIDReader","command":"python","args":"-u /home/pi/rfidreader.py","cr":true,"redo":true,"op":"string","x":287,"y":210.49998474121094,"wires":[["a458aa0b.479e68","36982250.6f416e"],[],[]]}]

```

---

<div class="post-metadata">

### Author: ![usmanEmder](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@usmanEmder](https://discourse.nodered.org/u/usmanEmder)
#### Post date: [24 March 2020 21:52 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/5 "2020-03-24T21:52:38Z")

</div>

Thanks for your kind reply. I tried but I got an error as shown in picture.

 ![error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/215a4bf53c344a85bf743a72d84b647f30209ac4.jpeg)

---

<div class="post-metadata">

### Author: ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)
#### Post date: [25 March 2020 05:58 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/6 "2020-03-25T05:58:52Z")

</div>

Try this library, the one I use has some pins changed, and make sure it matches the pins you use.

[MFRC522.py.txt](https://discourse.nodered.org/uploads/short-url/fwiPIFO5KjaYid10dmWat2Z6KCV.txt) (10.1 KB)

---

<div class="post-metadata">

### Author: ![usmanEmder](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@usmanEmder](https://discourse.nodered.org/u/usmanEmder)
#### Post date: [25 March 2020 08:26 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/7 "2020-03-25T08:26:28Z")

</div>

Thanks for your again reply, I am using the following tutorial with your sent files. [https://developer.ibm.com/recipes/tutorials/reading-rfid-mifare-cards-into-watson-iot-platform-using-your-raspberry-pi-3/](https://developer.ibm.com/recipes/tutorials/reading-rfid-mifare-cards-into-watson-iot-platform-using-your-raspberry-pi-3/)  
And connecting pins on exact same positions. But still got an error. ![error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/4/b4eed8310f7aa82099f2b93aadfbcae41be1b95f.jpeg)

---

<div class="post-metadata">

### Author: ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)
#### Post date: [25 March 2020 09:45 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/8 "2020-03-25T09:45:31Z")

</div>

What if you remove the old library files and do `sudo pip3 install mfrc522`? I don't think `python MFRC522.py` installs the library.

---

<div class="post-metadata">

### Author: ![usmanEmder](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@usmanEmder](https://discourse.nodered.org/u/usmanEmder)
#### Post date: [25 March 2020 09:58 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/9 "2020-03-25T09:58:15Z")

</div>

Thanks for your kindness Miss. Tobia. I got the modified files from following link [https://github.com/mxgxw/MFRC522-python/commit/52507f18514bd4259c3e34886587ac2f95b13cb4#diff-928e81e8826acacbcb72f6dcde038977](https://github.com/mxgxw/MFRC522-python/commit/52507f18514bd4259c3e34886587ac2f95b13cb4#diff-928e81e8826acacbcb72f6dcde038977)  
New update files are : [MFRC522.py.txt](https://discourse.nodered.org/uploads/short-url/5aRRjFcHSNibBx17VgWII0BiRfD.txt) (11.4 KB) [rfidreader.py.txt](https://discourse.nodered.org/uploads/short-url/qUhbIHeaJLJRt63ruDO7hU9mO4c.txt) (3.6 KB)

---

<div class="post-metadata">

### Author: ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)
#### Post date: [25 March 2020 10:06 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/10 "2020-03-25T10:06:12Z")

</div>

Great. Beware that the RPi will run at about 25% CPU with that rfidreader.py exec node. I'm sure it's possible to change the rfidreader.py file so that it runs differently, pausing a few seconds in between but I haven't tried to change it. Maybe someone else knows how to.

---

<div class="post-metadata">

### Author: ![usmanEmder](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@usmanEmder](https://discourse.nodered.org/u/usmanEmder)
#### Post date: [25 March 2020 18:04 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/11 "2020-03-25T18:04:20Z")

</div>

Hi, it is working fine but I need to attach LED with an RFID reader and for that, I am using function node to convert python to json as mentioned in the picture

 ![error 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/5258ffb483d138bb95aabb2fe8590ac38884d312.jpeg)  
And still, RFID working fine but shows an error of function node. ![error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/82232534f54ded69057740daad6558c1395ebbc1.jpeg)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 March 2020 20:41 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/12 "2020-03-25T20:41:30Z")

</div>

When you get an error like that the first thing to do is to also connect a debug node to show what is going _into_ the function node in order to see what it is working on. Once you know that then consider what you think the function `JSON.parse()` will do with whatever you are feeding it.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 March 2020 20:56 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/13 "2020-03-25T20:56:36Z")

</div>

Is this the same student project as in the [similar thread](https://discourse.nodered.org/t/servo-motor-with-fixed-angle/22678) going on at the same time?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [8 April 2020 20:56 UTC](https://discourse.nodered.org/t/rfid-with-raspberry-pi-through-node-red/23575/14 "2020-04-08T20:56:38Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
