hypermoose / Keiser2Zwift

29 stars 6 forks source link

Heart rate on Zwift #13

Open gerardogm opened 3 years ago

gerardogm commented 3 years ago

Hi, I'm testing this project and it's great! Thank you! What needs to be done so Zwift can pick up the heart rate? I see the program is getting the correct hr from the m3i and it's being passed via the "dataToSend" variable on index.js, but Zwift won't display it. I think I read that Zwift gets the hr from the M Series Converter, so this should be possible, please correct me if I'm wrong. I might be able to fix this if someone tells me what needs to be done.

Thanks again, -Gerardo.

hypermoose commented 3 years ago

Hi glad your liking it. I haven't really tried the HR option. Are you wearing a chest strap for your HR monitor? Also are you selecting a device specifically in Zwift for HR?

hypermoose commented 3 years ago

I have just paired my chest strap directly with Zwift before and bypassed the M3i. But maybe I don't understand your scenario

gerardogm commented 3 years ago

Thanks for your answer! I'm wearing a Polar chest strap, which can communicate with the Keiser computer module, which displays the heart rate. The Keiser app gets the heart rate from the Keiser computer.

Your node app also gets the heart rate; I tweaked the code a little bit and was able to log the heart rate. Example:

Bike 0: rt: true cd: 94 pw: 109 gr: 11 hr: 158 dr: 1913

I assume we can get the heart rate that the Keiser computer is providing to Zwift, as I read that the M Series Converter can do that: https://forums.zwift.com/t/keiser-m3i/165113/14

(I see you also participated on that thread, cool!)

Thanks, -Gerardo.

hypermoose commented 3 years ago

Have you tried connecting the Polar heart rate strap directly to Zwift?

gerardogm commented 3 years ago

The strap is not Bluetooth; it uses a different radio protocol that the Keiser computer recognizes. Since my iPhone or iPad (in my case) don’t support the Polar sensor’s protocol, Zwift cannot see it.

The good thing is that your program gets the heart rate reading from the Keiser computer, so I think we can find a way to pass that data to Zwift.

On Apr 29, 2021, at 9:52 PM, Gary Caldwell @.***> wrote:

 Have you tried connecting the Polar heart rate strap directly to Zwift?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

hypermoose commented 3 years ago

I see, we may need to add another BT Service to the App. See https://www.bluetooth.com/specifications/specs/heart-rate-service-1-0/

gerardogm commented 3 years ago

It looks like you are right: https://forums.zwift.com/t/ftms-and-heart-rate/518829

hypermoose commented 3 years ago

Shouldn't be too hard. Will take a look when I get a chance.

gerardogm commented 3 years ago

Thank you! Here is some code for the ESP32; it references other code projects: https://github.com/nkolban/esp32-snippets/issues/844

I think we can get the heart rate from the Keiser computer (if available) and then send it like this (from the code referenced above): /``` / _____ // HEART SECTION // ------------- // Read Heart Pins
// *****

bpm = hr_from_Keiser_computer; // Line added by Gerardo heart[1] = (byte)bpm; int energyUsed = 3000; heart[3] = energyUsed / 256; heart[2] = energyUsed - (heart[2] * 256); Serial.print("BPM = "); Serial.println(bpm);

// Send Heart Rate Notify heartRateMeasurementCharacteristics.setValue(heart, 8); heartRateMeasurementCharacteristics.notify();

hypermoose commented 3 years ago

@nealjane super awesome! Excited to see where you take it. @gerardogm sorry I haven't got back to this but it looks like @nealjane has taken the ball forward. However @nealjane it appears like your HR service is commented out on HEAD

gerardogm commented 3 years ago

Thanks, @nealjane, I will take a look at it! Don't worry, @hypermoose, I also wanted to try implementing the HR but I've been busy lately; I'll see if I can test something this week. So far your program continues working like a charm! FYI I'm running it on an old CHIP SBC (the famous $9 computer), upgraded to Debian Buster :)

Regards, -Gerardo.

nealjane commented 3 years ago

@nealjane super awesome! Excited to see where you take it. @gerardogm sorry I haven't got back to this but it looks like @nealjane has taken the ball forward. However @nealjane it appears like your HR service is commented out on HEAD

Nothing to do with me - it’s just another user that previously used your keiser2zwift.

gerardogm commented 3 years ago

I added the HR service that @djwasser created for the M3iPiZeroW project and it worked! Thanks a lot, @nealjane & @hypermoose! I'll submit a pull request as soon as I can.

Regards, -Gerardo.

IMG-0559

djwasser commented 3 years ago

@gerardogm - Glad you got HR Service working with this code! FYI, I updated the Readme on my repo to explain why I commented out the HR service after I had it working. Additionally, I was also able to get everything working using only the onboard PIZeroW Bluetooth (no BLE dongle). I imagine that could be done here, but I am kindof clueless when it comes to collaborating on code dev on github ;-/

gerardogm commented 3 years ago

@djwasser - Thanks for your comment! Yes, while I was moving your code to this project, I was wondering if there could be conflicts if a separate BT HR monitor was present (although you should be able to select a different one by tapping the HEART RATE button on Zwift and pairing it, right?) I'm thinking it might be worthwhile to add a startup option to enable the Keiser HR service so people like me that use the Polar sensor can use it :)

Like you, I'm not very familiar with GitHub collaboration :P Is it OK with you if I create a patch containing your HR monitor code for this project?

Regards, -Gerardo.

djwasser commented 3 years ago

@gerardogm - please feel free use my HR monitor code as you see fit!

nealjane commented 2 years ago

Thanks for your comment! Yes, while I was moving your code to this project, I was wondering if there could be conflicts if a separate BT HR monitor was present (although you should be able to select a different one by tapping the HEART RATE button on Zwift and pairing it, right?) I'm thinking it might be worthwhile to add a startup option to enable the Keiser HR service so people like me that use the Polar sensor can use it :)

Like you, I'm not very familiar with GitHub collaboration :P Is it OK with you if I create a patch containing your HR monitor code for this project?

Regards, -Gerardo.

@gerardogm Would be good if you could update this with your HR code when you do get a chance..