Reading bluetooth data using Node.js on a Raspberry Pi
If I were going to give Linux a tagline, it would be "Easier said than done." I thought that once I had gotten the USB combo dongle working in the last post, it would be trivial to get my Node.js application working on the Pi, but I was wrong.
On my mac, I was able to listen to the output of my Bluetooth device via a serial port with no extra work, but now I have to figure out how to get the same setup on the Pi.
I found this article that talks about how to set up rfcomm to set up a serial channel for the Bluetooth. I'm going to follow it. One issue I found with this article is that it tells you to type
sudo rfcomm connect 0
But that is missing arguments. It should be:
sudo rfcomm connect 0 AA:BB:CC:DD:EE:FF
Where you'd put your device's actual mac address in. I did that and it claimed to be connected, but it held one thread open on the terminal so I couldn't also run my Node.js app. I tried putting that in a bash script and then running Node in the same terminal window, but that didn't work. What worked was a pretty lame hack where I just opened two terminal windows. And then great success happened! I was able to start the server and then see the output locally on my machine.
And then life happened. I think the 9V battery on my KL46Z is almost dead because I wasn't getting enough juice for the Bluetooth card to work. That thing must really need a lot of power.
Finally, my husband pointed out that I really should put the units and scale on the graph.
So what's left to do before calling this project done?
- Figure out how to open up two threads in a bash script to make life easy
- Add scale to the graph
And what should I add for much improvement?
- Figure out how to have the rfcomm start up automatically when the right Bluetooth device appears
- Make my bash script start as soon as the Pi starts up