Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added peloton bike decoding service #12

Merged
merged 3 commits into from
Oct 8, 2020
Merged

added peloton bike decoding service #12

merged 3 commits into from
Oct 8, 2020

Conversation

kevtainer
Copy link
Contributor

@kevtainer kevtainer commented Sep 6, 2020

This PR will introduce Peloton bike support with the following caveats:

  • Requires a serial USB RS232 decoder PL2303TA+MAX3232 USB RS232 SERIAL TO 3.5MM STEREO AJ CABLE
  • Additionally requires a 3.5mm splitter (female->2x male)
  • Also, requires a F<->F coupler
  • Requires disconnecting the TIP from the USB board and connecting the RING to the RX pad on the USB board (soldering skills), alternatively, you could probably do this with the coupler
  • Requires several additional dependencies for build time in order to support the serialport node package (build-essentials, python)

Things left to do:

  • Better documentation on the hardware setup, maybe pictures, or something.
  • Write some test(s)

Credits to @jeremydk for helping solve the encoding format mystery

@jeremydk
Copy link
Contributor

jeremydk commented Sep 6, 2020

I'm waiting on delivery of my coupler, but I'll document my setup as I go to help drive the efforts here.

@kevtainer
Copy link
Contributor Author

PS. I haven't written Javascript in any serious capacity since roughly 2014, and even then I was terrible at it. My apologies in advanced.

@ptx2
Copy link
Owner

ptx2 commented Sep 20, 2020

Hi, sorry for the slow reply here, have been away for a bit.

I know this PR is still in Draft but just wanted to say this looks super exciting!

@jeremydk
Copy link
Contributor

Sep 21 16:01:07 gymnasticon gymnasticon[9174]: [2020-09-21T20:01:07.238Z] received stats from bike [power=0W cadence=0rpm]
Sep 21 16:01:08 gymnasticon gymnasticon[9174]: [2020-09-21T20:01:08.261Z] received stats from bike [power=0W cadence=0rpm]
Sep 21 16:01:09 gymnasticon gymnasticon[9174]: [2020-09-21T20:01:09.271Z] received stats from bike [power=0W cadence=0rpm]
Sep 21 16:01:10 gymnasticon gymnasticon[9174]: [2020-09-21T20:01:10.280Z] received stats from bike [power=0W cadence=0rpm]
Sep 21 16:01:11 gymnasticon gymnasticon[9174]: [2020-09-21T20:01:11.289Z] received stats from bike [power=0W cadence=0rpm]

Bike is currently off, so these are empty buffer reads, and we should cut down on the extra work being done to parse, process, and log these messages for cleanliness.

@jeremydk
Copy link
Contributor

jeremydk commented Sep 21, 2020

Additionally, for ease of use, rather than soldering, using the same USB to Serial part mentioned above, I've had success with:

1x 7238 Monoprice 2x RCA Jack to 2x RCA Jack Adapter, Gold Plated
2x 5612 Monoprice 6in Premium 3.5mm Stereo Female to 2x RCA Male Cable, 22AWG Gold Plated, Black
1x 30897 Monoprice Onyx Series Auxiliary 3.5mm Stereo Jack to Two 3.5mm Stereo Plug Cable (Gold Plated), 6 inch

119198591_10110895062000318_4048965111995435773_n

@jeremydk
Copy link
Contributor

Taking the changes from #15 helped with the cadence accuracy, but I could still see a visible lag between the Peloton display and Zwift/TR/Garmin.

In src/bikes/peloton.js, we use a timer to schedule calls to emit stats -- which is causing both the 0rpm/0w reports as well as some of the jitter and incongruities I see in the Peloton data. Removing the timer and calling this.onStatsUpdate from within onSerialMessage() simultaneously removes the empty log messages when the bike is disconnected (i.e. not on a ride screen) as well as dramatically improves the update rate seen by gymnasticon, and made the wattage and cadence match very precisely.

@jeremydk
Copy link
Contributor

jeremydk commented Oct 5, 2020

@notsureifkevin @ptx2 Given that this has sat in draft for a month now, do you want me to fork this and push toward merging?

@kevtainer
Copy link
Contributor Author

kevtainer commented Oct 6, 2020

@jeremydk Thanks, got a message about this yesterday on reddit as well. I'm now using an ANT+ stick and commanding the sensor package on the bike without the head unit. all that's necessary is swapping over the TIP/RING wires and use serialport to transmit the request packet. I wrote a small HTTP server for the bot sensor, but couldn't get UDP to work right so just switched it to HTTP. https://github.com/notsureifkevin/peloton-power/blob/master/index.js

ANT+ is sort of messy so I never brought those changes over to this project. ANT+ is nice though because multiple devices are able to receive the data. Anyways, I'll clean this PR up and get it ready to merge.

@kevtainer kevtainer marked this pull request as ready for review October 6, 2020 13:35
@jeremydk
Copy link
Contributor

jeremydk commented Oct 6, 2020

Once this is shipped and merged, it might be cool to look at merging in the request path as well under a cli flag since it would allow people with a broken tablet to continue to use their Peloton.

I'd also be interested in maybe exploring ANT+, but I think that may boil down to @ptx2 's vision for the project, and if we should refactor around an abstract Interface type.

@ptx2
Copy link
Owner

ptx2 commented Oct 7, 2020

Thanks for submitting this @notsureifkevin!

At a glance this looks good to me, I'll have a proper look tomorrow morning. One quick question though: any thoughts on @jeremydk's proposed change above about reducing log messages / lag?

@jeremydk
Copy link
Contributor

jeremydk commented Oct 7, 2020 via email

@ptx2 ptx2 merged commit d9d5f59 into ptx2:master Oct 8, 2020
@vodlogic
Copy link
Contributor

Additionally, for ease of use, rather than soldering, using the same USB to Serial part mentioned above, I've had success with:

2x 7238 Monoprice 2x RCA Jack to 2x RCA Jack Adapter, Gold Plated
1x 5612 Monoprice 6in Premium 3.5mm Stereo Female to 2x RCA Male Cable, 22AWG Gold Plated, Black
1x 30897 Monoprice Onyx Series Auxiliary 3.5mm Stereo Jack to Two 3.5mm Stereo Plug Cable (Gold Plated), 6 inch

119198591_10110895062000318_4048965111995435773_n

@notsureifkevin / @jeremydk fantastic that Peloton support has been added. I've got the Mac branch with master merged in working with Peloton/Zwift with my 16 inch MBP. I now need to hook up the cables to the peloton to see the power/cadence and wondered if there was any reason that replacing the RCA phono cables/RCA coupler for a 3.5mm female coupler wouldn't work?

@jeremydk
Copy link
Contributor

jeremydk commented Oct 14, 2020 via email

@vodlogic
Copy link
Contributor

OK thanks for the tip, will see how things work with the same setup...

@miked4499
Copy link

Thanks for doing this! Not sure sure if this is the correct place to ask a question regarding the peloton but, is there anything unique about the 3.5mm splitter in use here? I have the serial cable re-wired with what looks/sounds correct and can get my devices to see the power meter coming from the rasp pi but no data is being read. I'm assuming there is something wrong with my cabling.

@jeremydk
Copy link
Contributor

jeremydk commented Oct 14, 2020 via email

@miked4499
Copy link

Do you have a class loaded? The Peloton Tablet will only start sending data with a class (at the start screen, or later). Does the tablet show data still? If you’re not seeing data to the tablet, that usually means your tx is still connected. Finally, your splitter might be TRRS rather than TRS, which I didn’t test with.

On Wed, Oct 14, 2020 at 9:59 AM miked4499 @.***> wrote: Thanks for doing this! Not sure sure if this is the correct place to ask a question regarding the peloton but, is there anything unique about the 3.5mm splitter in use here? I have the serial cable re-wired with what looks/sounds correct and can get my devices to see the power meter coming from the rasp pi but no data is being read. I'm assuming there is something wrong with my cabling. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAM6M2QNIS5I47T5LJ4P2LSKXKI5ANCNFSM4Q5A4NKQ .

Yes, I was launching a "just ride" session. I noticed that if I have one end of the splitter connected to the bike, I get data on the tablet, if I swap connections on the splitter I get no data on the tablet. Which is why I'm thinking its the splitter. For reference , these are the two splitters I've tried -
https://www.amazon.com/gp/product/B073ZDDTH2
https://www.monoprice.com/product?p_id=30897

Thanks for the assist

@jeremydk
Copy link
Contributor

jeremydk commented Oct 14, 2020 via email

@miked4499
Copy link

Can you take a similar picture to the one I posted with the parts list above? The exact wiring i have shown is critical to make this work.

On Wed, Oct 14, 2020 at 10:12 AM miked4499 @.> wrote: Do you have a class loaded? The Peloton Tablet will only start sending data with a class (at the start screen, or later). Does the tablet show data still? If you’re not seeing data to the tablet, that usually means your tx is still connected. Finally, your splitter might be TRRS rather than TRS, which I didn’t test with. … <#m_-751417690062948692_> On Wed, Oct 14, 2020 at 9:59 AM miked4499 @.> wrote: Thanks for doing this! Not sure sure if this is the correct place to ask a question regarding the peloton but, is there anything unique about the 3.5mm splitter in use here? I have the serial cable re-wired with what looks/sounds correct and can get my devices to see the power meter coming from the rasp pi but no data is being read. I'm assuming there is something wrong with my cabling. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#12 (comment) <#12 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAM6M2QNIS5I47T5LJ4P2LSKXKI5ANCNFSM4Q5A4NKQ . Yes, I was launching a "just ride" session. I noticed that if I have one end of the splitter connected to the bike, I get data on the tablet, if I swap connections on the splitter I get no data on the tablet. Which is why I'm thinking its the splitter. For reference , these are the two splitters I've tried - https://www.amazon.com/gp/product/B073ZDDTH2 https://www.monoprice.com/product?p_id=30897 Thanks for the assist — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAM6M5EMBIXAO274F2LV4TSKXLZBANCNFSM4Q5A4NKQ .

Sure can. I'll do it tonight.

@jeremydk
Copy link
Contributor

Created a bucket Issue to discuss these cabling issues such that we can let this PR settle.

@vodlogic
Copy link
Contributor

Do you have a class loaded? The Peloton Tablet will only start sending data with a class (at the start screen, or later).

#22 Referencing this issue for advice on sideloading Zwift on the Peloton bike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants