teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

タブを一つ削除した

2021/11/22 03:55

投稿

ToshiakiHIRAI
ToshiakiHIRAI

スコア0

title CHANGED
File without changes
body CHANGED
File without changes

3

スケッチを表示しました。

2021/11/22 03:55

投稿

ToshiakiHIRAI
ToshiakiHIRAI

スコア0

title CHANGED
File without changes
body CHANGED
@@ -13,6 +13,7 @@
13
13
  SigfoxのスケッチはUnaBiz Arduino ライブラリーをインストールして、その中のsend-temperatureのスケッチを基にした。
14
14
  https://users.soracom.io/ja-jp/guides/devices/sigfox/unashield/
15
15
 
16
+
16
17
  AtlasScientific社のECセンサは、下記の通りです。
17
18
  ```ここに言語を入力
18
19
  #include <Ezo_i2c.h> //include the EZO I2C library from https://github.com/Atlas-Scientific/Ezo_I2c_lib

2

スケッチを表示しました。

2021/11/22 03:00

投稿

ToshiakiHIRAI
ToshiakiHIRAI

スコア0

title CHANGED
File without changes
body CHANGED
@@ -13,9 +13,54 @@
13
13
  SigfoxのスケッチはUnaBiz Arduino ライブラリーをインストールして、その中のsend-temperatureのスケッチを基にした。
14
14
  https://users.soracom.io/ja-jp/guides/devices/sigfox/unashield/
15
15
 
16
- AtlasScientific社のECセンサは、
16
+ AtlasScientific社のECセンサは、下記の通りです。
17
+ ```ここに言語を入力
18
+ #include <Ezo_i2c.h> //include the EZO I2C library from https://github.com/Atlas-Scientific/Ezo_I2c_lib
19
+ #include <Wire.h> //include arduinos i2c library
17
20
 
21
+
22
+ Ezo_board EC = Ezo_board(100, "EC"); //create an EC circuit object who's address is 100 and name is "EC"
23
+
24
+ bool reading_request_phase = true; //selects our phase
25
+
26
+ uint32_t next_poll_time = 0; //holds the next time we receive a response, in milliseconds
27
+ const unsigned int response_delay = 10000; //how long we wait to receive a response, in milliseconds
28
+
29
+ void setup() {
30
+ Wire.begin(); //start the I2C
31
+ Serial.begin(9600); //start the serial communication to the computer
32
+ }
33
+
34
+ void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued
35
+ Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading
36
+ Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful
37
+ Serial.print(Sensor.get_reading()); //the command was successful, print the reading
38
+ }
39
+
40
+ void loop() {
41
+
42
+ if (reading_request_phase) { //if were in the phase where we ask for a reading
43
+
44
+ //send a read command. we use this command instead of PH.send_cmd("R");
45
+ //to let the library know to parse the reading
46
+ EC.send_read();
47
+
48
+ next_poll_time = millis() + response_delay; //set when the response will arrive
49
+ reading_request_phase = false; //switch to the receiving phase
50
+ }
51
+ else { //if were in the receiving phase
52
+ if (millis() >= next_poll_time) { //and its time to get the response
53
+
54
+ receive_reading(EC); //get the reading from the EC circuit
55
+ Serial.println();
56
+
57
+ reading_request_phase = true; //switch back to asking for readings
58
+ }
59
+ }
60
+ }
18
61
  ```
62
+
63
+ ```
19
64
  エラーメッセージ
20
65
  ```
21
66
  ![イメージ説明](dca39205bdbda78a31859b0b084e2b1b.png)

1

スケッチを表示しました。

2021/11/22 02:55

投稿

ToshiakiHIRAI
ToshiakiHIRAI

スコア0

title CHANGED
File without changes
body CHANGED
@@ -9,16 +9,135 @@
9
9
  ### 発生している問題・エラーメッセージ
10
10
 
11
11
  シリアルポートには測定値(EC: 13.96)が正しく表示されますが、SORACOMでは3999になってしまいます。
12
+ 下2つのサンプルスケッチ(ECセンサ、Sigfox)をもとに、スケッチを作製しました。
13
+ SigfoxのスケッチはUnaBiz Arduino ライブラリーをインストールして、その中のsend-temperatureのスケッチを基にした。
14
+ https://users.soracom.io/ja-jp/guides/devices/sigfox/unashield/
12
15
 
16
+ AtlasScientific社のECセンサは、
17
+
13
18
  ```
14
19
  エラーメッセージ
15
20
  ```
16
21
  ![イメージ説明](dca39205bdbda78a31859b0b084e2b1b.png)
17
22
  ### 該当のソースコード
18
-
19
23
  Arduino
20
24
 
25
+ ```ここに言語を入力
26
+ // Send the sensor data from the temperature sensor to the SIGFOX cloud.
27
+ // This code assumes that you are using the Grove DHT Sensor Pro:
28
+ // http://wiki.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro
29
+ //
30
+ // You can easily adapt the code for other Grove temperature sensors:
31
+ // http://wiki.seeedstudio.com/wiki/Grove_-_Temperature_Sensor
32
+ // http://wiki.seeedstudio.com/wiki/Grove_-_Tempture&Humidity_Sensor_(High-Accuracy_&Mini)_v1.0
33
+ //
34
+ // Instructions and code based on: http://wiki.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro
35
+ // 1. Connect the Temperature and Humidity Sensor Pro to Port D2 of Grove - Base Shield
36
+ // 2. Download and install Seeed DHT Library: https://github.com/Seeed-Studio/Grove_Temperature_And_Humidity_Sensor
37
+ // 3. Make sure the voltage on the Grove Shield matches the voltage on the Arduino board.
21
38
 
39
+ ////////////////////////////////////////////////////////////
40
+ // Begin Sensor Declaration
41
+
42
+ #include <Ezo_i2c.h> //include the EZO I2C library from https://github.com/Atlas-Scientific/Ezo_I2c_lib
43
+ #include <Wire.h> //include arduinos i2c library
44
+
45
+
46
+ Ezo_board EC = Ezo_board(100, "EC"); //create an EC circuit object who's address is 100 and name is "EC"
47
+
48
+ bool reading_request_phase = true; //selects our phase
49
+
50
+ uint32_t next_poll_time = 0; //holds the next time we receive a response, in milliseconds
51
+ const unsigned int response_delay = 10000; //how long we wait to receive a response, in milliseconds
52
+ // End Sensor Declaration
53
+ ////////////////////////////////////////////////////////////
54
+
55
+
56
+
57
+ ////////////////////////////////////////////////////////////
58
+ // Begin SIGFOX Module Declaration
59
+
60
+ #include "SIGFOX.h"
61
+
62
+ // IMPORTANT: Check these settings with UnaBiz to use the SIGFOX library correctly.
63
+ static const String device = "g88pi"; // Set this to your device name if you're using UnaBiz Emulator.
64
+ static const bool useEmulator = false; // Set to true if using UnaBiz Emulator.
65
+ static const bool echo = true; // Set to true if the SIGFOX library should display the executed commands.
66
+ static const Country country = COUNTRY_JP; // Set this to your country to configure the SIGFOX transmission frequencies.
67
+ static UnaShieldV2S transceiver(country, useEmulator, device, echo); // Uncomment this for UnaBiz UnaShield V2S Dev Kit
68
+ // static UnaShieldV1 transceiver(country, useEmulator, device, echo); // Uncomment this for UnaBiz UnaShield V1 Dev Kit
69
+
70
+ // End SIGFOX Module Declaration
71
+ ////////////////////////////////////////////////////////////
72
+
73
+ void setup(){
74
+ {
75
+ Serial.begin(9600);
76
+ Serial.println(F("Water Monitoring"));
77
+ Wire.begin();
78
+ }
79
+
80
+
81
+ // End Sensor Setup
82
+ ////////////////////////////////////////////////////////////
83
+
84
+ ////////////////////////////////////////////////////////////
85
+ // Begin SIGFOX Module Setup
86
+
87
+ String result = "";
88
+ // Enter command mode.
89
+ Serial.println(F("\nEntering command mode..."));
90
+ transceiver.enterCommandMode();
91
+
92
+ if (useEmulator) {
93
+ // Emulation mode.
94
+ transceiver.enableEmulator(result);
95
+ } else {
96
+ // Disable emulation mode.
97
+ Serial.println(F("\nDisabling emulation mode..."));
98
+ transceiver.disableEmulator(result);
99
+
100
+ // Check whether emulator is used for transmission.
101
+ Serial.println(F("\nChecking emulation mode (expecting 0)...")); int emulator = 0;
102
+ transceiver.getEmulator(emulator);
103
+ }
104
+
105
+ // Set the frequency of SIGFOX module to SG/TW.
106
+ Serial.println(F("\nSetting frequency...")); result = "";
107
+ transceiver.setFrequencySG(result);
108
+ Serial.print(F("Set frequency result = ")); Serial.println(result);
109
+
110
+ // Get and display the frequency used by the SIGFOX module. Should return 3 for RCZ4 (SG/TW).
111
+ Serial.println(F("\nGetting frequency (expecting 3)...")); String frequency = "";
112
+ transceiver.getFrequency(frequency);
113
+ Serial.print(F("Frequency (expecting 3) = ")); Serial.println(frequency);
114
+
115
+ // Read SIGFOX ID and PAC from module.
116
+ Serial.println(F("\nGetting SIGFOX ID...")); String id = "", pac = "";
117
+ if (transceiver.getID(id, pac)) {
118
+ Serial.print(F("SIGFOX ID = ")); Serial.println(id);
119
+ Serial.print(F("PAC = ")); Serial.println(pac);
120
+ } else {
121
+ Serial.println(F("ID KO"));
122
+ }
123
+
124
+ // Exit command mode and prepare to send message.
125
+ transceiver.exitCommandMode();
126
+
127
+ // End SIGFOX Module Setup
128
+ ////////////////////////////////////////////////////////////
129
+ }
130
+
131
+ void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued
132
+
133
+ Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading
134
+ Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful
135
+ Serial.print(Sensor.get_reading()); //the command was successful, print the reading
136
+
137
+ }
138
+
139
+
140
+
22
141
  void loop()
23
142
  {
24
143
  ////////////////////////////////////////////////////////////
@@ -52,9 +171,34 @@
52
171
  // End Sensor Loop
53
172
  ////////////////////////////////////////////////////////////
54
173
 
174
+ ////////////////////////////////////////////////////////////
175
+ // Begin SIGFOX Module Loop
55
176
 
177
+ // Send the message.
178
+
179
+ Serial.print(F("\n>> Device sending message ")); Serial.print(msg.getEncodedMessage() + "...");
180
+ transceiver.echoOn();
181
+ if (msg.send()) {
182
+ Serial.println(F("Message sent"));
183
+ } else {
184
+ Serial.println(F("Message not sent"));
185
+ }
186
+
187
+ // End SIGFOX Module Loop
188
+ ////////////////////////////////////////////////////////////
189
+
190
+ // Wait a while before looping. 10000 milliseconds = 10 seconds.
191
+ delay(20000);
192
+ }
193
+ ```
194
+
195
+
196
+ //
197
+
56
198
  ### 試したこと
57
199
  他のセンサーでは問題なかったので、何を試したらいいのかわからない。
200
+ msg.addField("ecc", receive_reading);  の"receive_reading" が間違っている気がするが、他の方法が思いつかない。
58
201
 
202
+
59
203
  ### 補足情報(FW/ツールのバージョンなど)
60
204
  Arduino