Raspberry Pi barcode into mysql database

Hi all,

Does anyone have any idea how to integrate a barcode scanner output into a database using Nodered?

I have managed to get my scanner to output to the raspberry pi as text but i dont know how to get this to enter into a field in a database.

I have managed to get it so that using my code i can enter a payload in when i press the trigger.

I just need to combine these so that when i scan a barcode, it sends this into the database.

my code is:

[{"id":"4a69b8be.91c7f8","type":"function","z":"d2d1488a.5a49f8","name":"Query","func":"/*\nIn this function I enter my Raspberry Pi's CPU\ntemperature using the command \"vcgencmd measure_temp\".\nI then store this temperature in the variable temp,\ndo the necessary formatting and then send a database\nquery to enter the temperature in a database named\nNode-RED-test and the field named Field in the table\nnamed test, every two seconds.\n*/\nvar test = msg.payload\nmsg.topic = \"INSERT INTO testtable(testfield) VALUES('\"+test+\"')\";\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":430,"y":220,"wires":[["3dc5f360.9a44ec","e39c9d28.7e3d8","936b7279.b1f2"]]}]

Most barcode scanners seem to work as HID devices (the same as a keyboard). So you need something that is able to listen for keyboard input and then translate it into something that Node-RED can understand.

Come to think of it, I vaguely remember there being a keyboard node?

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