Public Sub SendData(device As BluetoothDeviceInfo, message As String) Dim ep As New BluetoothEndPoint(device.DeviceAddress, BluetoothService.SerialPort) Dim client As New BluetoothClient() client.Connect(ep)
For Each service In services.Services Dim chars As GattCharacteristicsResult = Await service.GetCharacteristicsAsync() For Each c In chars.Characteristics If c.Uuid.ToString() = "0000ffe1-0000-1000-8000-00805f9b34fb" Then ' Custom service Dim writer As New DataWriter() writer.WriteString("Hello BLE!") Await c.WriteValueAsync(writer.DetachBuffer()) End If Next Next End Function "But beware – you’ll need to run this on Windows 10+, and your app must be packaged or have with Bluetooth capability." Chapter 3 – The Unexpected Hero User: LegacyCoder interrupts: "Why overcomplicate? Just use Virtual COM Port drivers. Pair your Bluetooth device – Windows creates a new COM port. Then use good old SerialPort from .NET:" Imports System.IO.Ports Public Sub SendViaComPort(comPort As String, data As String) Using sp As New SerialPort(comPort, 9600, Parity.None, 8, StopBits.One) sp.Open() sp.WriteLine(data) sp.Close() End Using End Sub vb net bluetooth vbforums
' In Package Manager Console: ' Install-Package InTheHand.Net.Personal Then use good old SerialPort from
Public Class BluetoothHelper Public Shared Sub SendString(targetDeviceName As String, message As String) Try ' Method 1: Try COM ports first For Each com In My.Computer.Ports.SerialPortNames Using sp As New SerialPort(com, 9600) sp.Open() sp.WriteLine(message) sp.Close() Return End Using Next ' Method 2: Fallback to 32feet.NET Dim device = FindBluetoothDevice(targetDeviceName) If device IsNot Nothing Then SendData(device, message) End If Catch ex As Exception MessageBox.Show("Bluetooth failed: " & ex.Message) End Try End Sub End Class CodeNewbie_42 marks the thread as SOLVED and writes: "Turns out, the answer was hiding in plain sight. Bluetooth in VB.NET isn't hard – it's just serial communication with a different handshake . Thank you, VBForums. May your posts remain forever unarchived." Thread closed. 37,284 views. 9 helpful votes. Want me to turn this into a full downloadable VB.NET project or explain any specific Bluetooth scenario (e.g., receiving data, multiple connections, pairing without user dialog)? May your posts remain forever unarchived
Connecting the Unconnectable – A VB.NET Bluetooth Journey Prologue – The Forum Post Posted by CodeNewbie_42 on VBForums, 3:14 AM: "Help! I need to send a simple string from my VB.NET Windows app to a Bluetooth-enabled Arduino. I’ve tried SerialPort, 32feet.NET, even PowerShell – nothing works. The device pairs, but no data flows. What am I missing?" Chapter 1 – The Reply from a Guru User: SerialPortSavior (MVP, 12,847 posts) Replied: "Ah, young coder. Bluetooth on Windows with VB.NET is not magic – it’s emulated serial over RFCOMM . Here’s the path:" Step 1: Install 32feet.NET (the de facto library)
For Each device In devices If device.DeviceName.Contains(deviceName) Then Return device End If Next Return Nothing End Function