Was just looking at buying a version of this to fan assist my radiators when i have the heat pump installed, the price of them is horrendous, so i thought ill make one... youve just saved my a LOT of work! thanks
No problem. Personally I still think a standard on/off control for a fan is the best option in most situations due to its simplicity, but controlling the speed is a fun project!
The irf520 needs more than the 3 Volt that the D1 provides for switching. With a standard 5V Arduino it works with a fan (tried that a month ago). So there are two options: drive the mosfet with 12Volts or replace the mosfet with a logic level compatible. There you just need to get to 5V.
nice. I have built my own NAS and the case has 4 fans to be controlled (my motherboard does not have PWM - only 3 pin connector). So I decided for another approach: 1- script running on NAS (it is Debian based so easy to add it) 2- script collects the measurements: - HDD and NVMe temperature (using smartctl) - CPU temperature (using psutil) 3- script sends data over WiFi to MQTT server and then to Home Assistant 4- ESP32 subscribed to the temperature topics 5- ESP32 based on: - received setpoint (adjustable on Home Assistant) - received HDD temperatures (CPU is not needed as CPU fan is controlled by PWM on motherboard) executes and controls PWM signal 6- although there are 4 fans I grouped the control part into pairs of 2 because: - first pair is for HDD compartment - second pair is for NVMe/motherboard compartment So it is quite obvious that the PWM can be the same for each fan in the same compartment For measuring the actual RPM each fan has to have separate connection between RPM pin on the fan and GPIO on ESP32 - you cannot connect RPM pins from fans in parallel! 7- in case WiFi/MQTT/Home Assistant is disconnected, ESP32 sets PWM to 50%. This way I made it fully automatic (with emergency 50% of PWM in case ESP32 is disconnected from Home Assistant). Actually, this 50% PWM is configurable in the code and it can be changed to 100% to be even safer. I was also thinking about putting few temperature sensors (the cheapest and easiest would be DS18B20 as you can put them on 3 wires only and in series) but I wanted to avoid messing up with the case inside and the script running on OS provides proper measurements as well. What is good when you are inside the case you: have both voltages on molex: 12V for fan and 5V for ESP32 so no DC-DC converter is needed.
Just installed with Noctua fans and all good (incl. tachometer for 1 of the fans). My fans stops spinning without the relays so all good. Using it on a solar inverter i get the temperature from the heat sink of it and imports this into the Wemos. Works perfect, TY💪
I guess I was unlucky with a fan that can’t fully stop with PWM then. Oh well, the relay has come in handy for another project which I’ll publish in a few weeks :)
I wish I had found this exact video earlier when I was starting to set up my fan control setup. Oh well, at least I learned a lot through trial and error, and the end product works really well. I actually came up with a near identical setup, and the intial code looked pretty much the same as yours 😀 The only hardware difference is that I use an ESP32 nodeMCU (with hardware PWM support through esphome "ledc"), a buck converter for the 5v power, as well as a DS18B20 temperature probe. What I intended to build was a temperature controlled fan array for use as a radiator booster. The temperature is read from the probe mounted to the radiator intake. In Home Assistant I can switch the mode of operation between heating and cooling (yes, our radiators can cool too in the summer because it is fed by a new heat pump). Then I can adjust the fan speeds, temperature threshold for both modes and also some hysteresis (so the fan doesn't turn on/off all the time when the temp value is hopping around the threshold). Temperature control can also be switched off if I want manual control. All in all, I just love the ESP32 and similar SoCs, little inexpensive powerhouses of automation! ⚡
@@SpeakToTheGeekTech No, the heatpump is calculating the dewpoint at multiple points and regulates the cooling temperature accordingly. So far no issues, but we didn't run it for long since it was installed late summer/autumn this year. Next year we'll have much more time to test :)
Really enjoyed building this to act as a cooling fan for my PI 5 enclosure running Solar Assistant linked to my SunSynk. I have added the status LED from phase 2 but need a pointer to get green, amber and red to reflect fan off, calculated and full. Struggling with syntax's within Lambda's
Version 2 doesn't do red, amber, green. It does solid red if on, or flashing green if off. It works by checking the fan status every three seconds and acting accordingly, no lambda involved. interval: # Every 3 seconds, if the fan is off, then flash the LED green - interval: 3sec then: - if: condition: switch.is_off: switch_fan then: - light.turn_on: id: status_led transition_length: 1s red: 0.0 green: 1.0 blue: 0.0 brightness: 0.7 - delay: 1000ms - light.turn_off: id: status_led transition_length: 1s else: - light.turn_on: id: status_led transition_length: 0.1s red: 1.0 green: 0.0 blue: 0.0 brightness: 0.7
@@SpeakToTheGeekTech Understood - what I was trying to do was add the concept of a status led on the version three but not sure where is best to add the light.turn_on within the lambda's
A few options depending on what you want to achieve. If you just want red = off, green = on for example, just add extra actions in the fan section: fan: - platform: speed output: pwm_output name: "${device_description}" id: "the_fan" on_turn_on: - switch.turn_on: fan_relay - light.turn_on: id: status_led transition_length: 0.1s red: 0.0 green: 1.0 blue: 0.0 brightness: 0.7 on_turn_off: - switch.turn_off: fan_relay - light.turn_on: id: status_led transition_length: 0.1s red: 1.0 green: 0.0 blue: 0.0 brightness: 0.7 If you wanted to do different colours based on speed or temperature though then you are best using an interval like in my previous config checking your sensor every few seconds to see what the value is and which colour you'd like it to be in that threshold. That's a bit more work though so I won't be working an example up for you there :)
Thanks! This tutorial is fantastic! I'm new to HA but I've already managed to implement the project. The only additional help I would like to request is to create a dead band between the Off and On of the fan. When the temperature is close to the shutdown point we have pulses in the relay. Can you please help?
This is totally untested by I think you need to change the section that says: - if: condition: lambda: |- return id(temperature_sensor).state < id(${temperature_threshold_low}); then: - fan.turn_off: the_fan to something like: - if: condition: lambda: |- return id(temperature_sensor).state < (id(${temperature_threshold_low})-1); then: - fan.turn_off: the_fan Note the extra brackets and -1 which knocks a degree off the lower threshold before it turns off. The fan would already be at 0rpm anyway at the lower threshold so this just affects the relay.
I’ve been wanting to do this with a network cabinet and a few gpu mining servers I have. But I still think this is too much to do 10 or 20 times. I’ve been really hoping to stumble across a device or get familiar with pcb design enough to go have it printed and assembled.
in next video can you tell us how to control L298N with esp32 in home assistant ? for example to control peristaltic pumps, and make very simple automation of dosing few ml of liquid ? would probably save my sanity ......
I'll have a think but no promises. I tend to only make guides for things I'm actually using myself because that way I can test them long term to be certain they're working, but this part does look interesting. I'd need a motor to control too... and something for that motor to do.
@@SpeakToTheGeekTech i am in process of discovering HA and tinkering with my fish tank, as i am from time to time away from home for few weeks i want to build automatic feeder (dc motor, that will spin few seconds to push out food from 3d printed housing) and also want to automaticaly adjust ph level in tank, so i want to for example measure PH, if low dose few ml of ph up, wait, measure again, if still low dose few ml of ph up, wait, if ok do nothing. but to get those damn dc motors running ....
You may have part 4. How can you do it with multiple fans and multiple temp sensor. Ie. You have different shelves for your PC, game console, and receiver. I want to put separate sensors and separate fans for each.
Lol, maybe, that sounds like an expensive video to make with all the parts though :) you’d need probably a different microcontroller with more pinouts, and/or a multiplexer for the temperature sensors. Apart from that it’s the same configuration copied, pasted and tweaked slightly for each ‘zone’
The easiest way is to turn it on or off like a normal thermostat would, which is pretty much what most consumer electric heaters do. If you're talking about restricting the power used by a heating element so it runs constantly at a set temperature then you'd need some way to dynamically adjust the voltage to it. Really depends on the power demands of that heating element but you'd need some decent heat dissipation because that component itself would get hot! For safety reasons, that sort of home-made gadget is not one I'd plan to do a video on. I've made much simpler ones with low power (
I'm surprised that the 12V fan takes a 3.3V PWM signal. I'll have to try if that works for my fan as well - I was under the impression that I'd have to feed it a 12V PWM signal which would have made the entire setup more complicated. Did you try several fans? Do they all accept a 3.3V PWM signal?
Before I start my reply, I'll confirm I am an amateur at this so please double-check anything I say here! I haven't tried other fans, just that one, but my understanding of PWM is that the voltage itself doesn't matter too much (it must be in a range suitable for the fan of course - sending 240v down the PWM pin will likely fry it!), what does matter is the duty cycle of the voltage - so how long the PWM pin is on vs how long it is off. So for example if it's always on, that might be 100% speed, if it's on for 3/4 pulse periods, that's 75% etc...
@@SpeakToTheGeekTech you're right about PWM being about the duty cycle - I just would have expected the fan to not "see" 3.3V at all because it might be under the threshold where it reads a 0 or a 1. I would expect a 3.3V signal to always be seen as a 0. I'll give it a try. Thank you for the immediate answer. I'll also use a MOSFET instead of the relay.
can somebody PLEASE help me with simple thing? i have ADC photoresistor, and ledc for fan PWM output, how to make this C code to esp32 yaml? If (adc_value
Either way you can’t translate directly to yaml, you probably need to use lambda within the yaml file and that would depend totally on the entire context of the rest of your yaml file so far.
@@SpeakToTheGeekTech i know i cant directly, but i cant get it to work in yaml ... this language seems to be cursed for me, simple thing as simple if with variable and codition...
Thank you very much for the detailed explanation and example. Is there a way to (1) fetch the current set speed of the fan (2) compare with the `calc_speed` (3) only make a change when the two values are different? I am working on a similar setup but having a hard time to fetch the current speed value of the fan.
I guess you could but it wouldn't really make sense. The script must always return a speed value even if that hasn't changed otherwise the fan would get a null speed value. I'm not entirely sure what you're trying to achieve by checking and setting only if different. It's all based on monitoring the temperature, so the script to set the fan speed only runs if the temperature has changed. If the temperature has changed then almost certainly the fan speed will change. You could adjust it I guess so as the script only fires when there's major changes in the temperature, like 0.5 or 1.0 degree jumps if you're concerned about running it too often to save power or something?
Thank you so much for this! The same setup (Wemos D1-R2) is working almost flawlessly for me except for one issue that is driving me crazy. The BMP-280 sensor keeps freezing after 1-2 hours of operation. The only thing that will fix it is to unplug and reboot. After a lot of research I read about connecting the CSB terminal to VCC (3 or5v) as it should force it to keep running i2c instead of SPI. This has sadly not worked for me either, so im just wondering if you have encoutered anything similar or have any advice ? Thanks again for your work.
I'm afraid I don't know, sorry. I have two fan controllers in permanent use (not this variable version but the static ones) and they never need a reboot. It could perhaps be a quirk of the particular variant of BMP280 you are using? Maybe try a BME280?
Yes it would work with Tasmota but my configuration is specifically for ESPHome, so you'd need to 'translate' it to Tasmota configuration instead. I'm also not sure how logic works within Tasmota so you may just have to expose the raw sensors/actuators to Home Assistant and use an automation in there to co-ordinate things like the relay and the temperature sensor.
Hi ,another great revision in the series! A question: Instead of a relay, wouldn't a mosfet with a proper pull down suffice? I believe i have setup something like that in a way like your previous version, so with a mosfet "trying to simulate a voltage level by pwm'ing its gate", however it will need some beefy cap over the fan pins to flatten out the "output" pwm and the frequency should be high enough so you don't hear any buzzing. At an early revision i forgot to put a pull down on the output that goes to the mosfet. The mosfet has a parasitic capacitance and will stay "on" if the gate isnt really pulled down to ground, not sure but maybe you made the same assumption into believing the gpio should be able to completely pull that gate to ground? But a DC motor speed is really hard to control that way. Also i can relate to the feeling of hearing that relay switching and thinking "a cool, its doing its thing". Another thing; i think i didn't see that in your previous designs, the fan dc motor will need a flyback diode, just like the circuit responsible for switching the relay (should be builtin on the relay board) as these coils will generate a huge reverse voltage spike if you abruptly stop sending current through them. Did the previous revisions survive? Btw not all PWM fans keep turning at 0 duty cycle, i made another version myself which simply feeds the pwm to fan's pwm input signal (actually 5 fans connected like that in parallel) and they all turn off at 0 duty. Depends on the model i guess. Mine are the Delta AUB0812H, i guess the whole "AUB" series will work fine. These are 8cm, change the 08 into 12 for the 12cm version, etc. There are some variants, make sure to get the right one (4 pins). The 5 fans are cooling a closet with some computer hardware in it, very similar project. A tiny esp-01 with espeasy does it all; One GPIO controls the pwm signal to the fans, another one is used to read 3 digital temperature sensors (ds18b20). Seems to work great (got it running for about a week now). I used a voltage regulator to step down from 12V (an old HP laptop power supply) to 3.3V but that is highly inefficient, i think i will also need a 3rd revision with a proper step-down voltage regulator. This series is very inspirational, my approach is a bit different but its really nice to hear other enthusiasts explain their (similar) projects and especially what choices were made and why, cheers!
Hi, I’m glad you liked the videos. Yes, both previous versions are still going well - the ESP32-based one in my AV cabinet and the ‘deluxe’ one in my IT cabinet. I’m really no electronics expert and it appears your knowledge may greatly exceed mine in terms of whether capacitors might be needed or not for voltage smoothing! All I know is a relay turns stuff on or off, and it worked :) The buzzing was very annoying and also the whole voltage regulation method was very unreliable, which is why I switched to using a relay, and my current knowledge is not sufficient to be able to fix that non-relay solution.
Sorry to bother you but looked at this video some time ago and purchased all the components you suggested but never got to go ahead until today. Hit a problem immediately when trying to run either sketch, I am getting the message 'Compilation error: invalid preprocessing directive #Enable'. Is this something I am doing wrong or could it be I'm using a newer version of Arduino software? The D1 Mini is working perfectly well otherwise, any help would be appreciated. (FYI, D1 mini in only connected to the PC on a breadboard and no other components connected yet.
Hi, I have never tried this using Arduino - I've only tried this in ESPHome and my guide is for building this using ESPHome configuration not sketches.
Hi, I am new to the whole ESP universe and am still a little bit lost. Anyway, I want to jump into the cold water and start a project based on your amazing work as you explained the concept it in a great way and learn while doing 😊 I want to build a fan array to boost my radiator. Your code does basically what I need. Read a temp and set the fan speed accordingly. I have two questions: 1) Do you now if your setup also works for multible fans wired together? I am thinking on using Artic P12 PWM PST. With long radiators up to 7 or 8 fans would be necessary. As they only draw 0,1A/12V, I feel this is not an issue but wanted to hear your thoughts. Could they all use the one PWM signal to be controlled? 2) I need the temp sensor to be connected to the flow of the radiator to read, if the heater is on and only then start the fan. The BMP280 seems not ideal for my purpose or i dont get its correct function (it has no "probe" and leading singles wires to the flow and back seems not ideal for my project). Many related projects use DS18B20 for this but it only has a single signal cable instead of the two. Would that still work? Many thanks😊
The short answer to both is "I don't know", but I will elaborate! 1) I'm not sure what would happen if you wired the PWM pin to all of the fans in parallel. I would like to think it would work but I have never tested such a thing. Sounds like a good experiment for you to report back on though :) 2) Yes you could use a DS18B20, but you can't just swap one for the other. You'd need to add a pull-up resistor to the circuit and research which sort you'd have to add, and also change the ESPHome config to use a one-wire library to operate it. The reason I used BMP280 is because it's so simple to get working usually and it works well to detect ambient air temperature.
@@SpeakToTheGeekTech 😂 No worries. I think you already did an amazing job figuring out all those little hurdles that are typical for those projects 1) I will test it and let you know. 2) As this seems not trival as a beginner, I decided to stick with your sensor. Thanks for your feedback. As a side note: Due to my extensive search I have found an interesting setup using a ESP8266 ESP 01 12V relai with a TZT ESP 01S Wifi module. The setup is really small and still seems to handle the 12 V just fine. But the documentation is not nearly as good as yours so nothing a bloody beginner like me can handle for now. ;)
I finally had the time to recreate your setup and it instantly worked out of the box as described thanks to your great description of the project. 🎉😊 I can confirm that it works with multiple of those Artic fans (I bought the PST version as they can be connected easily) What I found are two things: 1) If the relay switches from the off state to the on state, my fans ramp up to a high speed (which is rather loud) and within some seconds go to the calculated fan speed from your code. Does this happen for you, too or is this an issue on my side? I am wondering if a delay in the code when switching from off to on might help to prevent this!? Maybe the information which speed to choose according to the temp needs a moment to be calculated and send and within this time, it just ramps up to 100% speed!? 2) As I want to use this setup for my heaters within all of my rooms including bed rooms, I wonder if there is a more silent option fo a relay. I thought about MOSFET type Solid State Relays. Do you have experience in this area? This is by far the best solution for heater booster I found! Thanks again for your great work ❤
Yes you can use an ESP32 and because an ESP32 has hardware PWM built-in, it should be more reliable. However it would need you to tweak the configuration a bit to get working. There are example on the ESPHome web site (esphome.io/components/output/ledc.html). Your output would change to something like this: output: - platform: ledc pin: GPIO19 id: pwm_output But you would also need to set the frequency so that's best done in the fan turn on event, changed similar to this: fan: - platform: speed output: pwm_output name: "${device_description}" id: "the_fan" on_turn_on: - switch.turn_on: fan_relay - output.ledc.set_frequency: id: pwm_output frequency: "25000Hz" on_turn_off: - switch.turn_off: fan_relay This is totally untested and roughly thrown together to give you an idea of where to start figuring it out.
I've concluded that task is beyond my abilities at the moment! When I looked into it there was talk about needing pull-up resistors and calculating rpm based on how many pulses your particular fan uses per rotation. I gave up in the end because I didn't actually need the value for this project. It would be a nice to have detail, but I'm afraid I can't help sorry!
Having said that, I Googled it again and came across this the suggests you can just create a sensor in ESPHome using the PWM pin: community.home-assistant.io/t/wemos-d1-mini-get-fan-speed-rpm/234833/2
Have you tried the slider to adjust the fan speed? your circuit doesn't work for me. the fan keeps running without any change. Also the Wemos pin 0 of your circuit cannot be right because this is not a PWM supported pin..
Hi and yes the slider control from my fan entity works to control the speed for me. Pin 0 is correct and you can see that in the photo on my web site if you zoom in. The D1 Mini uses software PWM and almost all of the pins support it. I tested it on a few of them just to be certain.
@@SpeakToTheGeekTech funny. I have the same setup, just a dht11 instead of the BMP280 but the fan speed doesn't change. no idea what could be wrong. I've tested several fans. use your manual control sketch.
@@micha4038 I had the same and found out that if I also connect pin 3 of the fan to the D1 mini it works. sensor: platform: pulse_counter pin: D5 unit_of_measurement: 'RPM' id: "fan_speed" name: Fan Speed accuracy_decimals: 0 filters: - multiply: 0.5 # Depending on how many pulses the fan sends per round - should be 0.5 or 1 - try...