-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path32_sensors.html
449 lines (302 loc) · 18.4 KB
/
32_sensors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Configuration using sensors — RPi-Monitor v2.13-r0</title>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="next" title="RPi-Monitor-LCD" href="33_lcd.html" />
<link rel="prev" title="Configuration examples" href="31_configuration_examples.html" />
<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-6853682829194266",
enable_page_level_ads: true
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-114314379-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-18642541-8');
</script>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav">
<img style="position: fixed; top: 0; right: 0; z-index: 100; height:300px; border: 0;" src="_images/wip.png">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> RPi-Monitor
</a>
<div class="version">
2.13
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="01_features.html">Keys features of RPi-Monitor</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="10_index.html">Getting started</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="20_index.html">Configuration</a></li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="30_index.html">Usages</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="31_configuration_examples.html">Configuration examples</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Configuration using sensors</a></li>
<li class="toctree-l2"><a class="reference internal" href="33_lcd.html">RPi-Monitor-LCD</a></li>
<li class="toctree-l2"><a class="reference internal" href="34_autentication.html">Authentication and secure access</a></li>
<li class="toctree-l2"><a class="reference internal" href="35_external.html">Non standard configuration</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="40_index.html">To go further</a></li>
</ul>
<hr />
<div style="padding: 0;">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"
data-ad-client="ca-pub-6853682829194266"
data-ad-slot="2876944524"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">RPi-Monitor</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li><a href="30_index.html">Usages</a> »</li>
<li>Configuration using sensors</li>
<li class="wy-breadcrumbs-aside">
<!-- User defined GitHub URL -->
<a href="https://github.com/XavierBerger/RPi-Monitor/blob/develop/docs/source/32_sensors.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="configuration-using-sensors">
<h1>Configuration using sensors<a class="headerlink" href="#configuration-using-sensors" title="Permalink to this headline">¶</a></h1>
<div class="section" id="dht11-temperature-and-humidity-sensor">
<h2>DHT11 temperature and humidity sensor<a class="headerlink" href="#dht11-temperature-and-humidity-sensor" title="Permalink to this headline">¶</a></h2>
<div class="section" id="overview">
<h3>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h3>
<p>In this chapter we will see how to connect a DHT11 or DHT22 Temperature and
Humidity sensor and configure <strong>RPi-Monitor</strong> to present and draw the outputs.</p>
<p>We will also see how to steup dual-axis.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p>Adafruit created a very good tutorial explaining how to use DHT11 or DHT22.</p>
<p class="last">This tutorial is available at this
<a class="reference external" href="http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/wiring">here</a>.</p>
</div>
</div>
<div class="section" id="electronic-assembly">
<h3>Electronic assembly<a class="headerlink" href="#electronic-assembly" title="Permalink to this headline">¶</a></h3>
<p>This electronic assembly is quite simple and will need:</p>
<ul class="simple">
<li>1 x DHT11 or 1 x DHT22</li>
<li>1 x 4.7k resistor</li>
</ul>
<p>Plug them as described in the following schema:</p>
<div class="figure align-center" id="id1">
<a class="reference internal image-reference" href="_images/sensor001.png"><img alt="_images/sensor001.png" src="_images/sensor001.png" style="width: 400px;" /></a>
<p class="caption"><span class="caption-text">Schema extracted from Adafruit but using GPIO #27 instead of GPIO #4</span></p>
</div>
</div>
<div class="section" id="software-installation">
<h3>Software installation<a class="headerlink" href="#software-installation" title="Permalink to this headline">¶</a></h3>
<p>Thanks to Adafruit ( again ;-) ) the installation is quite simple and can be
done with two command lines.</p>
<p>Download Adafruit_DHT form Adafruit’s github repository and copy is in <code class="docutils literal"><span class="pre">/usr/bin</span></code> as follow:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wget</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">goo</span><span class="o">.</span><span class="n">gl</span><span class="o">/</span><span class="n">oadpl</span> <span class="o">-</span><span class="n">O</span> <span class="n">Adafruit_DHT</span>
<span class="n">sudo</span> <span class="n">cp</span> <span class="n">Adafruit_DHT</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="nb">bin</span><span class="o">/</span>
</pre></div>
</div>
<p>To test the electronic assembly and the software installation execute the
following command (for DHT11):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>pi@raspberrypi ~ $ sudo Adafruit_DHT 11 27
Using pin #17Data (40): 0x28 0x0 0x18 0x0 0x40
Temp = 24 *C, Hum = 40 %
</pre></div>
</div>
<p>You should see the information about temperature and humidity displayed as shown upper.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The DHT11 and DHT22 sensors will only respond every second so if you
are not getting data, be sure to wait few seconds before trying again.</p>
</div>
</div>
<div class="section" id="rpi-monitor-configuration">
<h3>RPi-Monitor configuration<a class="headerlink" href="#rpi-monitor-configuration" title="Permalink to this headline">¶</a></h3>
<p>Let’s now use this information and add humidity graphs on existing temperature graph.</p>
<p>We first have to extract the data. This is done like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">dynamic</span><span class="o">.</span><span class="mf">1.</span><span class="n">name</span><span class="o">=</span><span class="n">humidity</span>
<span class="n">dynamic</span><span class="o">.</span><span class="mf">1.</span><span class="n">source</span><span class="o">=</span><span class="n">Adafruit_DHT</span> <span class="mi">11</span> <span class="mi">27</span>
<span class="n">dynamic</span><span class="o">.</span><span class="mf">1.</span><span class="n">regexp</span><span class="o">=</span><span class="n">Hum</span> <span class="o">=</span> <span class="p">(</span>\<span class="n">S</span><span class="o">+</span><span class="p">)</span>
<span class="n">dynamic</span><span class="o">.</span><span class="mf">1.</span><span class="n">postprocess</span><span class="o">=</span>
<span class="n">dynamic</span><span class="o">.</span><span class="mf">1.</span><span class="n">rrd</span><span class="o">=</span><span class="n">GAUGE</span>
</pre></div>
</div>
<p>We will now add the humidity curve into the graph of temperature.
This can be done with the configuration bellow:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">web</span><span class="o">.</span><span class="n">statistics</span><span class="o">.</span><span class="mf">1.</span><span class="n">content</span><span class="o">.</span><span class="mf">1.</span><span class="n">title</span><span class="o">=</span><span class="n">humidity</span>
<span class="n">web</span><span class="o">.</span><span class="n">statistics</span><span class="o">.</span><span class="mf">1.</span><span class="n">content</span><span class="o">.</span><span class="mf">1.</span><span class="n">ds_graph_options</span><span class="o">.</span><span class="n">humidity</span><span class="o">.</span><span class="n">label</span><span class="o">=</span><span class="n">Humidity</span> <span class="p">(</span><span class="o">%</span><span class="p">)</span>
<span class="n">web</span><span class="o">.</span><span class="n">statistics</span><span class="o">.</span><span class="mf">1.</span><span class="n">content</span><span class="o">.</span><span class="mf">1.</span><span class="n">ds_graph_options</span><span class="o">.</span><span class="n">humidity</span><span class="o">.</span><span class="n">yaxis</span><span class="o">=</span><span class="mi">2</span>
<span class="n">web</span><span class="o">.</span><span class="n">statistics</span><span class="o">.</span><span class="mf">1.</span><span class="n">content</span><span class="o">.</span><span class="mf">1.</span><span class="n">graph_options</span><span class="o">.</span><span class="n">y2axis</span><span class="o">=</span><span class="p">{</span> <span class="n">position</span><span class="p">:</span> <span class="s2">"right"</span><span class="p">,</span> <span class="nb">min</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">max</span><span class="p">:</span> <span class="mi">100</span> <span class="p">}</span>
</pre></div>
</div>
<p>As the unit are different than the one existing on the initial axis,
we will add a second axis for the percentage of humidity. This is the purpose
of the two last lines of the configuration bellow.</p>
<p>The first line is defining the usage of axis number 2 for the humidity.</p>
<p>The last line is defining how this graph should be drawn: On the right,
starting from 0 up to 100.</p>
<p><code class="docutils literal"><span class="pre">graph_options</span></code> can have other usefull option. They are described in the
documentation of <a class="reference external" href="http://javascriptrrd.sourceforge.net/docs/javascriptrrd_v0.6.3/doc/lib/rrdFlot_js.html">javascriptrrd</a>.</p>
<p>After restarting RPi-Monotor with the command:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">service</span> <span class="n">rpimonitor</span> <span class="n">restart</span>
</pre></div>
</div>
<p>You will see a new curve in Temperature graph as shown in the screenshot bellow:</p>
<div class="figure align-center" id="id2">
<a class="reference internal image-reference" href="_images/sensor002.png"><img alt="_images/sensor002.png" src="_images/sensor002.png" style="width: 400px;" /></a>
<p class="caption"><span class="caption-text">Graph with 2 Y axis: °C in left axis and % humidity (fixed from 0% to 100%)
on right axis</span></p>
</div>
</div>
</div>
<div class="section" id="ds18b20-1wire-temperature-sensor">
<h2>DS18B20 1wire temperature sensor<a class="headerlink" href="#ds18b20-1wire-temperature-sensor" title="Permalink to this headline">¶</a></h2>
<div class="admonition-todo admonition" id="index-0">
<p class="first admonition-title">Todo</p>
<p class="last">old conf: to be updated</p>
</div>
<p>Add other graphs from additional sources: external temperature probe</p>
<p>Let’s build a little electronic device to measure the room temperature and add this in the temperature graph.
Do do that, you will need:</p>
<blockquote>
<div>1 x DS18B20
1 x 4.7k resistor</div></blockquote>
<p>Plug them as described in the following schema extracted from Adafruit Lesson 11:</p>
<dl class="docutils">
<dt>Lets first load the kernel module required to get the information from this probe:</dt>
<dd>sudo modprobe gpio
sudo modprobe w1-gpio
sudo modprobe w1-therm</dd>
<dt>First we have to identify the id of our probe:</dt>
<dd>ls /sys/bus/w1/devices/
28-000004fe1847 w1_bus_master1</dd>
<dt>the id is: 28-000004fe1847. Let’s now check if we can get the temperature:</dt>
<dd>cat /sys/bus/w1/devices/28-000004fe1847/w1_slave
5a 01 4b 46 7f ff 06 10 a3 : crc=a3 YES
5a 01 4b 46 7f ff 06 10 a3 t=21625</dd>
</dl>
<p>It looks to work. So now we need to extract the the numbers ending the second line (21625). The regular expression will then be t.(d+)$. I’ll not do a course about what a regexp is there are many site on the internet explaining it.
Note: In version 1.x of RPi-Monitor it is prohibited to use = in regular expression.</p>
<p>To add a graph to RPi-Monitor statistic, we need to create a new section. Let’s call it
[room_temperature]. Then we have to declare the new data name room_temp, its source
/sys/bus/w1/devices/28-000004fe1847/w1_slave and the associated regular expression t.(d+)$.
The line to append will look like that:</p>
<blockquote>
<div># Room temperature
[room_temperature]
room_temp=/sys/bus/w1/devices/28-000004fe1847/w1_slave=t.(d+)$</div></blockquote>
<dl class="docutils">
<dt>Restart RPi-Monitor with the following command and it is done:</dt>
<dd>sudo service rpimonitor restart</dd>
</dl>
<p>A new graph is available in statistics (wait a little bit to have data and drawing):</p>
<p>Use zoom feature to see the freshly added data.
If you want to add a curve into the Temperature graph, it is possible by adding
the KPI line into the section [temperature] as describe bellow:</p>
<blockquote>
<div>[temperature]
soc_temp=/sys/devices/virtual/thermal/thermal_zone0/temp=(.*)
home_temp=/sys/bus/w1/devices/28-000004fe1847/w1_slave=t.(d+)$</div></blockquote>
<dl class="docutils">
<dt>It will then be required to delete the associated rrd file:</dt>
<dd>sudo rm /usr/share/rpimonitor/web/stat/temperature.rrd</dd>
</dl>
<p>Restarting RPi-Monitor will regenerate this file with the two describes temperature. After waiting some time to let data to be added, you will have a graph with two temperatures as in the screenshot bellow:</p>
<p>soc_temp and home_temp drawn on the same graph</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="33_lcd.html" class="btn btn-neutral float-right" title="RPi-Monitor-LCD" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="31_configuration_examples.html" class="btn btn-neutral" title="Configuration examples" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2018, Xavier Berger.
Last updated on Mar 18, 2018.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-6853682829194266"
data-ad-slot="2876944524"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'',
LANGUAGE:'None',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ''
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enableSticky();
});
</script>
</body>
</html>