My ADSB Receiver Box – Temperature Sensors – Upgrade 2

Reconfiguring collectd for two more temperature sensors

This chapter is applicable only for the ADSB receiver portal that comes with the OS image linked on page 1.

First we will configure the collectd service to read and log the additional two temperature sensors. So we edit the configuration at /etc/collectd/collectd.conf. Add the following lines to load the required curl plugin and its configuration.

# Load additional plugins for temperature sensors
LoadPlugin curl

# Read temperature from 1-wire sensors
<Plugin curl>
  <Page "temp">
    URL "file:///sys/bus/w1/devices/10-000800507da4/w1_slave"
      <Match>
        Regex "t=(-?[0-9]+)"
        DSType "GaugeLast"
        Type gauge
        Instance "inbox"
      </Match>
  </Page>
  <Page "temp">
    URL "file:///sys/bus/w1/devices/10-0008008d2583/w1_slave"
      <Match>
        Regex "t=(-?[0-9]+)"
        DSType "GaugeLast"
        Type gauge
        Instance "outside"
      </Match>
  </Page>
</Plugin>

Here again, you need to change the URLs to point to the sensors data folder, depending on its serial number. The regex in this configuration will read the temperature value from the end of the second line in sensor readout. Save and restart the collectd service with $ sudo service collectd force-reload. You can check the correct operation in the collectd data folder at /var/lib/collectd/rrd/localhost. There should be a new folder curl-temp with two files inside, gauge-inbox.rrd and gauge-outside.rrd.

Changing  the shell script for graph generation

Changing the shell script for graph generation is the last step to include our two new temperature sensors into the ADSB receivers performance graphs. In the referenced OS image the portal uses a git repository at /home/pi/adsb-receiver/build/portal/graphs that includes the shell script make-collectd-graphs.sh. That is what we need to edit. Inside there are two functions, starting at line 277, that needs to be replaced with the following text:

temp_graph_imperial() {
  rrdtool graph \
  "$1" \
  --start end-$4 \
  --width 480 \
  --height 200 \
  --step "$5" \
  --title "Temperature" \
  --vertical-label "Degrees Fahrenheit" \
  --lower-limit -5 \
  --upper-limit 215 \
  --rigid \
  --units-exponent 1 \
  "DEF:tcpu=$2/gauge-cpu_temp.rrd:value:MAX" \
  "DEF:tbox=/var/lib/collectd/rrd/localhost/curl-temp/gauge-inbox.rrd:value:MAX" \
  "DEF:tout=/var/lib/collectd/rrd/localhost/curl-temp/gauge-outside.rrd:value:MAX" \
  "TEXTALIGN:center" \
  "CDEF:tcpua=tcpu,1000,/" \
  "CDEF:tcpub=tcpua,1.8,*" \
  "CDEF:tcpuc=tcpub,32,+" \
  "LINE1:tcpuc#00ff00:CPU" \
  "CDEF:tboxa=tbox,1000,/" \
  "CDEF:tboxb=tboxa,1.8,*" \
  "CDEF:tboxc=tboxb,32,+" \
  "LINE1:tboxc#0000ff:Inside Box" \
  "CDEF:touta=tout,1000,/" \
  "CDEF:toutb=touta,1.8,*" \
  "CDEF:toutc=toutb,32,+" \
  "LINE1:toutc#ff0000:Outside" \
  "COMMENT: \n" \
  "COMMENT: \n" \
  --watermark "Drawn: $nowlit";
}

temp_graph_metric() {
  rrdtool graph \
  "$1" \
  --start end-$4 \
  --width 480 \
  --height 200 \
  --step "$5" \
  --title "Temperature" \
  --vertical-label "Degrees Celcius" \
  --lower-limit -20 \
  --upper-limit 100 \
  --rigid \
  --units-exponent 1 \
  "DEF:tcpu=$2/gauge-cpu_temp.rrd:value:MAX" \
  "DEF:tbox=/var/lib/collectd/rrd/localhost/curl-temp/gauge-inbox.rrd:value:MAX" \
  "DEF:tout=/var/lib/collectd/rrd/localhost/curl-temp/gauge-outside.rrd:value:MAX" \
  "CDEF:tcpufin=tcpu,1000,/" \
  "CDEF:toutfin=tout,1000,/" \
  "CDEF:tboxfin=tbox,1000,/" \
  "TEXTALIGN:center" \
  "LINE1:tcpufin#00ff00:CPU" \
  "LINE1:toutfin#ff0000:Outside" \
  "LINE1:tboxfin#0000FF:Inside Box" \
  "COMMENT: \n" \
  "COMMENT: \n" \
  --watermark "Drawn: $nowlit";
}

Save the changed shell script and the next cron run that calls it will create graphs with our two new temperature readings. Resulting in this:

Temperature plot, CPU + two DS1820 sensors

That example with my ADSB receiver box has demonstrated how to add 1-wire temperature sensors to the Raspberry Pi, collect their readings with collectd service and plot nice graphs using rrdtool.

See also:

My ADSB Receiver Box

My ADSB Receiver Box – GPS Precision Time – Upgrade 1

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments will be moderated! Spam deleted immediately!
Before you submit form:
Human test by Not Captcha