npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pi4-fan-control

v1.1.0

Published

Control the Raspberry Pi 4 Case Fan by temperature

Downloads

0

Readme

pi4-fan-control

Run the fan when the temperature gets high

This module is designed to be installed globally and will compile to a single executable called fan which will probably be in /usr/local/bin.

The executable can be used to turn the fan on or off but is primarily designed to be run out of systemd to monitor the temperature and turn the fan on and off as necessary.

The program was written for the pi4 with the official case fan but should work on any fan with its control set to a single gpio pin.

It will work on Ubuntu on the pi4 where none of the official solutions seems to do the job. For wiring of the case fan, please see the page at raspberrypi.com.

Install

npm install -g pi4-fan-control

Usage

fan [options] [on|off]
    Run without [on|off], the fan program will turn the fan on and off
      depending on temperature
    fan on  - Turn the fan on and exit
    fan off - Turn the fan off and exit
    options:
       -h --help:       Show this message
       -v --version:    Display version and exit
       -x --max:        Temperature to turn the fan on    (default: 85)
       -n --min:        Temperature to turn the fan off   (default: 80)
       -p --pin         Pin to use for control            (default: 14)
       -y --delay       Polling frequency in seconds      (default:  2)
       -s --show        Display on/off messages on stdout (default: off)
       -d --debug       Turn on debugging mode            (default: off)

Running from systemd

You will need to create a service file: /etc/systemd/system/pi4-fan.service.

The contents should be something like:

[Unit]
Description=Fan controller for the pi4

[Service]
Type=notify
User=root
Group=root
ExecStart=/usr/local/bin/fan
TimeoutStartSec=60
NotifyAccess=all
Restart=always
KillSignal=SIGTERM
TimeoutStopSec=20
RestartSec=20

[Install]
WantedBy=multi-user.target

If you want a lower max/min temperature setting, add, for example --max 80 --min 72 to the ExecStart line.

If you want the fan on/off messages to be logged to the journal, add --show to the ExecStart line. They can then be seen with sudo journalctl -xe -u pi4-fan.

Having created this file, please run the following commands:

$ sudo systemctl daemon-reload
$ sudo systemctl enable pi4-fan.service
$ sudo systemctl start  pi4-fan.service
$ sudo systemctl status pi4-fan.service

This should show the service as running.

Node version issue

As of the time of writing, pkg-fetch does not support node version 17. Please either revert to node version 16 or run the javascript file directly from node, rather than the executable.

Changelog

v1.0.0: First public release
v1.0.2: Documentation fixes only
v1.1.0: Added the --show switch

Problems

Any issues or comments would be appreciated at Github.