GithubHelp home page GithubHelp logo

acq688 / zwack-bike Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iaroslavn/zwack-bike

0.0 0.0 0.0 167 KB

BLE (Bluetooth Low Energy) Sensor to simulate an indoor bike trainer or runner.

License: MIT License

JavaScript 100.00%

zwack-bike's Introduction

Zwack Bike BLE

Simulate/Implement a Bluetooth Low Energy sensor that can send Cycling Power and Cadence (CSP Bluetooth profile).

Zwack Bike has many possible uses, here are some examples:

  • Simulate an indoor bike trainer (turbo) generating cyclist power and cadence data to test bike computers fitness or virtual indoor bike apps.
  • Integrate a common treadmill with Zwift, sending data from the treadmill to the Zwift game via Bluetooth

As an example, the code in this project is used to integrate with Peloton Bike Metrics Server to allow Peloton Bike owners to take rides on Zwift.
Diagram of the project:
Diagram of the project

Supports

At this time Zwack runs successfully on Raspberry PI with Bluetooth module (tested on Raspberry Pi 3 Model B).

Requirements

  • Raspberry Pi (theoretically should run in all Bleno (the base BLE module) supported platforms, which are Mac, Windows or Raspberry Pi.)
  • Node.js v8.x (The library we use to communicate over Bluetooth doesn't work with the latest versions of Node.js yet.)

Zwack cannot run on the same computer as the fitness or virtual indoor bike app, you'll need to run them on different systems.

Installation

Make sure you have Node.js v8.x installed.

On Raspberry Pi it can be installed like this:

curl -sL https://deb.nodesource.com/setup_8.x|sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential

Clone this repo and run

npm install

Debug Flags

You can see a lot of debug information if you run the simulator or your app with the DEBUG environment variable set to

  • csp - Cycling Power and Cadence messages
  • ble - Bluetooth low energy messages

Example:

DEBUG=rsc npm run simulator

You'll see something similar to this

rsc [Zwack notifyRSC] {"speed":4.4703888888888885,"cadence":180} +0ms
rsc Running Speed: 4.4703888888888885 +2ms
rsc Running Cadence: 180 +0ms
rsc [Zwack notifyRSC] {"speed":4.4703888888888885,"cadence":180} +1s
rsc Running Speed: 4.4703888888888885 +0ms

Using the simulator

This simulator requires a connection to the Metrics server (can be any HTTP endpoint) that returns metrics as a JSON document:

{"cadence": 85, "power": 102}

NOTE: If you wish to use a standalone simulator please have a look at zwack.

Start the simulator by executing:

npm run simulator -- --server=http://<YOUR METRICS SERVER URL>

E.g.:

npm run simulator -- --server=http://192.168.1.213:5000/metrics

On a different machine start your fitness app, bike computer or indoor virtual bike simulation software, like Zwift, and pair up the Zwack BLE sensor. The sensor name should be Zwack, it may have some numbers added to the name or you may see the hostname of the computer running zwack. It all depends on the operating system you're uing to run Zwack.

If your indoor biking software does not detect the BLE sensor, disable, then enable, the Bluetooth on the machine where Zwack is running and retry to discover and connect to the sensor again.

The ZwackBLE sensor may show up as Zwack or has the hostname of the machine running Zwack. This is normal.

Press x or q to exit Zwack.

Donations

If you like this project, please consider doing the following:

BuyMeACoffee

Credits

Initial prototype based on zwack code from paixaop.

zwack-bike's People

Contributors

iaroslavn avatar paixaop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.