Using PWM functions in Mongoose OS for fan control - SugarFreeOrbit/MosquittoMQTT GitHub Wiki

  1. Get yourself a 4-wire fan (it is supposed to be alright even with a 3-wire fan, but didn't work quite right for me).
  2. Connect the red wire with the power supply and the black wire with ground(GND).
  3. Connect the green wire with the pin which you mignt want to use later for reading the tachometric control.
  4. Connect the last wire with the pin that you want to use for sending the PWM signal.
  5. You need to add the PWM library to your Mongoose OS project and include it in the beggining of init.js.
  6. Now to control the PWN you simply use the following PWM.set(PIN_NUMBER, FREQUENCY, DUTY) (FREQUENCY is in hz). For a 4-wire fan you will need a frequency from 21kHz to 28kHz(the optimal is 25kHz), the higher the duty - the higher the speed(from 0 to 100).