Would anyone be willing to educate me on what I am doing wrong here or suggest a better alternative?
I have over extended my ESP32-S3’s (N8R2) ledc capability by wiring 5 motor driver boards (L298N - controlling 10 motors). I have read and proven that an S3 only has 8 available channels or 8 independent cases where I can use “ledc” which means I can use without issue, 4 motors with said code below. Anything more, than I get multiple motors running at once:
So obviously to most people I’m sure, the standard ESP32 is available with 16 channels which would let me run 8 motors independently and apparently I could use something like a PCA9685 16 Channel 12-bit PWM which would also give an additional 16 channels via i2c?
By this point I started getting AI involved as I found limited to no examples of other people making this mistake and thus possible ways around this. The general consensus of AI was that I could in theory just use two ledc per motor board by wiring them to the ENA/ENB pins but the code it offers just doesn’t work and I’m not that surprised:
This code snippet fails due to the pin_a/pin_b being “platorm: GPIO” - I think
ERROR: “ID ‘pump4_forward’ of type gpio::GPIOBinaryOutput doesn’t inherit from output::FloatOutput. Please double check your ID is pointing to the correct value.”
Seems to me I just need to add more channels via an additional i2c board or using a standard ESP32 but I was curious to see if anyone had anything to say on the topic.
I’m surprised that you got that much from AI.
It’s correct, L298N is supposed to be driven by PWM on ENA and static direction pins.
So normal Esp32 should be able to drive 16 motors.
That’s the problem with hbridge fan component. It doesn’t have the same logic, it’s using pwm on dir pins.
But do you really need that fan component?
I haven’t tested it yet using all 8 channels but it would appear to work based on this one example. However, I have two issues with this method:
Both the switch and the number (%) cards in home assistant do not retain the state you set. I.E. set the % to 90% but the card will always display 0
The speed at which a motor runs seems to run slower using the number % than the fan component. I.E. set both the number % card and the fan component card in home assistant to 50% and the speed of the motor configured to the fan component is faster. I think at 50% the number % card motor doesn’t even run
In this regard, I prefer how you interact with the fan component. Is there a way to adjust/resolve the above two points?
Instead for direction pins you can simply use gpio switch component, no need for separate template switch and output. If you want, you can also use interlocking, it would likely make switches easier to use.
Pwm duty cycle is NOT linear with motor speed. Fan component uses some conversion to get closer.
You can do something similar on the level lambda.