Skip to content

Stop on removal with USB RFID Reader

MalteHST edited this page Mar 29, 2020 · 6 revisions

This short description is a status summary of different issues and posts around the "stop on removal" feature. Based on the inital post from zxa which can be seen here: https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/62

Purpose / Issue:

Some of you want that the audio is played as long as the rfid chip is on the reader and stops or pause when its removed. The problem is that the reader transmits the card number via USB only one time after it read it and there's no way via USB to "see" for the RPi if the card is still near the reader.

Hardware Modification:

In many USB RFID Readers there is a green and red LED inside which shows the actual status of the reader. Green for: Seeing card as long as the card/chip stays in the reader range; Red for: no card. If you open your reader you will hopefully the something like this:

When the red led is on ("the idle state") there are approx. 2.7 V on point A and a few mV on point B. When the green LED is active (a card is near), there are 3.2 V on point B. This is almost exactly the voltage a GPIO of the RPi can bear. At next, you have to attach a 5k Ohm to point B (thanks to the manufacturer for the convenient soldering point in the board) and wire it with a free GPIO pin:

If you are using the PHATBeat from Pimoroni, BCM25 could be a convenient free pin for your setup. Please check this on your own.

Script Modification:

The configuration of this feature is actually not considered during the one-line installation. So you have to modify gpio-buttons.py on your own. Over SSH type the following command in the terminal:

sudo nano \home\RPi-Jukebox-RFID\gpio-buttons.py

In the actual code the feature is already prepared for personal configuration, but commented out. To activate the feature look for the following 3 lines, delete the # and adapt the btn_rfidoff for your setup:

#btn_rfidoff =

#GPIO.setup(btn_rfidoff , GPIO.IN, pull_up_down=GPIO.PUD_DOWN) -> The pin has to be pulled down, as the voltage is applied from the reader.

#GPIO.add_event_detect(btn_rfidoff, GPIO.FALLING, callback=rfidoff_action, bouncetime=bouncetime)

Exit and save the file afterwards. To test the function over the terminal start the script manually:

sudo \home\RPi-Jukebox-RFID\gpio-buttons.py

There should be no error just empty line. You will get a feedback if you press any buttons. If you now test a RFID chip (must not be registered, just readable with your reader) you should only get a feedback when you remove your chip.

Of course you have to activate GPIO over the Web-App to use this feature. Pay attention that you donΒ΄t have any double assignment for BCM pins with the rotary-encoder.py or just deactivate it if you donΒ΄t use it.

For further explanation:

"LED voltage GPIO button" is pressed and stays in that state until the card is removed. Then the "released" event is triggered by the gpio-buttons.py. In gpio-buttons.py the rfidoff_action is defined to trigger "playerpauseforce" from the playout controls. This means the audio is paused by removal.

Thanks to: zxa , dertobes

Home

πŸ”₯ Version 3

Version 3 Pages

Nothing yet

🎢 Version 2

Version 2 Pages

Installation

Specials

RFID Reader

Sound card configurations

Hardware Buttons

Displays (LED, LCD, Matrix, etc.)

Hacks

Bluetooth

AirPlay

MPD tricks

For Developers

Clone this wiki locally