Code Monkey home page Code Monkey logo

orangepi-pwm's Introduction

Connection diagram

OrangePi PWM fan control

The purpose of this project is to manage to control fan speed based on the temperature of the SOC for Orange Pi SBC.

The solution is tested and currently running on OrangePi5 but you should not have any issues runnig it on older Orange Pi 4 or never Orange Pi 5B or Orange Pi 5 Plus.

Prerequisites

For start you need to use any PWM enabled fan. In my case I am using Noctua NF-A4x10 5V PWM but you should be good with pretty much any fan that supports PWM. Connect fan to Orange Pi 5 GND and 5V pins GPIO pins. PWM should be connected to GPIO7 which you will use to control the value.

How does it work?

Once the configured temperature threshold is reached, process will set PWM value associated with that threshold. Temperature value is checked on configurable period which is 1 second by default but can be changed.

OrangePi.PWM.Service

This project is a proper service library. It is recommended to run it as compiled binary.

All configurations are in appsettings.json configuration file. Once peoject is published, in order to change any or the paramaters you do not need to stop and start tr process. Confiuration values will be automatically reloded once configuration/setting file changes are saved. To run it as a systemd service use the followin service configuration

[Unit]
Description=Run PWM control

[Service]
ExecStart=%h/.dotnet/dotnet /etc/orangepi-pwm/OrangePi.PWM.Service.dll
WorkingDirectory=/etc/orangepi-pwm
User=root
Group=0
Type=simple
Restart=no

[Install]
WantedBy=multi-user.target

Place your .service file to /etc/systemd/system directory on the Linux host.

To setup and start the service run the following commands

systemctl daemon-reload
systemctl enable orangepi-pwm.service
systemctl start orangepi-pwm.service

While service is runnig you can check recent logs and service status

systemctl status orangepi-pwm.service

Configuring temperature thresholds

Predefined temperature thresholds and PWM values for each threshold are configured in appsettings.json file.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "ServiceConfiguration": {
    "wPi": 2,
    "IntervalSeconds": 1,
    "ExitValue": 0,
    "TemperatureConfigurations": [
      {
        "Temperature": 0,
        "Value": 0
      },
      {
        "Temperature": 30,
        "Value": 100
      },
      {
        "Temperature": 40,
        "Value": 300
      },
      {
        "Temperature": 50,
        "Value": 400
      },
      {
        "Temperature": 60,
        "Value": 500
      },
      {
        "Temperature": 70,
        "Value": 800
      },
      {
        "Temperature": 80,
        "Value": 1000
      }
    ]
  }
}

If you want to update thresholds or PWM values you just need to update values in appsettings.json file without need to restart the service. New values will be picked up automatically once you save the file.

orangepi-pwm's People

Contributors

dejan-marcura avatar dejanstojanovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

orangepi-pwm's Issues

Cant get it to run

Hi, i just bought an Orangepi 5 plus nad tried to install dotnet on the debian12 image.
the system says i have it installed but the status says an error. Any idea ?
i have 2 files in the /etc/systemd/system/ folder

  1. the orangepi-cpu-fan.service
  2. appsettings.json
    Screenshot_2024-03-01_11-53-59
    Screenshot_2024-03-01_11-54-49

Documentation is confusing

This project is a proper service library. It is recommended to run it as compiled binary.

How do I compile? How do I install compiled binary and where?

All configurations are in appsettings.json configuration file.

What directory should I put this file?

Once peoject is published

How it is published?

. Confiuration values will be automatically reloded once configuration/setting file changes are saved.

Which file and where?

To run it as a systemd service use the followin service configuration

What should be the file name?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.