質問編集履歴
4
タブを一つ削除した
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
3
スケッチを表示しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,6 +28,8 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
+
|
32
|
+
|
31
33
|
AtlasScientific社のECセンサは、下記の通りです。
|
32
34
|
|
33
35
|
```ここに言語を入力
|
2
スケッチを表示しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,12 +28,102 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
AtlasScientific社のECセンサは、
|
31
|
+
AtlasScientific社のECセンサは、下記の通りです。
|
32
|
+
|
32
|
-
|
33
|
+
```ここに言語を入力
|
34
|
+
|
33
|
-
|
35
|
+
#include <Ezo_i2c.h> //include the EZO I2C library from https://github.com/Atlas-Scientific/Ezo_I2c_lib
|
36
|
+
|
37
|
+
#include <Wire.h> //include arduinos i2c library
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Ezo_board EC = Ezo_board(100, "EC"); //create an EC circuit object who's address is 100 and name is "EC"
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
bool reading_request_phase = true; //selects our phase
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
uint32_t next_poll_time = 0; //holds the next time we receive a response, in milliseconds
|
52
|
+
|
53
|
+
const unsigned int response_delay = 10000; //how long we wait to receive a response, in milliseconds
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
void setup() {
|
58
|
+
|
59
|
+
Wire.begin(); //start the I2C
|
60
|
+
|
61
|
+
Serial.begin(9600); //start the serial communication to the computer
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued
|
68
|
+
|
69
|
+
Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading
|
70
|
+
|
71
|
+
Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful
|
72
|
+
|
73
|
+
Serial.print(Sensor.get_reading()); //the command was successful, print the reading
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
void loop() {
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
if (reading_request_phase) { //if were in the phase where we ask for a reading
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
//send a read command. we use this command instead of PH.send_cmd("R");
|
88
|
+
|
89
|
+
//to let the library know to parse the reading
|
90
|
+
|
91
|
+
EC.send_read();
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
next_poll_time = millis() + response_delay; //set when the response will arrive
|
96
|
+
|
97
|
+
reading_request_phase = false; //switch to the receiving phase
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
else { //if were in the receiving phase
|
102
|
+
|
103
|
+
if (millis() >= next_poll_time) { //and its time to get the response
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
receive_reading(EC); //get the reading from the EC circuit
|
108
|
+
|
109
|
+
Serial.println();
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
reading_request_phase = true; //switch back to asking for readings
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
34
120
|
|
35
121
|
```
|
36
122
|
|
123
|
+
|
124
|
+
|
125
|
+
```
|
126
|
+
|
37
127
|
エラーメッセージ
|
38
128
|
|
39
129
|
```
|
1
スケッチを表示しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,6 +20,16 @@
|
|
20
20
|
|
21
21
|
シリアルポートには測定値(EC: 13.96)が正しく表示されますが、SORACOMでは3999になってしまいます。
|
22
22
|
|
23
|
+
下2つのサンプルスケッチ(ECセンサ、Sigfox)をもとに、スケッチを作製しました。
|
24
|
+
|
25
|
+
SigfoxのスケッチはUnaBiz Arduino ライブラリーをインストールして、その中のsend-temperatureのスケッチを基にした。
|
26
|
+
|
27
|
+
https://users.soracom.io/ja-jp/guides/devices/sigfox/unashield/
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
AtlasScientific社のECセンサは、
|
32
|
+
|
23
33
|
|
24
34
|
|
25
35
|
```
|
@@ -32,12 +42,240 @@
|
|
32
42
|
|
33
43
|
### 該当のソースコード
|
34
44
|
|
35
|
-
|
36
|
-
|
37
45
|
Arduino
|
38
46
|
|
39
47
|
|
40
48
|
|
49
|
+
```ここに言語を入力
|
50
|
+
|
51
|
+
// Send the sensor data from the temperature sensor to the SIGFOX cloud.
|
52
|
+
|
53
|
+
// This code assumes that you are using the Grove DHT Sensor Pro:
|
54
|
+
|
55
|
+
// http://wiki.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro
|
56
|
+
|
57
|
+
//
|
58
|
+
|
59
|
+
// You can easily adapt the code for other Grove temperature sensors:
|
60
|
+
|
61
|
+
// http://wiki.seeedstudio.com/wiki/Grove_-_Temperature_Sensor
|
62
|
+
|
63
|
+
// http://wiki.seeedstudio.com/wiki/Grove_-_Tempture&Humidity_Sensor_(High-Accuracy_&Mini)_v1.0
|
64
|
+
|
65
|
+
//
|
66
|
+
|
67
|
+
// Instructions and code based on: http://wiki.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro
|
68
|
+
|
69
|
+
// 1. Connect the Temperature and Humidity Sensor Pro to Port D2 of Grove - Base Shield
|
70
|
+
|
71
|
+
// 2. Download and install Seeed DHT Library: https://github.com/Seeed-Studio/Grove_Temperature_And_Humidity_Sensor
|
72
|
+
|
73
|
+
// 3. Make sure the voltage on the Grove Shield matches the voltage on the Arduino board.
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
////////////////////////////////////////////////////////////
|
78
|
+
|
79
|
+
// Begin Sensor Declaration
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
#include <Ezo_i2c.h> //include the EZO I2C library from https://github.com/Atlas-Scientific/Ezo_I2c_lib
|
84
|
+
|
85
|
+
#include <Wire.h> //include arduinos i2c library
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
Ezo_board EC = Ezo_board(100, "EC"); //create an EC circuit object who's address is 100 and name is "EC"
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
bool reading_request_phase = true; //selects our phase
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
uint32_t next_poll_time = 0; //holds the next time we receive a response, in milliseconds
|
100
|
+
|
101
|
+
const unsigned int response_delay = 10000; //how long we wait to receive a response, in milliseconds
|
102
|
+
|
103
|
+
// End Sensor Declaration
|
104
|
+
|
105
|
+
////////////////////////////////////////////////////////////
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
////////////////////////////////////////////////////////////
|
114
|
+
|
115
|
+
// Begin SIGFOX Module Declaration
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
#include "SIGFOX.h"
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
// IMPORTANT: Check these settings with UnaBiz to use the SIGFOX library correctly.
|
124
|
+
|
125
|
+
static const String device = "g88pi"; // Set this to your device name if you're using UnaBiz Emulator.
|
126
|
+
|
127
|
+
static const bool useEmulator = false; // Set to true if using UnaBiz Emulator.
|
128
|
+
|
129
|
+
static const bool echo = true; // Set to true if the SIGFOX library should display the executed commands.
|
130
|
+
|
131
|
+
static const Country country = COUNTRY_JP; // Set this to your country to configure the SIGFOX transmission frequencies.
|
132
|
+
|
133
|
+
static UnaShieldV2S transceiver(country, useEmulator, device, echo); // Uncomment this for UnaBiz UnaShield V2S Dev Kit
|
134
|
+
|
135
|
+
// static UnaShieldV1 transceiver(country, useEmulator, device, echo); // Uncomment this for UnaBiz UnaShield V1 Dev Kit
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
// End SIGFOX Module Declaration
|
140
|
+
|
141
|
+
////////////////////////////////////////////////////////////
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
void setup(){
|
146
|
+
|
147
|
+
{
|
148
|
+
|
149
|
+
Serial.begin(9600);
|
150
|
+
|
151
|
+
Serial.println(F("Water Monitoring"));
|
152
|
+
|
153
|
+
Wire.begin();
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
// End Sensor Setup
|
162
|
+
|
163
|
+
////////////////////////////////////////////////////////////
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
////////////////////////////////////////////////////////////
|
168
|
+
|
169
|
+
// Begin SIGFOX Module Setup
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
String result = "";
|
174
|
+
|
175
|
+
// Enter command mode.
|
176
|
+
|
177
|
+
Serial.println(F("\nEntering command mode..."));
|
178
|
+
|
179
|
+
transceiver.enterCommandMode();
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
if (useEmulator) {
|
184
|
+
|
185
|
+
// Emulation mode.
|
186
|
+
|
187
|
+
transceiver.enableEmulator(result);
|
188
|
+
|
189
|
+
} else {
|
190
|
+
|
191
|
+
// Disable emulation mode.
|
192
|
+
|
193
|
+
Serial.println(F("\nDisabling emulation mode..."));
|
194
|
+
|
195
|
+
transceiver.disableEmulator(result);
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
// Check whether emulator is used for transmission.
|
200
|
+
|
201
|
+
Serial.println(F("\nChecking emulation mode (expecting 0)...")); int emulator = 0;
|
202
|
+
|
203
|
+
transceiver.getEmulator(emulator);
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
// Set the frequency of SIGFOX module to SG/TW.
|
210
|
+
|
211
|
+
Serial.println(F("\nSetting frequency...")); result = "";
|
212
|
+
|
213
|
+
transceiver.setFrequencySG(result);
|
214
|
+
|
215
|
+
Serial.print(F("Set frequency result = ")); Serial.println(result);
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
// Get and display the frequency used by the SIGFOX module. Should return 3 for RCZ4 (SG/TW).
|
220
|
+
|
221
|
+
Serial.println(F("\nGetting frequency (expecting 3)...")); String frequency = "";
|
222
|
+
|
223
|
+
transceiver.getFrequency(frequency);
|
224
|
+
|
225
|
+
Serial.print(F("Frequency (expecting 3) = ")); Serial.println(frequency);
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
// Read SIGFOX ID and PAC from module.
|
230
|
+
|
231
|
+
Serial.println(F("\nGetting SIGFOX ID...")); String id = "", pac = "";
|
232
|
+
|
233
|
+
if (transceiver.getID(id, pac)) {
|
234
|
+
|
235
|
+
Serial.print(F("SIGFOX ID = ")); Serial.println(id);
|
236
|
+
|
237
|
+
Serial.print(F("PAC = ")); Serial.println(pac);
|
238
|
+
|
239
|
+
} else {
|
240
|
+
|
241
|
+
Serial.println(F("ID KO"));
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
// Exit command mode and prepare to send message.
|
248
|
+
|
249
|
+
transceiver.exitCommandMode();
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
// End SIGFOX Module Setup
|
254
|
+
|
255
|
+
////////////////////////////////////////////////////////////
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading
|
266
|
+
|
267
|
+
Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful
|
268
|
+
|
269
|
+
Serial.print(Sensor.get_reading()); //the command was successful, print the reading
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
41
279
|
|
42
280
|
|
43
281
|
void loop()
|
@@ -106,12 +344,62 @@
|
|
106
344
|
|
107
345
|
|
108
346
|
|
347
|
+
////////////////////////////////////////////////////////////
|
348
|
+
|
349
|
+
// Begin SIGFOX Module Loop
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
// Send the message.
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
Serial.print(F("\n>> Device sending message ")); Serial.print(msg.getEncodedMessage() + "...");
|
358
|
+
|
359
|
+
transceiver.echoOn();
|
360
|
+
|
361
|
+
if (msg.send()) {
|
362
|
+
|
363
|
+
Serial.println(F("Message sent"));
|
364
|
+
|
365
|
+
} else {
|
366
|
+
|
367
|
+
Serial.println(F("Message not sent"));
|
368
|
+
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
// End SIGFOX Module Loop
|
374
|
+
|
375
|
+
////////////////////////////////////////////////////////////
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
// Wait a while before looping. 10000 milliseconds = 10 seconds.
|
380
|
+
|
381
|
+
delay(20000);
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
```
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
//
|
392
|
+
|
109
393
|
|
110
394
|
|
111
395
|
### 試したこと
|
112
396
|
|
113
397
|
他のセンサーでは問題なかったので、何を試したらいいのかわからない。
|
114
398
|
|
399
|
+
msg.addField("ecc", receive_reading); の"receive_reading" が間違っている気がするが、他の方法が思いつかない。
|
400
|
+
|
401
|
+
|
402
|
+
|
115
403
|
|
116
404
|
|
117
405
|
### 補足情報(FW/ツールのバージョンなど)
|