DEV Community

Cover image for Check the temperature of your Raspberry Pi on any OS with `pitemp`
Sebastian Alsina
Sebastian Alsina

Posted on

Check the temperature of your Raspberry Pi on any OS with `pitemp`

There's nothing funner then setting up your brand new Pi, especially if you picked up a starter kit that includes a case and a fan. A good case and fan allows you to overclock the Pi to higher speeds, allowing some pretty cool things.

If you're like, that brings some worry to table!

What if my Pi is getting too hot and it burns my board?

Although this scenario is not probable due to the Pi's smart cooling system that will automatically throttle the CPU if it reaches a temperature of about ~85° C, it's always a good idea to test the temperature of your Pi during initial set-up. When your Pi'c CPU is throttled, it slows down and loses its ability to perform at its max—that's not something we want happening.

I'd recommend checking the temperature of your machine somewhat regularly, just to ensure new processes aren't causing your machine to throttle.

Unfortunately, if you're running an OS other than Raspbian—the Raspberry Pi's recommended/default OS—the available tooling for checking temperature is limited.

Fortunately, there's a command line utility named pitemp (that I built) to quickly check the temperature of your machine. It's built in JavaScript and works on most OS's available for the Pi (Ubuntu, Linux Arch, etc.) and on almost all platforms, including macOS and Windows.

https://pitemp.vercel.app/

Here's how you can use pitemp. It's just a single line of code.

Usage

Requires NodeJS.

1. Using pitemp with npx

The suggested usage is npx, because that way you'll always be running the latest version of pitemp without installing it. npx is installed by default with npm. You can get npm by installing NodeJS.

npx pitemp

// pitemp is reporting every X seconds.
// Main: 62.322° C - Max: 62.322° C

2. Installing globally and running

You can install pitemp globally with your favorite package manager.

npm install -g pitemp
yarn global add pitemp

Then simply run pitemp with the command.

pitemp

// pitemp is reporting every X seconds.
// Main: 61.323° C - Max: 62.826° C

You can read the full documentation and view the flags available on the pitemp NPM page. pitemp is an open source tool built in Node.js. Drop it a star on Github!

Now you know how to ensure your Pi does not become deep fried. Run a stress test and see how high you can push it... with a decent fan, you should never hit 85° C or more—even if you're overclocked.

Once you're done with that, shoot me a follow on Twitter. Thanks for the read!

Top comments (0)