Zephyr HxM BT – Wireless Bluetooth Heart Rate Monitor for Android

Beja

Expert
Licensed User
Longtime User
Hi Sayed,

That's interesting and the HxM BT is sold on Sears, so I will stop by Sears at New Port Mall some time this week
and buy this animal.. but for your question I need some more details.
The device receives HBs by bluetooth, and then it displays the information on it's own screen.. if this is true
then what do you want to do more than that? (I must tell you I didn't read the documentation)
 

Beja

Expert
Licensed User
Longtime User
False!
The device is directly connected to subject and measures the HB then sends it out by BT.
In this case, you can try to use Erel's BT example and listen to the device.
 

hbruno

Member
Licensed User
Longtime User
See in http://www.zephyranywhere.com/media/pdf/HXM1_API_P-Bluetooth-HXM-API-Guide_20100722_V01.pdf
The Byte 12 give you the Heat Rate. (see page 11)

B4X:
Sub Process_Globals
    Dim AST As AsyncStreams
    Dim Serial1 As Serial
    Dim byteg As ByteConverter
    Dim BT_Admin As BluetoothAdmin
End Sub

Sub Globals
    Dim reser_Byte As List
    Dim EditText1, EditText2, EditText3 As EditText
    Dim synchro As Boolean
    Dim Label1, Label2, Label5 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        Serial1.Initialize("Serial1")       
        BT_Admin.Initialize("BT_Admin")
    End If
    Activity.LoadLayout("Page1")
    Activity.AddMenuItem("Connexion", "Menu")
    Activity.AddMenuItem("Déconnexion", "Menu")
    Activity.AddMenuItem("Quitter", "Menu")
    reser_Byte.Initialize
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then Serial1.Disconnect
End Sub

Sub Menu_Click
    Select Sender
        Case "Connexion"
            Dim PairedDevices As Map
            PairedDevices = Serial1.GetPairedDevices
            Dim listeDevices As List
            listeDevices.Initialize
            For i = 0 To PairedDevices.Size - 1 : listeDevices.Add(PairedDevices.GetKeyAt(i)) : Next
            Dim reponse As Int
            reponse = InputList(listeDevices, "Choix du device", -1) 'affiche la liste de choix des devices trouvés
            If reponse <> DialogResponse.CANCEL Then
                Serial1.Connect(PairedDevices.Get(listeDevices.Get(reponse))) 'Connexion avec le device choisi (nom converti en adresse MAC)
            End If
        Case "Déconnexion"
            Serial1.Disconnect
        Case "Quitter"
            Activity_Pause(True)
    End Select
End Sub

Sub Serial1_Connected (Success As Boolean)
    ToastMessageShow("My name is : " & Serial1.Name, False)
    If Success Then
        Serial1.StopListening
        ToastMessageShow("Connexion réussie", False)
        AST.Initialize(Serial1.InputStream, Serial1.OutputStream, "AST")
    Else
        Msgbox(LastException.Message, "Erreur de connexion.")
    End If
End Sub

Sub AST_Terminated
    Log("Connexion terminée")
End Sub

Sub AST_NewData (Buffer() As Byte)
    reser_Byte.AddAll(Buffer)
    Dim tabb As String
    Dim maval As Int

    tabb= byteg.HexFromBytes(Buffer)
    Log("tabb= "& tabb)
    maval=Buffer(0)

    If (maval<>0x02 AND synchro=False) Then
        reser_Byte.Clear
        synchro=False
        Return
    Else
        synchro=True
    End If

    Dim taille As Int =reser_Byte.Size
    Dim sybyte As Byte=reser_Byte.Get(0)
    If taille<12 OR sybyte<>0x02  Then
        Return
    Else
        Label1.Text = "Firmware : 9500." & reser_Byte.Get(4) & reser_Byte.Get(3) & ".V" & Chr(reser_Byte.Get(5)) & Chr(reser_Byte.Get(6))
        Label2.Text = "Hardware : 9800." & reser_Byte.Get(8) & reser_Byte.Get(7) & ".V" & Chr(reser_Byte.Get(9)) & Chr(reser_Byte.Get(10))
        EditText3.Text = reser_Byte.Get(11) & " %"   
        EditText1.Text=reser_Byte.Get(12)
        Label5.Text = reser_Byte.Get(13)
        EditText2.Text=tabb
       
        reser_Byte.Clear
        synchro=False
    End If
End Sub

The detection is done on the sub "AST_NewData (Buffer() As Byte)"

I give you the .apk, for testing your Zephyr
 

Attachments

  • Cardio_BT_Zephyr.apk
    117.4 KB · Views: 295
  • Cardio_BT_Zephyr.zip
    8.8 KB · Views: 294

synasir

Member
Licensed User
Longtime User
Basically, my app with receive the heartbeat data from the HXM via bluetooth and sends the data back via TCP to a Windows PC server.
 

synasir

Member
Licensed User
Longtime User
See in http://www.zephyranywhere.com/media/pdf/HXM1_API_P-Bluetooth-HXM-API-Guide_20100722_V01.pdf
The Byte 12 give you the Heat Rate. (see page 11)

B4X:
Sub Process_Globals
    Dim AST As AsyncStreams
    Dim Serial1 As Serial
    Dim byteg As ByteConverter
    Dim BT_Admin As BluetoothAdmin
End Sub

Sub Globals
    Dim reser_Byte As List
    Dim EditText1, EditText2, EditText3 As EditText
    Dim synchro As Boolean
    Dim Label1, Label2, Label5 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        Serial1.Initialize("Serial1")      
        BT_Admin.Initialize("BT_Admin")
    End If
    Activity.LoadLayout("Page1")
    Activity.AddMenuItem("Connexion", "Menu")
    Activity.AddMenuItem("Déconnexion", "Menu")
    Activity.AddMenuItem("Quitter", "Menu")
    reser_Byte.Initialize
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then Serial1.Disconnect
End Sub

Sub Menu_Click
    Select Sender
        Case "Connexion"
            Dim PairedDevices As Map
            PairedDevices = Serial1.GetPairedDevices
            Dim listeDevices As List
            listeDevices.Initialize
            For i = 0 To PairedDevices.Size - 1 : listeDevices.Add(PairedDevices.GetKeyAt(i)) : Next
            Dim reponse As Int
            reponse = InputList(listeDevices, "Choix du device", -1) 'affiche la liste de choix des devices trouvés
            If reponse <> DialogResponse.CANCEL Then
                Serial1.Connect(PairedDevices.Get(listeDevices.Get(reponse))) 'Connexion avec le device choisi (nom converti en adresse MAC)
            End If
        Case "Déconnexion"
            Serial1.Disconnect
        Case "Quitter"
            Activity_Pause(True)
    End Select
End Sub

Sub Serial1_Connected (Success As Boolean)
    ToastMessageShow("My name is : " & Serial1.Name, False)
    If Success Then
        Serial1.StopListening
        ToastMessageShow("Connexion réussie", False)
        AST.Initialize(Serial1.InputStream, Serial1.OutputStream, "AST")
    Else
        Msgbox(LastException.Message, "Erreur de connexion.")
    End If
End Sub

Sub AST_Terminated
    Log("Connexion terminée")
End Sub

Sub AST_NewData (Buffer() As Byte)
    reser_Byte.AddAll(Buffer)
    Dim tabb As String
    Dim maval As Int

    tabb= byteg.HexFromBytes(Buffer)
    Log("tabb= "& tabb)
    maval=Buffer(0)

    If (maval<>0x02 AND synchro=False) Then
        reser_Byte.Clear
        synchro=False
        Return
    Else
        synchro=True
    End If

    Dim taille As Int =reser_Byte.Size
    Dim sybyte As Byte=reser_Byte.Get(0)
    If taille<12 OR sybyte<>0x02  Then
        Return
    Else
        Label1.Text = "Firmware : 9500." & reser_Byte.Get(4) & reser_Byte.Get(3) & ".V" & Chr(reser_Byte.Get(5)) & Chr(reser_Byte.Get(6))
        Label2.Text = "Hardware : 9800." & reser_Byte.Get(8) & reser_Byte.Get(7) & ".V" & Chr(reser_Byte.Get(9)) & Chr(reser_Byte.Get(10))
        EditText3.Text = reser_Byte.Get(11) & " %"  
        EditText1.Text=reser_Byte.Get(12)
        Label5.Text = reser_Byte.Get(13)
        EditText2.Text=tabb
      
        reser_Byte.Clear
        synchro=False
    End If
End Sub

The detection is done on the sub "AST_NewData (Buffer() As Byte)"

I give you the .apk, for testing your Zephyr


Thank you very much. I will test it first with the HXM at my workplace. If it works, I can pay you for the time and effort. Once again, thanks.
 

Beja

Expert
Licensed User
Longtime User
Basically, my app with receive the heartbeat data from the HXM via bluetooth and sends the data back via TCP to a Windows PC server.

Hi Sayed,
Sorry but please more clarification..
If the device acquires the HB directly from the person and sending it to a server by BT, then what are you looking for? you already have
the interface and functioning.
 

synasir

Member
Licensed User
Longtime User
The HXM will send the heart beat data to the android phone via bluetooth. The android phone will then send the heart beat data via TCP back to a Windows server. Since BT is not long range, The data will need to be send via long range wireless TCP.
 

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I bought a Zephyr HxM BT about a week ago. I've been playing with interfacing it to B4A. I've developed a test app which I attached below. The test app is based on one of Erel's Bluetooth examples.

The thing I've found is that the heart rate information is just plain wrong – hmm, maybe I don't have a heart rate :D

I've also found that the information I get for the heart rate and heartbeat timestamp is all zeros if I use the harness either around my chest or holding the harness in my hands pressing my thumbs against two sensors. If I unsnap the Zephyr unit from the harness and hold it in my hands pressing my thumbs firmly against the two snaps I receive heart rate and heartbeat timestamp information (although the heart rate starts out around 240 then slowly comes down to about 50 points higher than the heart rate I get by manually measuring my pulse).

I am going to purchase some ECG contact gel (improves electrical contact) to see if this helps.

What are other's experiences with this unit? Do you get accurate readings? Have you found a different device to be more accurate?

Barry.
 

Attachments

  • zepher.zip
    50.6 KB · Views: 247
  • ss.png
    ss.png
    9.6 KB · Views: 411
Top