I want to read a RFC tag with a RFC reader connected to my Raspberry Pi via USB.
It acts like a keyboard with a 10-digit output on the active tty.
How do I read that input with Node-RED?
I saw a post on a Siemens forum, but that did not help me:
https://support.industry.siemens.com/tf/WW/en/posts/usb-keyboard-and-node-red/164793?page=0
I don't want to use the RPI keyboard node which scans only single keypresses with up and down, but return one single string as msg.payload.
Have you tried the serial in node?
I have found a solution:
#!/bin/sh
# start only when called from the console
if [ ! "$TERM" = "linux" ] ; then
exit 0
fi
ok=false
while [ $ok = false ]
do
read choice
case $choice in
123456789) sudo init 0
;;
*) echo `date +%Y-%m-%d_%H:%M:%S`: $choice>>/home/pi/keyboard-archive.txt
echo $choice>/run/user/1000/keyboard.txt
;;
esac
done
I start the bash script from ~/.bashrc (last command)
In Node-RED I check for changes in the archive via the watch node and read the content of the keyboard.txt via the file in node, because the watch node has this...
Note: The directory or file must exist in order to be watched. If the file or directory gets deleted it may no longer be monitored even if it gets re-created.
To prevent massive SD card writes, the archive file could also be stored in /run/user/1000/
(tempfs)
When the transponder with the number 123456789 is read, the raspi will shutdown.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.