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

@alexkratky/rpi-info

v1.0.4

Published

Detect Raspberry Pi model

Downloads

5

Readme

@alexkratky/rpi-info

A simple package to detect if your app is currently running on Raspberry Pi and also to detect which one.

Installation

npm i @alexkratky/rpi-info
# or
yarn add @alexkratky/rpi-info

Usage

import { RaspberryPiInfo } from '@alexkratky/rpi-info';

const raspberryPiInfo = new RaspberryPiInfo();

console.log(raspberryPiInfo.detect());

Expected output on Raspberry Pi device:

{
    isRaspberry: true,
    model: '5',
    fullModelName: 'Raspberry Pi 5',
    fullModelNameWithRam: 'Raspberry Pi 5 - 4GB',
    ram: '4GB',
    manufacturer: 'Sony UK',
    revisionCode: 'c04170'
}

on non-Raspberry Pi device the output will be:

{
    isRaspberry: false,
    model: null,
    fullModelName: null,
    fullModelNameWithRam: null,
    ram: null,
    manufacturer: null,
    revisionCode: null
}

Custom usage

This package uses detection based on revision code presented in /proc/cpuinfo (you can list that on your machine by typing cat /proc/cpuinfo in your terminal) and uses that revision code to detect which model you are currently using. I will try to keep the list updated, but in case there is a new version of Raspberry Pi, or some custom, you can always pass additional revision codes to the constructor as the first parameter (You can add a completly new one, or override the existing):

import { RaspberryPiInfo } from '@alexkratky/rpi-info';

const raspberryPiInfo = new RaspberryPiInfo(
    {'c04170': { model: '0', ram: '128GB', manufacturer: 'Custom' }},
    {'customRevisionCode': { model: 'New Raspberry Pi 6?', ram: '16GB', manufacturer: 'Custom' }},
);

console.log(raspberryPiInfo.detect());

Expected output on Raspberry Pi device:

{
    isRaspberry: true,
    model: '0',
    fullModelName: 'Raspberry Pi 0',
    fullModelNameWithRam: 'Raspberry Pi 0 - 128GB',
    ram: '128GB',
    manufacturer: 'Custom',
    revisionCode: 'c04170'
}

By default, the fullModelName and fullModelNameWithRam start with 'Raspberry Pi', you can modify this behavior by passing the base name to the constructor as a second parameter:

import { RaspberryPiInfo } from '@alexkratky/rpi-info';

const raspberryPiInfo = new RaspberryPiInfo({}, 'Custom PI');

console.log(raspberryPiInfo.detect());

Expected output on Raspberry Pi device:

{
    isRaspberry: true,
    model: '5',
    fullModelName: 'Custom PI 5',
    fullModelNameWithRam: 'Custom PI 5 - 4GB',
    ram: '4GB',
    manufacturer: 'Sony UK',
    revisionCode: 'c04170'
}

Usage in commonjs

Recommended usage is in the module, but if you are using CommonJS, the import and the usage should look like this:

const rpiInfo = require('@alexkratky/rpi-info');

const raspberryPiInfo = new rpiInfo.RaspberryPiInfo();

console.log(raspberryPiInfo.detect());

Contributing

Pull requests are always welcomed.

With ❤️ by Alex Kratky

Contact webpage¨