ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
308 stars 18 forks source link

CPU temperature of -40° on Raspberry Pi Model B Rev 2 #74

Closed tgilbert09 closed 3 years ago

tgilbert09 commented 3 years ago

Hi @ebaauw,

Thank you for creating and maintaining RPi. My Pi controls lights - it's great!

Set-up

I am running on a Raspberry Pi Model B Rev 2. Here is my current /var/lib/homebridge/config.json:

"hosts": [
    {
        "host": "localhost",
        "name": "Raspberry Pi",
        "hidden": false,
        "noPowerLed": true,
        "noSmokeSensor": true,
        "devices": [
            {
                "device": "light",
                "name": "Lights",
                "gpio": 4
            }
        ]
    }
],

Issue

With "hidden": false in the above config, the warning message: warning: /sys/class/leds/led1/brightness: cannot open: ENOENT no such file or directory is continually printed to the Homebridge Logs (with "noPowerLed": true). This warning seems to cause the Home app to report a CPU temperature of -40°.

Running ls /sys/class/leds/ returns default-on led0 mmc0 i.e. the warning is correct - led1 does not exist - perhaps due to my Pi being an older generation!

Possible workaround to fix temperature readings

This worked for me:

  1. Change /sys/class/leds/led1/brightness to /sys/class/leds/led0/brightness in /usr/local/lib/node_modules/homebridge-rpi/lib/RpiInfo.js. (Opened RpiInfo.js with sudo to save it).
  2. Restart Homebridge

End result: warning message no longer shows in the Homebridge Logs and correct CPU temperature is shown in the Home app.

New issues caused by workaround (only if "noPowerLed": false)

If "noPowerLed": false then Homebridge Log error: Raspberry Pi Power LED: error: FO (104): no permission to access file (-137)

I believe led0 is the one (out of five) LED on the Raspberry Pi Model B Rev 2 which is user controllable (led0 being ACT (or OK), usually an SD card indicator) but it looks like the trigger in /sys/class/leds/led0/trigger needs to be deactivated first. Source: https://www.raspberrypi.org/forums/viewtopic.php?t=12530

This is as far as I have gotten (I'm new to this).

Thanks again for RPi!

ebaauw commented 3 years ago

Does led0 control the (red) power LED? It's the (green) disk activity LED on the Pi 3B, 3B+ and 4B. Sorry, I don't have any older models to verify.

Hm, looks like the model A, model B (rev 1), and model B (rev 2) have the power LED hard-wired to 3.3V, see e.g.: https://www.raspberrypi-spy.co.uk/2013/02/raspberry-pi-status-leds-explained/. I'm afraid, best I can do is not expose the Lightbulb service on those RPis.

Raspberry Pi Power LED: error: FO (104): no permission to access file (-137)

You need to configure pigpiod and add permission to write the file, see Release Notes and README.

ebaauw commented 3 years ago

Fixed in v1.2.7.

tgilbert09 commented 3 years ago

Temperature is fixed on my Model B Rev 2 with version 1.2.7!

With:

  1. RPi updated to 1.2.7 (which discarded my previous workaround changes in /usr/local/lib/node_modules/homebridge-rpi/lib/RpiInfo.js)
  2. A Homebridge restart

Does led0 control the (red) power LED?

I think led0 is the same on Model B Rev 2 (a green SD activity LED, labelled ACT in the link sent by @ebaauw).

I'm afraid, best I can do is not expose the Lightbulb service on those RPis.

That works, it's an old Pi - I appreciate the GPIO support.

I set "noPowerLed": false to see what would happen. It acts identically to "noPowerLed": true - as expected! I'd possibly add a printout to the Homebridge Log if "noPowerLed": false AND running on old hardware?

Thanks for the support!