Skip to content

Commit

Permalink
add support for Raspberry Zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfonso committed Oct 8, 2024
1 parent 3b4435f commit 6ebaa81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ Connect such a sensor to a GPIO pin as described on the [node-dht-sensor](https:
PLACEHOLDER for the next version:
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (jangatzke) add support for gpios on Raspberry Zero.

### 2.0.1 (2024-10-07)
* (Garfonso) make gpio library required dependency
* (Garfonso) make errors clearer, if gpio library could not be initialized.
Expand Down
7 changes: 7 additions & 0 deletions lib/gpioControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const util = require('util');
const exec = util.promisify(require('node:child_process').exec);

function getRaspberryModelFromCpuInfo(cpuinfo) {
//Zero reports: Raspberry Pi Zero 2 W Rev 1.0
// RPi Zero family has a different naming.
// All Rpi Zero share the same ChipNum as RPi 1 and thus can all be handled as a Rpi 1.
if (cpuinfo.includes("Zero")) {
return 1;
}

const modelRegEx = /^Raspberry Pi (\d+) Model.*/mi;
const model = modelRegEx.exec(cpuinfo)[1];
return Number(model);
Expand Down

0 comments on commit 6ebaa81

Please sign in to comment.