16

I build a Zwift connected fan

I build a Zwift connected fan that blows more wind as you go faster, to simulate real world conditions in my pain cave. If anyone is interested, i will make a manual on how to build your own. Also here is a video of the fan in use (turned backwards to show the moving parts). https://photos.app.goo.gl/DX1hgXk7IufHDHkj2  

update: Here's the manual. https://www.instructables.com/id/Internet-Connected-Fan-for-Use-With-Zwift Hope you manage to rebuild it. If you have any questions or suggestions, let me know!





33 comments

  • 0
    Avatar
    wai loon

    Cool! Could you share how to do it?

  • 0
    Avatar
    Just Vervaart

    Sure. I'm working on a manual. Will post it here when complete. 

  • 0
    Avatar
    Paul Cooper - Fuelled by Plants

    V. Cool

  • 1
    Avatar
    Just Vervaart

    Here's the manual. https://www.instructables.com/id/Internet-Connected-Fan-for-Use-With-Zwift Hope you manage to rebuild it. If you have any questions or suggestions, let me know!

  • -1
    Avatar
    wai loon

    Nice! Very detailed step by step and seems easy enough to follow.

    Will try it out soon and hopefully can post some pics afterwards. 

    Cheers

  • 0
    Avatar
    Just Vervaart

    I added some 'pro' features to the manual to adjust the script to use your heartrate or power output as input for changing the fan-speed. 

    If you want your fan to react on different metrics like your heart rate or power output you can change

    status.riderStatus.speed

    into 

    status.riderStatus.heartrate or
    status.riderStatus.power

    Be sure to print the metric to you terminal to see the value's that Zwift returns. You can do so by adding 

    console.log(status.riderStatus.power); 
    console.log(status.riderStatus.heartrate);

    If you want to see everything Zwift return about you during a rider use

    console.log(status); // JSON of rider status
  • 0
    Avatar
    V ROOM

    Kickstart a more polished and powerful version of it. Would do well. Needs different options, such as choosing fan speed in relation to in game speed, or power, or effort.

  • 1
    Avatar
    Just Vervaart

    @V ROOM the thought had crossed my mind, and maybe you are right, but I don't have the ambition to go into the production of Zwift fan's. As soon as you start asking money for something, the fun is most of the time over, and the headache begins...

  • 0
    Avatar
    V ROOM

    Yes! It would consume a couple of years of your life and possibly bankrupt you.

    On the other hand, you could make a million too but it'd need to work on all platforms. Sufferfest etc. It would corner the market if done right. 

  • 0
    Avatar
    Just Vervaart

    If Pebble with a 10 million Smartwatch kickstarter doesn't make it... and if your successful some Chinese manufacturer brings a cheap copy on the market. I'm happy the way my life is, tinkering on fun projects, riding my bike, and doing work thats meaningful. 

  • -1
    Avatar
    Thomas Zeutschler

    Cool idea, very cool project. I will check if my wahoo kickr allows multiple bluetooth host connections. If yes, I will try to build smart fan for it. Many thanks for this brilliant idea.

    Kickstarter would be a nice idea. But this idea should be handed over to a Fan Company. A generic smart fan would be a great idea with various applications. @JustVervaart: Hand this over to Dyson and ask for a beer (or two) in return...

     

  • 0
    Avatar
    Just Vervaart

    @Thomas, thx for the compliment. You don't need to connect the fan to your trainer, the fan talks to Zwift for your speed (or power / heart rate) via the internet (wifi). I fan company is an option, but i think a trainer company like Tacx is a more logical option maybe? 

  • 0
    Avatar
    Just Vervaart

    Cool! The Zwiftfan is #HackOfTheMonth on the GCN-show. https://www.youtube.com/watch?v=iA927OgEcQw&t=1005s

  • 1
    Avatar
    Armin bikechimps.de

    very very good work..i have tried to get people which knowledge to help me design an api which is able to read the gradient, as i am working swiftavator which is supposed to lift your front when gradient changes...

    i had no luck...

    Does your api read gradient?

    i ended up designing an easy rockerplate as seen on bikechimps.de ...

    Maybe we could join to get the fan going on a lifter :-) for the front in one step, with one electronic...i am also doing it just for fun...

    Once again congrats for your great design and the fame beeing the hack of the month on GCN 

    Armin.., bikechimps

  • 0
    Avatar
    Just Vervaart

    Hi Armin,

    thanks for the compliments. First of all, it's not my API, it'sby the mysteries Ogadai https://github.com/Ogadai/zwift-mobile-api

    i can't test things right now, but it seams that there is some data on climbing in the API. I see the following;

    • lean: 1000000
    • climbing: 0
    •   altitude: 14478.4609375

    All could have something to do with gradients. Best is to install the right script on a computer that runs Zwift and see what the output is when you ride up hill. You have to uncomment this line in the script to see this. 

    console.log(status); // JSON of rider status\

    What you could do for sure is check the altitude and speed every second. You could then calculate gradiënt. (meters up / meters forward) https://www.mathsisfun.com/gradient.html 

    Good luck with the project.

    Greetings,

    Just Vervaart

  • 1
    Avatar
    Sebastian Linz

    Hi Just,

    thank you for your pioneer work. I didn't knew the photon before. With your instructions and Ogadai's lib I built an improvement for me.

    Now the second version of the photon relay shield is available,

    which I could completely integrate in the case of my fan.

    So my fan is only connected by wire to power connection.

    On my notebook runnig the Zwift client I'm running my node.js-application. The node.js-application provides a way to manually control the fan or control the fan by my Zwift-ride. Therefore the app, which makes the calls to Zwift using Ogadai's API and provides a simple text HTTP interface to the photon. There are two Zwift-modes: simulation and workout. Simulation is like what you implemented and workout controls the fan based on my power levels. Furthermore the node.js.application provides a web-UI so I can control it riding on Zwift with my mobile phone:

    Finally I added a favicon so I can call the web-app from home screen:

    Thank you very much and RIDE ON!

    Sebastian

  • 0
    Avatar
    Just Vervaart

    Hi Sebastian,

    nice work. I like the way you integrated in into the fan and love the web interface you have build. Would you like to share your code so i can add it to the github repo https://github.com/justusvervaart/zwift-fan and to the instructable manual https://www.instructables.com/member/justvervaart/instructables/ And i for sure would love to use your web interface instead of the script editing i have to do at the moment to change modes. 

    Greetings en happy riding,

    Just

     

  • 0
    Avatar
    Sebastian Linz

    Hi Just,

    you can find the code on github (see: https://github.com/sebastianlinz/FanControl). It need some documentation and refactoring, I'll provide next days/weeks.

    Regards,

    Sebastian

  • 0
    Avatar
    Just Vervaart

    Hi Sebastian, 

    impressive work. If you could make a installation manual that would be great. Would love to change my config to yours.

    Greetings, Just. 

  • 0
    Avatar
    Sebastian Linz

    Hi Just

    I've extended the documentation on GitHub. I’m looking forward to getting your feedback to improve documentation.

    Best regards,

    Sebastian

     

  • 0
    Avatar
    Just Vervaart

    Hi Sebastian, 

    it took a while before i was able to test your setup. I got a new wifi router and it took a while to figure out that the particle core does not support wifi channels higher then #11 :( 

    Anyhows, installation of the project was smooth (only problem i encountered was having to manually add the HttpClient to my Particle libraries). The node.js code seems to be running fine. I Get the front-end application on localhost:3000 and this is what the terminal is giving back. 

    MacBook-Pro-van-NPO-2:fancontrol justvervaart$ npm install

    up to date in 2.446s

    MacBook-Pro-van-NPO-2:fancontrol justvervaart$ npm start

    > [email protected] start /Users/justvervaart/Google Drive/Zwift/FanControl

    > node ./bin/www

    Sat Feb 17 2018 09:46:29 GMT+0100 (CET) - debug: ZwiftAdapter.constructor()

    Sat Feb 17 2018 09:46:33 GMT+0100 (CET) - debug: playerId: 120891

    Sat Feb 17 2018 09:49:07 GMT+0100 (CET) - debug: /fanStateLevel3 fanState: 3, fanLevel: [3]

    GET /fanStateLevel3 200 439.646 ms - 873

    GET /stylesheets/style.css 304 5.565 ms - -

    Sat Feb 17 2018 09:49:12 GMT+0100 (CET) - debug: /getFanLevel fanState: 3, fanLevel: [3]

    GET /getFanLevel 200 3.584 ms - 28

    But the Core seems to be unresponsive to input and when I select on Get Fan State I get this output: 

    FCS3FLV3PWR0000HR000SPD00000 

    Any idea what is wrong? 

    Greetings,

    Just

     

     

  • 0
    Avatar
    Just Vervaart

    ps. i also don't see a folder with log files...

  • 0
    Avatar
    Just Vervaart

    Wait. I used a previous version of your Particle code. Just downloaded the new .ino file. Will test this afternoon again. 

  • 0
    Avatar
    Just Vervaart

    mmm. Stil no luck.

     

  • 0
    Avatar
    Sebastian Linz

    Hi Just,

    node.js-app are looking good. Maybe I've to fixe an error. While .gitignore ignores folder "./log" it isn't added to repository and I should create this folder because watson (logging framework) is configured to log to file ./log/fancontrol.log. So if you create a folder "log" it should create the log-file.

    Fan is set to level 3 because of the response given. So it's somewhat between Photon and node.js-app.

    If you have the possibility to connect the photon with your Mac by USB and have Putty installed, you can see what the Firmware is logging and if the response reaches the Photon. The response:

    FCS3FLV3PWR0000HR000SPD00000 

    should start your fan with speed level 3 if relays are connected accordingly. Anyhow the fan should start. In Photon's log you should see this statement:

    httpRequestBodyHandler(data): bodyHandler: 3

    and before:

    loop(): HTTP Response Body: FCS3FLV3PWR0000HR000SPD00000

    If you don't see this statement, the response doesn't reach the photon.

    I propose you check this out and post the photon's log here if you like.

    Best regards,

    Sebastian

     

  • 0
    Avatar
    Just Vervaart

    Hi Sebastian,

    thx for the feedback. This is the output of the monitor. 


    MacBook-Pro-van-NPO-2:fancontrol justvervaart$ particle serial monitor

    Opening serial monitor for com port: "/dev/tty.usbmodem1411"

    Serial monitor opened successfully:

    FanController.setup()

    FanController.setupPins(): entry.

    FanController.setupPins(): RELAY1 mode OUTPUT

    FanController.setupPins(): RELAY2 mode OUTPUT

    FanController.setupPins(): RELAY3 mode OUTPUT

    FanController.setupPins(): done.

    FanController.setup(): pins setup

    FanController.setupHttpRequest(): entry.

    FanController.setupHttpRequest(): done.

    loop(): number 1

    loop(): Response status: -1

    FanController.resetPins(): entry.

    FanController.resetPins(): entry.

    loop(): number 2

    loop(): number 3

    loop(): number 4

    loop(): number 5

    loop(): number 6

    loop(): number 7

    loop(): number 8

    ....
  • 0
    Avatar
    Sebastian Linz

    Hi Just,

    for me it seems the issue is caused by the network connection between photon and your mac. Would you check the IP-address you've entered for your mac in the ino-file? Did you set the constant HOST_IP to the IP-address of the mac in your local network? Or the mac's firewall settings are rejecting calls on port 3000. Sorry, I'm not a mac-user. Is there a firewall setting by default?

    Regards,

    Sebastian

  • 0
    Avatar
    Just Vervaart

    Yes! Problem solved. I used the external wifi address of the router and not the internal address of the macbook. Stupid error. It now works like a charm! Great job and thx for sharing and help with setting up on my end.

    Btw. is there a reason you only refresh every 5 seconds and not every second? 

  • 0
    Avatar
    Sebastian Linz

    Hi Just,

    that's great! I started with 5 seconds. For me it's enough. Maybe I'm changing to 3 seconds. I won't go below 1 second, because the of request-response-cycle. But you can try out anyway.

    Have fun and ride on

    Sebastian

  • 0
    Avatar
    Just Vervaart

    Hi Sebastian,

    i'v been tinkering with deploying the app on Heroku so it will work without having my laptop function as a server. The app runs fine, but connecting to the Particle is unsuccessful so far. Probably an ip/port thing again. Any experience with Heroku?

    Greeting, Just

Please sign in to leave a comment.