A microcontroller, comprising: a processor; and instructions in a computer-readable medium, the instructions, when loaded and executed by the processor, cause the processor to: receive a power consumption value indicating power consumption of an electronic device (102; 200); receive a device temperature value and a temperature setpoint value of the electronic device; determine, based on the power consumption value and a stored previous power consumption value, a change value representing an amount that power consumption of the electronic device (102; 200) changed from a previous power consumption of the electronic device (102; 200); and control an output for cooling the electronic device (102; 200) using an output cooling control value for controlling a fan; characterized in that the processor is further configured to determine the output cooling control value based at least in part on the change value used in combination with a proportional-integrative-derivative, PID, control loop, wherein the device temperature value is subtracted from the temperature setpoint value and the result fed into the PID control loop; determine an adaptive gain value from a fan speed value, said stored previous power consumption value, and the device temperature value; iteratively process the adaptive gain value and a finite impulse response, FIR, filtered power consumption value to produce a continuously updated output signal comprising a predicted minimum fan speed based on the power usage of the electronic device as a function of time; and derivate the output signal to determine its slope and if the slope is negative, provide a reduction value to the PID control loop representing the amount the fan speed can be reduced and if the slope is positive, provide an incremental value to the PID control loop representing the amount the fan speed can be increased. a processor; and instructions in a computer-readable medium, the instructions, when loaded and executed by the processor, cause the processor to: receive a power consumption value indicating power consumption of an electronic device (102; 200); receive a device temperature value and a temperature setpoint value of the electronic device; determine, based on the power consumption value and a stored previous power consumption value, a change value representing an amount that power consumption of the electronic device (102; 200) changed from a previous power consumption of the electronic device (102; 200); and control an output for cooling the electronic device (102; 200) using an output cooling control value for controlling a fan; characterized in that the processor is further configured to determine the output cooling control value based at least in part on the change value used in combination with a proportional-integrative-derivative, PID, control loop, wherein the device temperature value is subtracted from the temperature setpoint value and the result fed into the PID control loop; determine an adaptive gain value from a fan speed value, said stored previous power consumption value, and the device temperature value; iteratively process the adaptive gain value and a finite impulse response, FIR, filtered power consumption value to produce a continuously updated output signal comprising a predicted minimum fan speed based on the power usage of the electronic device as a function of time; and derivate the output signal to determine its slope and if the slope is negative, provide a reduction value to the PID control loop representing the amount the fan speed can be reduced and if the slope is positive, provide an incremental value to the PID control loop representing the amount the fan speed can be increased. receive a power consumption value indicating power consumption of an electronic device (102; 200); receive a device temperature value and a temperature setpoint value of the electronic device; determine, based on the power consumption value and a stored previous power consumption value, a change value representing an amount that power consumption of the electronic device (102; 200) changed from a previous power consumption of the electronic device (102; 200); and control an output for cooling the electronic device (102; 200) using an output cooling control value for controlling a fan; characterized in that the processor is further configured to determine the output cooling control value based at least in part on the change value used in combination with a proportional-integrative-derivative, PID, control loop, wherein the device temperature value is subtracted from the temperature setpoint value and the result fed into the PID control loop; determine an adaptive gain value from a fan speed value, said stored previous power consumption value, and the device temperature value; iteratively process the adaptive gain value and a finite impulse response, FIR, filtered power consumption value to produce a continuously updated output signal comprising a predicted minimum fan speed based on the power usage of the electronic device as a function of time; and derivate the output signal to determine its slope and if the slope is negative, provide a reduction value to the PID control loop representing the amount the fan speed can be reduced and if the slope is positive, provide an incremental value to the PID control loop representing the amount the fan speed can be increased.