<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/i-wrote-a-540-line-c-program-to-control-the-fan-on-my-thinkcentre-m920q-dwfa2yyq6" -->

---
title: I wrote a 540-line C program to control the fan on my...
description: A homelab enthusiast built m920q-fanctl, a root-only C CLI tool that bypasses the read-only nct6683 kernel driver to directly control fan speed on the Lenovo...
canonical: https://daily.dev/posts/i-wrote-a-540-line-c-program-to-control-the-fan-on-my-thinkcentre-m920q-dwfa2yyq6
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: I wrote a 540-line C program to control the fan on my ThinkCentre M920q | daily.dev
og:description: A homelab enthusiast built m920q-fanctl, a root-only C CLI tool that bypasses the read-only nct6683 kernel driver to directly control fan speed on the Lenovo...
og:url: https://daily.dev/posts/i-wrote-a-540-line-c-program-to-control-the-fan-on-my-thinkcentre-m920q-dwfa2yyq6
og:image: https://api.daily.dev/og/posts/DwFA2Yyq6.png
og:image:alt: I wrote a 540-line C program to control the fan on my ThinkCentre M920q
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# I wrote a 540-line C program to control the fan on my ThinkCentre M920q

**[Priyaranjan Kumar](https://daily.dev/sources/xjigcoxf6dj2ksxgiebbe)** · [@priyaranjankumar](https://daily.dev/priyaranjankumar) · 2 min read · 7 upvotes · 0 comments

## Summary

A homelab enthusiast built m920q-fanctl, a root-only C CLI tool that bypasses the read-only nct6683 kernel driver to directly control fan speed on the Lenovo ThinkCentre M920q mini PC. The tool communicates with the Nuvoton NCT6686D Super I/O chip via /dev/port using raw register I/O, no kernel module or Python required. The hardest part was reverse-engineering the config-request handshake, discovering that the M920q needs a 0x00 completion byte instead of the 0x40 used by other NCT implementations, which otherwise silently resets the fan to auto mode. Safety checks include DMI verification, refusing to run if the hwmon driver is loaded, and blocking 0% PWM by default.

## Content

The Lenovo M920q is a great mini PC for homelabs, but its fan control is locked behind firmware with no user-facing control. The `nct6683` kernel driver exposes read-only sensors - you can _see_ the RPM, but you can't change it.

So I wrote [m920q-fanctl](https://github.com/priyaranjankumar/m920q-fanctl)- a root-only CLI that talks directly to the Nuvoton NCT6686D Super I/O chip through `/dev/port`. No kernel module, no DKMS, no Python. Just raw register I/O with a verified hardware transaction.

```
m920q-fanctl status    # check current state
m920q-fanctl set 50    # set fan to 50%
m920q-fanctl auto      # return to firmware control
```

The tricky part was the NCT6686D's config-request handshake. You can't just write a PWM value - you open a config window via register `0x0A01`, poll the engine status at `0x0CF8` until it's ready, set the mode and PWM, then close the window and verify. Get the completion byte wrong and the controller silently reverts your change.

I found that the M920q specifically needs `0x00` as the completion byte - the `0x40` used by other NCT implementations immediately resets the fan to auto. That one byte cost me a few hours.

Safety-wise, the tool refuses to run if the kernel hwmon driver is loaded (they'd race on the same I/O ports), checks DMI to confirm it's actually an M920q, and blocks 0% PWM by default.

`#c` `#linux` `#homelab` `#hardware` `#fan-control` `#lenovo`

## Similar posts on daily.dev

- [I use my keyboard knob to control my PC fans, and it's more practical than you think](https://daily.dev/posts/i-use-my-keyboard-knob-to-control-my-pc-fans-and-it-s-more-practical-than-you-think-jgf68scvv) · XDA Developers · 0 upvotes · 0 comments
- [ARCTIC Cooling Publishes ARCTIC Fan Controller Driver For Linux](https://daily.dev/posts/arctic-cooling-publishes-arctic-fan-controller-driver-for-linux-ojbfdii66) · Phoronix · 0 upvotes · 0 comments
- [ARCTIC Fan Controller Driver Expected To Land In Linux 7.2](https://daily.dev/posts/arctic-fan-controller-driver-expected-to-land-in-linux-7-2-jwqakjdwn) · Phoronix · 0 upvotes · 0 comments
- [Reverse-Engineering a AIO \[lovingcool dp 360 02\] Cooler’s LCD display manager.](https://daily.dev/posts/reverse-engineering-a-aio-lovingcool-dp-360-02-cooler-s-lcd-display-manager--gew4ekpmq) · Medium · 0 upvotes · 0 comments
- [My Fan Worked Fine, So I Gave it WiFi](https://daily.dev/posts/my-fan-worked-fine-so-i-gave-it-wifi-fd4lzfzab) · Hacker News · 1 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux), [#hardware](https://daily.dev/tags/hardware), [#c](https://daily.dev/tags/c), [#homelab](https://daily.dev/tags/homelab)

[View this post on daily.dev](https://daily.dev/posts/i-wrote-a-540-line-c-program-to-control-the-fan-on-my-thinkcentre-m920q-dwfa2yyq6)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/i-wrote-a-540-line-c-program-to-control-the-fan-on-my-thinkcentre-m920q-dwfa2yyq6","headline":"I wrote a 540-line C program to control the fan on my ThinkCentre M920q","text":"A homelab enthusiast built m920q-fanctl, a root-only C CLI tool that bypasses the read-only nct6683 kernel driver to directly control fan speed on the Lenovo ThinkCentre M920q mini PC. The tool communicates with the Nuvoton NCT6686D Super I/O chip via /dev/port using raw register I/O, no kernel module or Python required. The hardest part was reverse-engineering the config-request handshake, discovering that the M920q needs a 0x00 completion byte instead of the 0x40 used by other NCT implementations, which otherwise silently resets the fan to auto mode. Safety checks include DMI verification, refusing to run if the hwmon driver is loaded, and blocking 0% PWM by default.","url":"https://daily.dev/posts/i-wrote-a-540-line-c-program-to-control-the-fan-on-my-thinkcentre-m920q-dwfa2yyq6","datePublished":"2026-09-16T15:40:46.381Z","dateModified":"2026-09-16T15:42:23.935Z","author":{"@type":"Person","name":"Priyaranjan Kumar","url":"https://daily.dev/priyaranjankumar","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":810}},"image":"https://media.daily.dev/image/upload/s---TKSZlrr--/f_auto/v1789573247/posts/DwFA2Yyq6?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/xjigcoxf6dj2ksxgiebbe","name":"Priyaranjan Kumar"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Priyaranjan Kumar","item":"https://daily.dev/sources/xjigcoxf6dj2ksxgiebbe"},{"@type":"ListItem","position":3,"name":"I wrote a 540-line C program to control the fan on my ThinkCentre M920q"}]}
```

