Using Zwift With Nearly Any Fitness Device

by AndreasO1 in Circuits > Raspberry Pi

17389 Views, 19 Favorites, 0 Comments

Using Zwift With Nearly Any Fitness Device

zwift1.PNG
table.PNG

On Zwift the best results are with a Power Meter.

But what when you have no Bicycle with Power Meter, or no High Expensive Standalone Trainer?

With this Instructable you are able to Running / Driving on Zwift with virtual Data from a Power Table.

The most cheap Trainer have this table in the manual. If you dont have the manual anymore, google can help you to find it. Just search with "manual" + your Training device. Without this table you cant use my Instructable.

See the example:

What You Need

DSC_0563.JPG
antstick.PNG

An Ergometer or Elliptical Trainer works good. If you have a rowing device with flywheel, then it should work, too.

2x ANT+ Stick *I use Garmin and a noName Ebay Link

1x Raspberry PI 2 or 3 All in package

Some 4.7K Resistors Resistors

Some 50K Resistors Resistors

1x Magnet (I use a cube neodym)

1x reed Switch (fast) KSK 1A87

1x connector/ terminal strip (4 ports are good) Terminal Strip

Some Wires / Dupont connectors Cableset

A piece of PCB *optional PCB

A PC or Laptop / MAC for Zwift Software To Zwift

For your Fitness Device you have 2 Options:

Open the Display an place a cable parallel to the switches for the level + -

Or place a foil switch over your switches.

I use the 1 Option. The second works too.

Be sure what you do! If you are not familiar with wiring and soldering then someone should help you!

Hard and Soft Lets Do Some Nerd Stuff

DSC_0567.JPG
DSC_0569.JPG

Place the Terminal strip with power glue on the chassis of the fitness device.

Carefully put the reed switch in your terminal strip (It is Glass) From the terminal let 2 wires out 1-2 meter are fine. On the moving round plate(flywheel) place the magnet with power glue. (I use a neodym magnet). Check that the reed contact closes when the magnet pass the reed switch (You hear a click).

Install for the Raspberry PI a actuality debian jessie: Full Image

Raspberry PI Download

Do not connect any wires to your Raspberry PI yet.

Put 1 ANT+ Stick in the Raspberry PI and boot your PI

The Software Part

consolepi.PNG

install some stuff:

sudo apt-get update

sudo apt-get upgrade

you do grab a coffee * :)

sudo apt-get install mc (I use mc often)

sudo apt-get install git

you will clone this rep:

https://github.com/olympum/ant-cycling-power

git clone https://github.com/olympum/ant-cycling-power

install some more stuff :)

sudo apt install libudev-dev

sudo apt-get install nodejs npm

sudo npm install -g typings

sudo npm install -g typescript

cd ant-cycling-power

sudo typings install

sudo npm install

If you fail put a sudo before the installer command. If you have issues follow the instructions on: https://github.com/olympum/ant-cycling-power

test it with "sudo node test.js" You need to see an output! If not you have an issue.

I try to help, ask here.

When you seeing an output with power and cadence go on:

if you are not there:

cd ant-cycling-power

sudo npm install rpi-gpio

clone my git in your ant-cycling-power:

git clone https://github.com/Landixus/ZwiftVirtualPower

copy SpeedMeter.js and test.js

in ant-cycling-power

My table have 16 Level and example for 24 Levels is also included.

If the values are not yours open the SpeedMeter.js and correct the table for your needs.

Many Thanks for helping me with the code goes to tsseh from http://forum.jswelt.de

Shutdown your PI and remove the power supply.

The Hard Hardwarepart

DSC_0572.JPG
DSC_0573.JPG

Wire up (Do not make a Chaos like me in the 1 Picture!) :) :

Connect to GPIO 20(PIN 38) and 21(PIN 40) the Switch lines the reed goes to GPIO 4 (PIN 7)

How i did connect the switches:

From (Pin1 3.3V) --> 4.7K Resistor --> to Level Switch Training Device.

From Training Device Level+ output Wire --> to GPIO20 from GPIO20 --> 50K Resistor --> Ground

From Training Device Level- output Wire --> to GPIO21 from GPIO21 --> 50K Resistor --> Ground

You need to put a voltage divider, if you use the open Display Version, because the output voltage on my device are 5.5Volt.

My Voltage divider from GND to a 10k Resistor, from the 10k Resistor to a (10k and 4,7k parallel) Resistors.

Lazy Version:

The ReedSwitch: GPIO4 --> to reed Switch, from reed Switch to Ground. Check twice! All correct placed? No short circuit?

Ready?

Lets Test It. and Do Not Doubt Yourself...

zwift2.PNG

Turn on your PC and install Zwift with the second ANT+ Stick. (may be you need to install driver for the Stick)

Check if the ANT+ Stick working on PC see the ANT+ icon upper left in Zwift. Working?

OK start your Rapsberry PI and login

then go to directoy:

cd /ant-cycling-power

sudo node test.js

your output should be Power 0w Cadence 0rpm

let the console running and start pedaling / walking The power and rpm should have values now.

OK Go to Zwift and pair your new power meter and cadence You should see them now in Zwift pair Window!

Make sure that PC Windows ANT+ device and Raspberry PI ANT+ Device close together, 1-2 Meter i wrote above :)

Congrats you have a cheap accurate cadence and power meter to ride in Zwift what is also usable for Intervall Training.

do not cheating! Cheating makes you small and you lie to yourself.

Ride on!

Troubleshooting...

DSC_0566.JPG

When you plug in a USB-m ANT+ stick, the default permissions are for only root to get access to it:

$ node test.js /home/pi/ant-plus/node_modules/usb/usb.js:33 this.__open() ^

Error: LIBUSB_ERROR_ACCESS at Error (native) at Device.usb.Device.open (/home/pi/ant-plus/node_modules/usb/usb.js:33:7)

We can fix this by changing udev settings, for Garmin v1 and v2 sticks:

$ cat /etc/udev/rules.d/51-garmin-usb.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="0fcf", ATTRS{idProduct}=="1009", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1" SUBSYSTEM=="usb", ATTRS{idVendor}=="0fcf", ATTRS{idProduct}=="1008", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"

And reload udev rules: $ sudo udevadm control --reload-rules

In power-meter.js change:

stick.write(Ant.Messages.setPeriod(channel, 8182)); to

stick.write(Ant.Messages.setPeriod(channel, 4096)); // (Hz

This should reduce the drop outs to 1%

if you have still problems with radio, make sure that the both stick see each other to stable the signal.

If you have power freezes, because you have NaN values in console logout update the test.js to the latest version

Good Luck!