I want to connect my Unity 3D Game with Micro-controller Like Arduino through Bluetooth and for that I'm using a (HC‐05) Bluetooth module.
And for that there is one plugin named Arduino Bluetooth Plugin Link in the asset Store. And Charge is 19$.
Is there any other way to do this by just using free functionality and Coding?
HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. Its communication is via serial communication which makes an easy way to interface with controller or PC.
Head to Edit > Project Settings > Player. In the Inspector, open up the tab Publishing Settings. Under the Capabilities section, make sure that Bluetooth is enabled.
You can definitely do it by coding it yourself.
I can't aid you with the C# part but I've written code to send data over the HC-06 module for arduino and communicated with an Android app via bluetooth and bluetooth low energy.
At the end of the day is very similar to Socket programming.
So for the C# part this user has a basic working C# BT communication example
And for the Arduino side I have used this sketch:
/**************************************************
*
* Using the BUILT-IN Serial.
*
* CONFIGURATION:
*
* ARDUINO NANO - HC-06
* YELLOW TX RX
* GREEN RX TX
* RED 3V3 VCC
* BLACK GND GND
*
**************************************************/
void setup() {
// Init the Built-In Serial.
Serial.begin(9600);
}
void loop() {
// Send the message
Serial.println("MISSATGE PER UN LINUX!!!");
delay(2000);
}
With this wiring:
This image of the module may also be useful to you, so you can see the pinout:
So after pairing the arduino with my laptop and listening to incomming messages by using the command
$ cat /dev/rfcomm0
I started seeing the output on my console:
So instead of sending a String you can send whatever you read from your Arduino inputs and then re-parse it on your C# side.
I hope I was helpful; Good luck!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With