So Arduino is great but if you want to do any really clever or processor intensive work with your Arduino, you need to get it to a bigger better machine, maybe even in to the cloud and when form factor is a must, bluetooth is a great method of achieving just that.
All the source code for this project can be found here.1. Wiring
The wiring for this setup is super simple, i'm using the SoftwareSerial library so we can connect to pins 10 and 11 rather than using A0
Arduino Pins Bluetooth pins
Pin 11 -------> RXD
Pin 10 -------> TXD
5V -------> VCC
GND -------> GND
Grab the code from below or the gibhub repo and then upload it to your Arduino, comments are provided through out to explain whats going on.3. Connect to your computer
So now the Arduino is wired up and transmitting (a blue Led on the bluetooth module should blink) its time to connect it to your computer, the same way you would add any other bluetooth device. Just go to your settings and look for the device named HC-02 or HC-05 depending on your chip. Try to connect (the default password is normally 0000 or 1234)4. Node Software
I'm going to presume you already understand Node and the ecosphere of that world, if not there are amazing tutorials out there (*flies away*). If you are still here you need to do the following;
1. Install Node Gyp, this is the software that allows node to talk to your computers bluetooth hardware and thus to other bluetooth devices. Setup instructions can be found here
2. Grab the source code, the easiest way is via the Github repo found here
3. Now you have the code run yarn or npm install (I prefer yarn and so the lock files and yarn based)
4. Start the server with yarn start or npm start5. Enjoy the fruits of your labour.
If you look at the serial monitor on Baud 4800 and Nodes console you should see your computer and the Arduino having a little chat. All the code is documented with explanations of whats going on.Questions, Comments and Concerns?
I wrote this little demo for myself as a stepping stone to a much larger project I have planned and i've tried to simplify and explain whats going on as much as possible however if you have any questions, or problems or suggestions for how to improve please comment them below and i'll do my best to get back to you.Thanks
A special thanks goes out to Mayoogh Girish who wrote a nice tutorial on Arudino and Android communication via bluetooth, his code and insights helped me figure out how to do it with Node, his article can be found here.