Skip to content

gajdipajti/munin-rpi-temp

 
 

Repository files navigation

munin-rpi-internal-temp

  • Check the wiki page for wiring or the blog post in hungarian
  • Munin plugin for monitoring Raspberry Pi internal temperature: rpi-internal-temp
  • Munin plugin for monitoring a DS18B20 OneWire based temperature sensor connected to the Raspberry Pi: rpi-w1-temp

Munin plugin for monitoring temperature and humidity with an Aosong 2302, DHT11, DHT22 connected to the Raspberry Pi. This plugin uses the Adafruit binary from https://github.com/adafruit/Adafruit_Python_DHT

1. If you use the code

  • Please give a star, because it feels good that I helped someone. :)
  • If you need help, open an issue.

2. Installation (Hardware)

3. Installation (Software, setting up raspbianOS)

Chose only one method (3.1., 3.2, ...)

3.1. Using raspi-config

  1. In Interface Options enable 1-Wire.
  2. Save & Reboot
  3. Read the sensors manually:

cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves

My output looks like this:

pi@raspberrypi:~ $ cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves
28-000005c7df9c
28-000005c7c812
28-000005c7cf75
28-000005c7220d
28-0000048d5987
28-000005c7a30f

3.2. OR manually edit /boot/config.txt

  1. Add dtparam=spi=on and dtoverlay=w1-gpio,gpiopin=4 if they are not present.
  2. Save & Reboot

3.3. OrangePi Zero with Armbian - using armbian-config

  1. In System > Hardware enable spi-spidev, w1-gpio.
  2. Save & Reboot

3.4. OrangePi Zero with Armbian - edit /boot/armbianEnv.txt

Mine has the following lines:

overlays=analog-codec spi-spidev usbhost2 usbhost3 w1-gpio

param_w1_pin=PA6

param_w1_pin_int_pullup=1

4. Test the w1 network

Read the sensor IDs manually:

cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves

My output looks like this:

pi@raspberrypi:~ $ cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves
28-000005c7df9c
28-000005c7c812
28-000005c7cf75
28-000005c7220d
28-0000048d5987
28-000005c7a30f

5. Installation (munin-node and plugin)

  1. sudo apt install munin-node git
  2. git clone https://github.com/gajdipajti/munin-rpi-temp.git
  3. Copy the munin plugins from the local git repository to /etc/munin/plugins
    • sudo cp munin-rpi-temp/rpi-w1-temp /etc/munin/plugins/rpi-w1-temp
    • sudo cp munin-rpi-temp/rpi-internal-temp /etc/munin/plugins/rpi-internal-temp
    • sudo cp munin-rpi-temp/rpi-internal-freq /etc/munin/plugins/rpi-internal-freq
  4. Set the plugins executable:
    • sudo chmod a+x /etc/munin/plugins/rpi-w1-temp
    • sudo chmod a+x /etc/munin/plugins/rpi-internal-temp
    • sudo chmod a+x /etc/munin/plugins/rpi-internal-freq
  5. Edit the /etc/munin/munin-node.conf file:
    • Add or modify the following line: cidr_allow 192.168.0.0/16
  6. Edit the /etc/munin/plugin-conf.d/munin-node file:
    • Note: This step might be skipped if your device is on kernel version >=5.8.
    • Add the following lines:

      [rpi-*]

      user root

      group root

  7. Reload munin-node: sudo service munin-node restart
  8. Test sensor readout: sudo munin-run rpi-w1-temp
pi@raspberrypi:~ $ sudo munin-run rpi-w1-temp
temp1.value 22.750
temp2.value 28.500
temp3.value 24.812
temp4.value 22.125
temp5.value 27.687
temp6.value 24.000

5.1. Instead of direct copying you can use the following method also

  1. Copy the plugin files to /usr/share/munin/plugins and link them
    • sudo ln -sf /usr/share/munin/plugins/rpi-internal-temp /etc/munin/plugins/rpi-internal-temp
    • sudo ln -sf /usr/share/munin/plugins/rpi-internal-freq /etc/munin/plugins/rpi-internal-freq
    • sudo ln -sf /usr/share/munin/plugins/rpi-w1-temp /etc/munin/plugins/rpi-w1-temp

6. New sysfs entry in kernel 5.8

In kernel 5.8 a new sysfs entry was added to output only the temperature commit. The rpi-w1-temp plugin was updated to use this method when present. Please update your local plugin.

To read the temperature:

pi@raspberrypi:~ $ cat /sys/bus/w1/devices/28-0000048d5987/temperature
22750

And the root user access can be removed from the plugin-conf.d/munin-node file.

7. More nice to have w1-therm features

8. Other plugins in repository

8.1. Monitor accespoint

Use the rpi-hotspot-wlan0 script, tested on the OrangePi Zero with Armbian.

8.2. DHT sensors

I hate the DHT sensors. It will be redesigned from the ground up. But now do the Adafruit setup and copy the AdafruitDHT.py to /usr/local/bin Give exec permission: sudo chmod +x /usr/local/bin/Adafruit.py

9. Now obsolete stuff, kept for historical reasons

Previously we just loaded the w1-gpio and w1-therm kernel modules.

9.1. Kernel 3.18.* PROBLEM

The new Raspberry Pi kernel has switched to device trees, this will break the w1 module. link link link

9.2. Kernel 3.18.* FIX

Add the following lines to the end of /boot/config.txt to enable device trees:

dtoverlay=w1-gpio,gpiopin=4

9.3. Kernel 4.0.* DHT11 overlay

The current code is not compatible with the DHT11 overlay. I experimented with it, but 3 out of 5 reads have failed. link Just keep using the adafruit code.

9.4. Unexpected negative temperature values

About

Munin plugin for monitoring Raspberry Pi internal & external temperature

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%