When you want to connect an IoT device to anything (or, for that matter, anything to anything), you should take a serious look at Node-RED, a free, open source visual process wiring system from IBM ...
Most microcontrollers have a pulse-width modulator (PWM) output that can effectively drive variable output loads such as proportional solenoid valves, motors, or light dimmers. You control these loads ...