Search code examples
c#bluetoothvisual-studio-2015windows-10-mobile

windows 10 and bluetooth module hc-05 with passcode


I'm trying to make a connection to control a LED with a Windows Phone 10, a HC-05 bluetooth module and an Arduino Uno. I just can't get the LED to respond when using the bluetooth module, only when connecting directly trough USB.

The HC-05 uses a passcode and I just can't find how to pass the passcode on the API

The code I'm using on Visual Studio is:

//on the constructor:
connection = new BluetoothSerial("HC-05");
arduino = new RemoteDevice(connection);
connection.ConnectionEstablished += onConnectionStablished;
connection.begin(38400, SerialConfig.SERIAL_8N1);

//on the buttons:
private void OnButton_Click(object sender, RoutedEventArgs e)
    {
        //turn the led on pin 5 on
        arduino.digitalWrite(9, PinState.HIGH);
    }

Solution

  • Found the problem, the baud rate must be 9600, both on the firmata and on the Visual Studio:

    On the setup() function of the arduino:

        Firmata.begin(9600);
    

    On the begin part of the code:

        connection.begin(9600, SerialConfig.SERIAL_8N1);