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

Request: Fan control via http #474

Open
AfromD opened this issue Jan 6, 2025 · 5 comments
Open

Request: Fan control via http #474

AfromD opened this issue Jan 6, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@AfromD
Copy link

AfromD commented Jan 6, 2025

I would like to request a new feature for Raspberry Pi boards.

The objective is to automate the operation of a ventilation fan to cool the rider. I propose a command line option like -fp 200 or alternatively -fs 40. -fp 200 would cause the raspberry pi to output a PWM signal on GPIO 19 (lower pins are blocked by my screen), where 0 fortius power would mean no duty cycle, 200 would mean full duty cycle, and any value between that would linearly scale the duty cycle between 25 and 100%. -fs 40 would mean scale the duty cycle according to speed to reach 100% by 40 km/h.

On the hardware side, I would use this https://www.amazon.de/dp/B0C3QTKV5V/ which I think is a phase controlled triac with pwm input. This would control the 220v power to a regular fan.

update:
Another mechanism would be hardware that reports the ac zero pass which can trigger an interrupt, where the interrupt function controls the switching of the 220v, effectively also doing phase aware pwm. This is the hardware https://aliexpress.com/item/1005006767689646.html and this is a project that has some code for the switching https://github.com/edelans/Heart-Rate-Smart-Fan

@WouterJD WouterJD added the enhancement New feature or request label Jan 6, 2025
@WouterJD
Copy link
Owner

WouterJD commented Jan 6, 2025

Hi @AfromD I welcome you to build the feature; when working we can discuss to integrate it!

@AfromD
Copy link
Author

AfromD commented Jan 7, 2025

I had a nights sleep over it. The first piece of hardware would be simpler to program, ask python to set PWM on GPIO 19 and the hardware does the rest. The second piece of hardware I found needs explicit and timing ciritical commands to chop up the AC power smoothly.

Now the problem with the first hardware is that I found multiple reviews mentioning it going up in smoke. So that is not really something I want to use. It would be prudent to use the second hardware.

The example program I found is not that great as it puts the processor into wait loops, effectively monopolizing a processor core. Sufficient for a single purpose arduino, not so great on a proper computer like a pi. So what is needed is an efficient piece of interrupt coding that doesn't pause processing.

Given that I am a total noob at Python and not an experienced programmer in general (ChatGPT has advanced to my most productive IDE), I will need some studying up to do that kind of coding (should I avoid floating point math, how to properly chop up the AC, getting the timing spot on). I have no experience with git. Also the code will need to take care of evaluating the AC frequency. And I will have to familiarize myself with the project and git.

I have Ideas on a high level on how to do this, it will take some time though. Might not get done this winter.

@AfromD
Copy link
Author

AfromD commented Jan 7, 2025

Ok, I've been looking at this for some time now, but I think I do not need to reinvent the wheel.

Integrating this real time stuff in FortiusANT doesn't seem ideal, and with my skills I would rather do it on a microcontroller, which would then interface with FortiusANT. That opens up the question about how to interface, and then there is a bit more effort in supplying the microcontroller with a power supply. I was thinking about making a standalone networked fan with an ESP8266. Networked would remove the need for pi hardware.

Researching the hardware side of this, I found there are smart home wifi enabled phase cutting dimmers available as a whole package for not a lot of money. A good example would be the shelly dimmer 2. But there is also the sonoff ifan04 It is not a pwm module, but it switches capacitors via relays. It allows control via http, and also supports Tasmota firmware. It simply connects inline in the AC supply, so no diy skills required. I found a german eBay supplier that sells it pre-flashed with tasmota.

So all that would be needed for FortiusANT in this case is to fire off http requests to control the fan.

So I will simply get a sonoff ifan module, and limit my FortiusANT efforts to getting it to fire off appropriate http requests. The big advantage of this is that it might even be platform-independent (like I said, Python noob), so all FortiusANT users can use it with a fan, not just Pi users.

@AfromD AfromD changed the title Request: PWM output on Raspi Request: Fan control via http Jan 7, 2025
@WouterJD
Copy link
Owner

WouterJD commented Jan 7, 2025

I am a total noob at Python

The FortiusANT story started in finding antifier on github, concluding the idea was good but the implementation needed improvement.

So I learned python, git, vsc, oo-programming, tacx-, ant-and later also ble(Bluetooth)-interfaces as documented in the manual.

So let's the fear not overwhelm you and grab the challenge!

@WouterJD
Copy link
Owner

WouterJD commented Jan 7, 2025

By the way, I use a normal fan with a remote control that I have attached to the steering bar.
Perhaps not as advanced as a Wahoo KICKR Headwind Ventilator but for a fraction of the cost.

Drawback: no python, git, vsc, oo-programming, tacx-, ant- programming required😉

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

No branches or pull requests

2 participants