i build a smart ventilation for my bathroom with 2 PC Fans. It all runs properly but i cant control the fan speed with PWM. Im using the Arctic P12 MAX Fans. For testing i used another PWM Fan and i could controll the Speed with PWM. But with the Arctic Fan it just turns off if i put it to 99%. On 100% it runs with full power.
The Arctic Fans have a 0% Mode which shuts them off at <2% PWM thats why i bought them. But they shut off way to early.
I tested the Fan on my Computer and it worked, but it would shut off when lowering the Power to 50% or less in the Fan Controll Software. I could live with that and fit it in software but currently i cant controll the Fans at all in ESPHome.
12v are directly from the Powersupply. The PWM Signal is from the ESP32 itself. I guess some Fans dont like the 3.3V PWM Signal and need 5V wich the ESP cant Provide.
Maby a Levelshifter could help ?
I have tried varying the Frequencie, but it didnt help.
Absolutely worth to try.
I remember I tried PWM with open drain pin mode many years ago on arduino framework and it didn’t work. Things might be different now though.
I tried that but sadly it didnt help. Code compiled but it is still shutting off the Fan at 99% PWM Signal.
I dont have any transistors available and i think of just swapping the fans out for something idfferent. In Testing every other Fan i tried worked. Just those Artics didnt. Little bit frustrating because i know that they should work but i dont know how
So you configured the pin OUTPUT_OPEN_DRAIN ?
Disconnect the pin from fan, set the PWM at 50%, 25kHz and measure the pin voltage with multimeter. If it’s stable 1.65V, open drain LEDC approach doesnt work, if you get some lower fluctuating or zero voltage, it works.
Also, try without servo output configuration to be sure esphome doesn’t give them adjacent LEDC channels (which share same frequency). Or add option channel: 4
to your fan ledc output config.
It worked: I assigned different Channels to Servo and Fans and used the open_drain function. That worked, thank you so much
Thanks to @tom_l and @Karosm for the Solution. I will reference this post as the Solution because it has the working code in it, but credits belong to those guys <3
This is the code that worked for future reference:
Nice you got it working. For my curiosity could you give it a try without open_drain: true
to confirm if the problem was just adjacent LEDC channels or push-pull PWM.
Thats kind of the correct suggestion but, it can be simplified much more. Logic shifters are just a group of transistors which typically come only as small as 4 channel modules commonly. Thats kind of overkill and wasteful to use a logic shifter especially if its 4+ channels and you only need 1 channel.
Instead someone only needs a simple transistor or moafet to achieve the same output. Depending on how much someone does DIY stuff or plans to do, it cab be a good idea to pick up one of the variety packs of transistors, mosfets, resistors, etc so that little problems like this dont completely stop a project in its tracks to wait on components.
I personally use and really like these mostly because of the organizer they come in and each one completely closes so that you cant have accidental mixing between different components. Component variety kit
Also if your not familiar with these mosfet modules you can buy for very little money, these things are extremely useful to have around IMO and i use them all the time because they can control so much stuff!
They come in single channel modules or 4 channel modules most commonly. Mosfet module
It all stores away nicely when not being used too.
Ya, that’s true but, transistors are dirt cheap and if im going to risk burning something up from pulling excessive mAh then id rather smoke a .01 cent transistor personaly.
The main reson for my post though was a bit more deceptive though… Muahahaha!! (Evil laugh) im working on it…
Using transistors/mosfets are something that anyone wanting to DIY stuff is going to need to have a good deal of understanding and some practice and is why i was motivating them that direction, plus i dont believe that open-drain is capable of driving something that would require a PNP type transistor is it? Yes, i realize that NPN type control is far more common but… when those dang situations come up and your way rusty, they can be a PITA or thas how it goes for me if i dont keep knowledge circulating up there where my hat holder is.