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 ...
This article describes a simple technique for using a processors PWM output to produce an analog control voltage that matches the load’s input range, thus maximizing control resolution. Most ...