diff --git a/README.md b/README.md index 45a6fca..ec251cb 100755 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/gpioControl.js b/lib/gpioControl.js index f1047e0..bd813a6 100644 --- a/lib/gpioControl.js +++ b/lib/gpioControl.js @@ -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);