I’ve got a solenoid that I’m trying to drive with a MOSFET. I want to avoid the ‘slam’ of the initial inrush so I’d like the PWM driving the MOSFET to use the 1s transition speed. I’ve made the below config and want it to be operated as a template switch to transition on, delay, then transition off, but I’m getting the error below.
Compiling .pioenvs/esphome_zdev_01/src/main.cpp.o
src/main.cpp: In lambda function:
src/main.cpp:178:23: error: 'class esphome::esp8266_pwm::ESP8266PWM' has no member named 'state'
if (pwm_output->state) {
^
src/main.cpp:183:3: warning: control reaches end of non-void function [-Wreturn-type]
});
^
*** [.pioenvs/esphome_zdev_01/src/main.cpp.o] Error 1
Awesome!! Thank you, this worked exactly as expected!
Driving a solenoid through a MOSFET is rather normal. It’s essentially a solid state way of doing it over using a relay. The unique thing is that I’m trying to “ramp up” the MOSFET rather treat it as a on/off switch. Maybe there is a better way to handle this while still having a switch front end.
So I tried looking for more info on the site and only saw a bit about loops in custom components section. If I’m understanding this correctly, on each loop of the mcu it will check to see if the light is on, and update the value of the switch (on/off) based on the actual status of the light (being on/off)?
It’s not as quiet/smooth as I’d like it to be, but it’s to be expected based on how a solenoid’s magnetic field works. It is probably about half as loud as was when it was just acting like a switch and sending the full 12v power to the solenoid. So in that regard, it is a great improvement.