Wednesday, January 12, 2022

Smart Fan for indoor cycling

If you cycle indoors, whether you like ZWIFT, RGT, Rouvy, or The Sufferfest / Wahoo SYSTM you know one of the most important thing is ventilation!

You do need one or more big fans, preferably with a remote.

As in the winter, in a cold pain cave, you need to warm up before turning on the fan, otherwise it is not very pleasant.

I use a big cheap generic box store fan, that has plenty of cooling power, but no remote. So I was warming up in a hoodie with the fan on, before taking it off when warm enough.

There was also the question about the fan speed, it has 3 available speeds. Which one to choose ? 

Depending on the workout and what interval it could be too much or too little, so that was the motivation for getting some smartness into the fan.


A bit of online searching, and I found my new friend, a device called ESP32 ! It is a single chip microprocessor that has built in Bluetooth and WiFi.

So basically, you can build stuff and control them wirelessly. It also has lots of GPIO (general purpose) pins for you to connect whatever.

It has everything you need to program it (just connect to a PC with an USB cable), the software to compile the code and program it is FREE, and it has libraries and examples for lots of stuff.

Additionally it is VERY cheap.


To get things setup so you can program it, here is a link to one of the nicest tutorials out there.

https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/


One you get that going, lets go over the electrical part.

The generic fan has 3 speeds, so 3 buttons on it, each connect the power supply to a different wire.

What we need are some relays to perform the power connections, based on the controller signals

I got a 4 channel solid state relay board for arduino (5V controllable) on Aliexpress.

(Just take note if your board is HIGH or LOW enable, mine is HIGH enable, if you get a LOW one you need to update the code).

That's all the schematic you need.

Wire one GPIO for each of the fan speeds to the relay board (take note of the GPIO number).

Get a 5V supply (I used an old mobile phone charger), replace the fan switches with the relays, and bob's your uncle.

Here's the fan during testing.


Here it is with the box closed, and the ESP32 left out, as it could not fit.

It is for the better, as it should help BT reception to have the antenna out.


I then found a nicer/smaller ESP32 module, which is the M5Stack ATOM.

https://shop.m5stack.com/products/atom-lite-esp32-development-kit

This has a much nicer look to it, and has an RGB led, so I set that according to the HR zone you are in.

(Like in the above youtube video).

It also has a button you can use. I set it up so that you can toggle between bluetooth control and manual speed, in case you want to use the fan as a "normal" fan with a fixed speed.


This should be all you need to build one for yourself : 

Relay board:

https://www.aliexpress.com/item/4000115910334.html

ESP32:

https://www.aliexpress.com/item/32826540261.html

or preferably the M5Stack one ( slightly more expensive).

https://shop.m5stack.com/products/atom-lite-esp32-development-kit


Source code for this :

https://github.com/pauloserra81/smartbtlefan/tree/main


Check the README file, on what you need to adjust to your case.

If you have any questions on this, or found a bug in the code and know how to fix it, let me know !


No comments:

Post a Comment