質問編集履歴

3

訂正

2016/08/27 02:07

投稿

yu_polo
yu_polo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -1,18 +1,124 @@
1
- 実行過程で
1
+ AdafruitDHT.pyから温度用temp.py,湿度用humid.pyを作成
2
2
 
3
- "total.value 23.0"なくて
3
+ temp.py、tempスクリプト
4
4
 
5
- "total.value GENNUM='python /usr/local/bin/temp.py 222 4'
5
+ URL
6
6
 
7
+ blog.bnikka.com/raspberrypi/am2302dht22raspberrypi.html
8
+
9
+ ```ここに言語を入力
10
+
11
+ コード!/usr/bin/python
12
+
13
+ # Copyright (c) 2014 Adafruit Industries
14
+
15
+ # Author: Tony DiCola
16
+
17
+
18
+
19
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
20
+
21
+ # of this software and associated documentation files (the "Software"), to deal
22
+
23
+ # in the Software without restriction, including without limitation the rights
24
+
25
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+
27
+ # copies of the Software, and to permit persons to whom the Software is
28
+
29
+ # furnished to do so, subject to the following conditions:
30
+
31
+
32
+
33
+ # The above copyright notice and this permission notice shall be included in all
34
+
35
+ # copies or substantial portions of the Software.
36
+
37
+
38
+
39
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+
41
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42
+
43
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
+
45
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+
47
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+
49
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50
+
51
+ # SOFTWARE.
52
+
7
- とでる
53
+ import sys
54
+
55
+
56
+
57
+ import Adafruit_DHT
8
58
 
9
59
 
10
60
 
11
61
 
12
62
 
13
- ```
63
+ # Parse command line parameters.
14
64
 
65
+ sensor_args = { '11': Adafruit_DHT.DHT11,
66
+
67
+ '22': Adafruit_DHT.DHT22,
68
+
69
+ '2302': Adafruit_DHT.AM2302 }
70
+
71
+ if len(sys.argv) == 3 and sys.argv[1] in sensor_args:
72
+
73
+ sensor = sensor_args[sys.argv[1]]
74
+
75
+ pin = sys.argv[2]
76
+
77
+ else:
78
+
79
+ print('usage: sudo ./Adafruit_DHT.py [11|22|2302] GPIOpin#')
80
+
81
+ print('example: sudo ./Adafruit_DHT.py 2302 4 - Read from an AM2302 connected to GPIO #4')
82
+
15
- 引用しました、スクリプト。
83
+ sys.exit(1)
84
+
85
+
86
+
87
+ # Try to grab a sensor reading. Use the read_retry method which will retry up
88
+
89
+ # to 15 times to get a sensor reading (waiting 2 seconds between each retry).
90
+
91
+ humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
92
+
93
+
94
+
95
+ # Un-comment the line below to convert the temperature to Fahrenheit.
96
+
97
+ # temperature = temperature * 9/5.0 + 32
98
+
99
+
100
+
101
+ # Note that sometimes you won't get a reading and
102
+
103
+ # the results will be null (because Linux can't
104
+
105
+ # guarantee the timing of calls to read the sensor).
106
+
107
+ # If this happens try again!
108
+
109
+ if humidity is not None and temperature is not None:
110
+
111
+ print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity))
112
+
113
+ else:
114
+
115
+ print('Failed to get reading. Try again!')
116
+
117
+ sys.exit(1)
118
+
119
+ ```
120
+
121
+ ```ここに言語を入力
16
122
 
17
123
  #!/bin/sh
18
124
 
@@ -62,30 +168,6 @@
62
168
 
63
169
  fi
64
170
 
65
- echo "total.value $GETNUM";
171
+ echo "total.value $GETNUM";
66
172
 
67
-
68
-
69
- ###試したこと
70
-
71
-
72
-
73
- cd /usr/share/munin/plugins
74
-
75
- sudo nano temp
76
-
77
- 上記もスクリプト作成後、アクセス権を調整
78
-
79
- sudo chmod 755 temp
80
-
81
-
82
-
83
-
84
-
85
- 課題に対してアプローチしたことを記載してください
86
-
87
-
88
-
89
- ###補足情報(言語/FW/ツール等のバージョンなど)
90
-
91
- より詳細な情報
173
+ ```

2

書き方の訂正

2016/08/27 02:06

投稿

yu_polo
yu_polo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -1,15 +1,3 @@
1
- > 引用テキスト**__###ボールドテキスト__**###前提・実現したいこと
2
-
3
- ここに質問したいことを詳細に書いてください
4
-
5
- (例)PHP(CakePHP)で●●なシステムを作っています。
6
-
7
- ■■な機能を実装中に以下のエラーメッセージが発生しました。
8
-
9
-
10
-
11
- ###発生している問題・エラーメッセージ
12
-
13
1
  実行過程で
14
2
 
15
3
  "total.value 23.0"なくて
@@ -20,19 +8,7 @@
20
8
 
21
9
 
22
10
 
23
- ```
24
11
 
25
- エラーメッセージ
26
-
27
- ```
28
-
29
-
30
-
31
- ###該当のソースコード
32
-
33
- ```ここに言語を入力
34
-
35
- ここにご自身が実行したソースコードを書いてください
36
12
 
37
13
  ```
38
14
 

1

書き方の訂正

2016/08/24 03:02

投稿

yu_polo
yu_polo

スコア13

test CHANGED
File without changes
test CHANGED
File without changes