質問編集履歴
3
写真追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -462,6 +462,10 @@
|
|
462
462
|
|
463
463
|
###補足情報
|
464
464
|
|
465
|
+
|
466
|
+
|
467
|
+
![イメージ説明](49ca16b29051b3843987eac293be7d1d.jpeg)
|
468
|
+
|
465
469
|
構成:
|
466
470
|
|
467
471
|
Arduino mega2560
|
2
問題の明確化
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
JPEG画像にノイズが入る原因
|
test
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
###前提・実現したいこと
|
2
2
|
|
3
|
-
Arduinoで3G回線を使いカメラで撮影した画像データ[JPG]をSDカードに保存し、
|
3
|
+
Arduinoで3G回線を使いカメラで撮影した画像データ[JPG]をSDカードに保存し、一定間隔でサーバーにアップロードする監視カメラを作っています。データをバイナリから文字変換し、サーバーにpostする時にノイズが入ってしまいます。
|
4
|
-
|
5
|
-
|
4
|
+
|
6
|
-
|
7
|
-
データをバイナリから文字変換し、サーバーにpostする時に
|
8
|
-
|
9
|
-
|
5
|
+
この状態では監視カメラとして問題があるので、ノイズ発生の原因、また解決方法などご教授頂ければと思います。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
10
12
|
|
11
13
|
|
12
14
|
|
@@ -16,333 +18,437 @@
|
|
16
18
|
|
17
19
|
|
18
20
|
|
21
|
+
|
22
|
+
|
23
|
+
![イメージ説明](101b5bdd78d02eb01439c8e29ce3c75a.jpeg)
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
###全体のソースコード
|
30
|
+
|
31
|
+
```ここに言語を入力
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
#include <Adafruit_VC0706.h>
|
36
|
+
|
37
|
+
#include <SoftwareSerial.h>
|
38
|
+
|
39
|
+
#include <SD.h>
|
40
|
+
|
41
|
+
#include <SPI.h>
|
42
|
+
|
43
|
+
#include "a3gim2.h"
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
#define chipSelect 53
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
//送信データ格納
|
52
|
+
|
53
|
+
#define BODY_BUFFER 965
|
54
|
+
|
55
|
+
char body[BODY_BUFFER]; // バッファ
|
56
|
+
|
57
|
+
#define IMGEQ "img="
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
// POST send parameter
|
62
|
+
|
63
|
+
const char *server = "******.bitter.jp"; // サーバ名
|
64
|
+
|
65
|
+
const char *path = "******.php"; // PHPファイル
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
// 送信書式
|
70
|
+
|
71
|
+
const char *header = "Content-Type: application/x-www-form-urlencoded";
|
72
|
+
|
73
|
+
const int port = 80;
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
int IS=strlen(IMGEQ);
|
78
|
+
|
79
|
+
char res[100];
|
80
|
+
|
81
|
+
const int powerPin = 0; //ここ重要 3gim power pinIf not using power control, 0 is set.
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
// CAMERA TX => 69
|
86
|
+
|
87
|
+
// CAMERA RX => 3
|
88
|
+
|
89
|
+
SoftwareSerial cameraconnection = SoftwareSerial(69,3);
|
90
|
+
|
91
|
+
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
|
92
|
+
|
93
|
+
boolean camera_found = false;
|
94
|
+
|
95
|
+
int file_count = 1;
|
96
|
+
|
97
|
+
char fname[13];
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
void setup(){
|
102
|
+
|
103
|
+
Serial.begin(9600);//シリアル通信設定
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
Serial.println("//monitoring program start//");
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
//SD初期化
|
112
|
+
|
113
|
+
pinMode(chipSelect,OUTPUT); delay(10);
|
114
|
+
|
115
|
+
//SD.begin();
|
116
|
+
|
117
|
+
if(!SD.begin(chipSelect)){
|
118
|
+
|
119
|
+
Serial.println("SD card initialization failed!");
|
120
|
+
|
121
|
+
while(1){
|
122
|
+
|
123
|
+
;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
//カメラ初期化
|
132
|
+
|
133
|
+
if( cam.begin() ){
|
134
|
+
|
135
|
+
camera_found = true;
|
136
|
+
|
137
|
+
Serial.println("Camera Found");
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
else{
|
142
|
+
|
143
|
+
Serial.println("No camera found?");
|
144
|
+
|
145
|
+
return;
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
//メイン処理
|
154
|
+
|
155
|
+
void loop() {
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
//a3gs.setLED(true);
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
//画像サイズ選択(640x480, 320x240 or 160x120)
|
164
|
+
|
165
|
+
//cam.setImageSize(VC0706_640x480); // biggest
|
166
|
+
|
167
|
+
cam.setImageSize(VC0706_320x240); // medium
|
168
|
+
|
169
|
+
//cam.setImageSize(VC0706_160x120); // small
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
uint8_t imgsize = cam.getImageSize();
|
174
|
+
|
175
|
+
Serial.print("Image size: ");
|
176
|
+
|
177
|
+
if (imgsize == VC0706_640x480) Serial.println("640x480");
|
178
|
+
|
179
|
+
if (imgsize == VC0706_320x240) Serial.println("320x240");
|
180
|
+
|
181
|
+
if (imgsize == VC0706_160x120) Serial.println("160x120");
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
Serial.println("Snap in 3 secs...");
|
186
|
+
|
187
|
+
delay(3000);
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
//撮影処理部分
|
192
|
+
|
193
|
+
if( cam.takePicture() ){
|
194
|
+
|
195
|
+
set_filename();
|
196
|
+
|
197
|
+
Serial.println("Picture taken!");
|
198
|
+
|
199
|
+
File fp = SD.open( fname, FILE_WRITE | O_TRUNC );
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
if( fp ){
|
204
|
+
|
205
|
+
uint16_t leng = cam.frameLength();
|
206
|
+
|
207
|
+
Serial.print("Storing ");
|
208
|
+
|
209
|
+
Serial.print(leng, DEC);
|
210
|
+
|
211
|
+
Serial.print(" byte image.");
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
pinMode(8, OUTPUT);
|
216
|
+
|
217
|
+
byte wCount = 0; // For counting # of writes
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
while (leng > 0) {
|
222
|
+
|
223
|
+
uint8_t *buf;
|
224
|
+
|
225
|
+
uint8_t bytesToRead = min(32, leng);
|
226
|
+
|
227
|
+
buf = cam.readPicture(bytesToRead);
|
228
|
+
|
229
|
+
fp.write( buf, bytesToRead );
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
|
234
|
+
|
235
|
+
Serial.print('.');
|
236
|
+
|
237
|
+
wCount = 0;
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
leng -= bytesToRead;
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
fp.close();
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
int32_t time = millis();
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
//-------------- 3G接続 ------------
|
256
|
+
|
257
|
+
Serial.println("\n----------------------------------");
|
258
|
+
|
259
|
+
Serial.println("3G connect ready : Wait about 40 sec...");
|
260
|
+
|
261
|
+
while( !(a3gs.start() == 0 && a3gs.begin()==0))
|
262
|
+
|
263
|
+
{
|
264
|
+
|
265
|
+
Serial.print(".");
|
266
|
+
|
267
|
+
delay(1000);
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
Serial.println("connected!");
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
//------------ SDメモリー読込み3GSA書出し --------------
|
276
|
+
|
277
|
+
File fp = SD.open( fname ,FILE_READ );
|
278
|
+
|
279
|
+
int len = sizeof(res);
|
280
|
+
|
281
|
+
int i=strlen(IMGEQ);
|
282
|
+
|
283
|
+
sprintf(body,"%s",IMGEQ);//POST引き渡し変数名設定
|
284
|
+
|
285
|
+
uint8_t b;
|
286
|
+
|
287
|
+
//delay(3000);
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
Serial.print("\nhttpPOST..");
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
delay(50);
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
while(fp.available()) {//------------読み取り可能なbyteがある場合入る --------------
|
300
|
+
|
301
|
+
b = fp.read();
|
302
|
+
|
303
|
+
body[i++] = b/16 + (b/16>9?'A'-10:'0'); // バイナリ―から文字変換(上位)
|
304
|
+
|
305
|
+
body[i++] = b%16 + (b%16>9?'A'-10:'0'); // バイナリ―から文字変換(下位)
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
delay(50);
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
if( i>=BODY_BUFFER ) {
|
314
|
+
|
315
|
+
if(a3gs.httpPOST(server,port,path,header,body,res,&len,false)!=0){
|
316
|
+
|
317
|
+
//Serial.println("httpPOST error1...");
|
318
|
+
|
319
|
+
delay(200);
|
320
|
+
|
321
|
+
}else{
|
322
|
+
|
323
|
+
Serial.print(".");
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
i=strlen(IMGEQ);
|
328
|
+
|
329
|
+
sprintf(body,"%s",IMGEQ); //POST引き渡し変数名設定
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
//delay(50);
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
fp.close();
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
if(i>strlen(IMGEQ)) {
|
342
|
+
|
343
|
+
body[IS +i] = 0x00 ; // 残りバッファの3GSA書出し
|
344
|
+
|
345
|
+
if(a3gs.httpPOST(server,port,path,header,body,res,&len,false)!=0){
|
346
|
+
|
347
|
+
//Serial.println("httpPOST error2...");
|
348
|
+
|
349
|
+
delay(200);
|
350
|
+
|
351
|
+
}else{
|
352
|
+
|
353
|
+
Serial.print("!");
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
sprintf(body,"img=%s",fname); // ファイル名の書出し(php側でファイル名変更)
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
if(a3gs.httpPOST(server,port,path,header,body,res,&len,false)!=0){
|
366
|
+
|
367
|
+
Serial.println(" file name send error");
|
368
|
+
|
369
|
+
}else {
|
370
|
+
|
371
|
+
Serial.print(" Completed send '"); Serial.println(fname);
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
cam.reset();
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
time = millis() - time;
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
Serial.print(time); Serial.println(" ms elapsed");
|
384
|
+
|
385
|
+
Serial.println("done!");
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
Serial.println("3G Shutdown..");
|
390
|
+
|
391
|
+
a3gs.end();
|
392
|
+
|
393
|
+
a3gs.shutdown();
|
394
|
+
|
395
|
+
//a3gs.setLED(false);
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
Serial.println("----------------------------------");
|
400
|
+
|
401
|
+
delay(25000);
|
402
|
+
|
403
|
+
}
|
404
|
+
|
405
|
+
void set_filename(){
|
406
|
+
|
407
|
+
sprintf(fname, "IMG%02d.JPG", file_count++);
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
if( file_count > 10){
|
412
|
+
|
413
|
+
file_count = 1; // Overwrite
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
}
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
19
427
|
```
|
20
428
|
|
21
|
-
|
429
|
+
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
430
|
+
|
26
|
-
|
27
|
-
データが壊れてしまう
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
・1ループ目で以下のSerial.printlnが表示されない
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
//画像サイズ選択(640x480, 320x240 or 160x120)
|
36
|
-
|
37
|
-
//cam.setImageSize(VC0706_640x480); // biggest
|
38
|
-
|
39
|
-
//cam.setImageSize(VC0706_320x240); // medium
|
40
|
-
|
41
|
-
cam.setImageSize(VC0706_160x120); // small
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
431
|
+
###原因と思われる部分
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
uint8_t imgsize = cam.getImageSize();
|
50
|
-
|
51
|
-
Serial.print("Image size: ");
|
52
|
-
|
53
|
-
///////////この部分/////////////
|
54
|
-
|
55
|
-
if (imgsize == VC0706_640x480) Serial.println("640x480");
|
56
|
-
|
57
|
-
if (imgsize == VC0706_320x240) Serial.println("320x240");
|
58
|
-
|
59
|
-
if (imgsize == VC0706_160x120) Serial.println("160x120");
|
60
432
|
|
61
433
|
```
|
62
434
|
|
63
|
-
|
64
|
-
|
65
|
-
###全体のソースコード
|
66
|
-
|
67
|
-
```ここに言語を入力
|
68
|
-
|
69
|
-
/*
|
70
|
-
|
71
|
-
* Arduino UNO + TTL Camera + SD Storage w/SPI Interface
|
72
|
-
|
73
|
-
*/
|
74
|
-
|
75
|
-
#include <Adafruit_VC0706.h>
|
76
|
-
|
77
|
-
#include <SoftwareSerial.h>
|
78
|
-
|
79
|
-
#include <SD.h>
|
80
|
-
|
81
|
-
#include <SPI.h>
|
82
|
-
|
83
|
-
#include "a3gim2.h"
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
#define chipSelect 53
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
//送信データ格納
|
92
|
-
|
93
|
-
#define BODY_BUFFER 550
|
94
|
-
|
95
|
-
char body[BODY_BUFFER];
|
96
|
-
|
97
|
-
#define IMGEQ "img="
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
// POST send parameter
|
102
|
-
|
103
|
-
const char *server = "*******.bitter.jp"; // サーバ名
|
104
|
-
|
105
|
-
const char *path = "*******.php"; // PHPファイル
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
// 送信書式
|
110
|
-
|
111
|
-
const char *header = "Content-Type: application/x-www-form-urlencoded";
|
112
|
-
|
113
|
-
const int port = 80;
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
int IS=strlen(IMGEQ);
|
118
|
-
|
119
|
-
char res[100];
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
// CAMERA TX => 69
|
124
|
-
|
125
|
-
// CAMERA RX => 3
|
126
|
-
|
127
|
-
SoftwareSerial cameraconnection = SoftwareSerial(69,3);
|
128
|
-
|
129
|
-
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
|
130
|
-
|
131
|
-
boolean camera_found = false;
|
132
|
-
|
133
|
-
int file_count = 1;
|
134
|
-
|
135
|
-
char fname[13];
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
void setup(){
|
140
|
-
|
141
|
-
Serial.begin(9600);
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
Serial.println("//monitoring program start//");
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
pinMode(SS,OUTPUT); delay(10);
|
150
|
-
|
151
|
-
//SD.begin();
|
152
|
-
|
153
|
-
if(!SD.begin()){
|
154
|
-
|
155
|
-
Serial.println("SD card initialization failed!");
|
156
|
-
|
157
|
-
while(1){
|
158
|
-
|
159
|
-
;
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
if( cam.begin() ){
|
168
|
-
|
169
|
-
camera_found = true;
|
170
|
-
|
171
|
-
Serial.println("Camera Found");
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
else{
|
176
|
-
|
177
|
-
Serial.println("No camera found?");
|
178
|
-
|
179
|
-
return;
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
void loop() {
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
//画像サイズ選択(640x480, 320x240 or 160x120)
|
192
|
-
|
193
|
-
//cam.setImageSize(VC0706_640x480); // biggest
|
194
|
-
|
195
|
-
//cam.setImageSize(VC0706_320x240); // medium
|
196
|
-
|
197
|
-
cam.setImageSize(VC0706_160x120); // small
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
delay(100);
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
uint8_t imgsize = cam.getImageSize();
|
206
|
-
|
207
|
-
Serial.print("Image size: ");
|
208
|
-
|
209
|
-
if (imgsize == VC0706_640x480) Serial.println("640x480");
|
210
|
-
|
211
|
-
if (imgsize == VC0706_320x240) Serial.println("320x240");
|
212
|
-
|
213
|
-
if (imgsize == VC0706_160x120) Serial.println("160x120");
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
Serial.println("Snap in 3 secs...");
|
218
|
-
|
219
|
-
delay(3000);
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
//撮影
|
224
|
-
|
225
|
-
if( cam.takePicture() ){
|
226
|
-
|
227
|
-
set_filename();
|
228
|
-
|
229
|
-
Serial.println("Picture taken!");
|
230
|
-
|
231
|
-
File fp = SD.open( fname, FILE_WRITE | O_TRUNC );
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
//データ容量
|
236
|
-
|
237
|
-
if( fp ){
|
238
|
-
|
239
|
-
uint16_t leng = cam.frameLength();
|
240
|
-
|
241
|
-
Serial.print("Storing ");
|
242
|
-
|
243
|
-
Serial.print(leng, DEC);
|
244
|
-
|
245
|
-
Serial.print(" byte image.");
|
246
|
-
|
247
|
-
pinMode(8, OUTPUT);
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
byte wCount = 0; // For counting # of writes
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
while (leng > 0) {
|
256
|
-
|
257
|
-
uint8_t *buf;
|
258
|
-
|
259
|
-
uint8_t bytesToRead = min(32, leng);
|
260
|
-
|
261
|
-
buf = cam.readPicture(bytesToRead);
|
262
|
-
|
263
|
-
fp.write( buf, bytesToRead );
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
|
268
|
-
|
269
|
-
Serial.print('.');
|
270
|
-
|
271
|
-
wCount = 0;
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
leng -= bytesToRead;
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
fp.close();
|
280
|
-
|
281
|
-
}
|
282
|
-
|
283
|
-
}
|
284
|
-
|
285
|
-
int32_t time = millis();
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
//-------------- 3G接続 ------------
|
290
|
-
|
291
|
-
Serial.println("\n----------------------------------");
|
292
|
-
|
293
|
-
Serial.println("3G connect ready : Wait about 40 sec...");
|
294
|
-
|
295
|
-
while( !(a3gs.start() == 0 && a3gs.begin()==0))
|
296
|
-
|
297
|
-
{
|
298
|
-
|
299
|
-
Serial.print(".");
|
300
|
-
|
301
|
-
delay(1000);
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
Serial.println("connected!");
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
//------------ SDメモリー読込み3GS書出し --------------
|
310
|
-
|
311
|
-
File fp = SD.open( fname ,FILE_READ );
|
312
|
-
|
313
|
-
int len = sizeof(res);
|
314
|
-
|
315
|
-
int i=strlen(IMGEQ);
|
316
|
-
|
317
|
-
sprintf(body,"%s",IMGEQ);//POST引き渡し変数名設定
|
318
|
-
|
319
|
-
uint8_t b;
|
320
|
-
|
321
|
-
delay(3000);
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
Serial.print("\nhttpPOST..");
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
while(fp.available()) {//------------読み取り可能なbyteがある場合入る --------------
|
330
|
-
|
331
|
-
b = fp.read();
|
332
|
-
|
333
|
-
|
435
|
+
body[i++] = b/16 + (b/16>9?'A'-10:'0'); // バイナリ―から文字変換(上位)
|
334
436
|
|
335
437
|
body[i++] = b%16 + (b%16>9?'A'-10:'0'); // バイナリ―から文字変換(下位)
|
336
438
|
|
337
439
|
|
338
440
|
|
441
|
+
delay(50);
|
442
|
+
|
443
|
+
|
444
|
+
|
339
445
|
if( i>=BODY_BUFFER ) {
|
340
446
|
|
341
447
|
if(a3gs.httpPOST(server,port,path,header,body,res,&len,false)!=0){
|
342
448
|
|
343
|
-
//
|
449
|
+
//Serial.println("httpPOST error1...");SDとの通信が上手くできていない?
|
344
|
-
|
450
|
+
|
345
|
-
delay(
|
451
|
+
delay(200);
|
346
452
|
|
347
453
|
}else{
|
348
454
|
|
@@ -350,134 +456,10 @@
|
|
350
456
|
|
351
457
|
}
|
352
458
|
|
353
|
-
i=strlen(IMGEQ);
|
354
|
-
|
355
|
-
sprintf(body,"%s",IMGEQ); //POST引き渡し変数名設定
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
delay(50);
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
fp.close();
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
if(i>strlen(IMGEQ)) {
|
368
|
-
|
369
|
-
body[IS +i] = 0x00 ; // 残りバッファの3GSA書出し
|
370
|
-
|
371
|
-
if(a3gs.httpPOST(server,port,path,header,body,res,&len,false)!=0){
|
372
|
-
|
373
|
-
//Serial.println("httpPOST error2...");
|
374
|
-
|
375
|
-
delay(100);
|
376
|
-
|
377
|
-
}else{
|
378
|
-
|
379
|
-
Serial.print(".");
|
380
|
-
|
381
|
-
}
|
382
|
-
|
383
|
-
}
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
sprintf(body,"img=%s",fname); // ファイル名の書出し(php側でファイル名変更)
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
if(a3gs.httpPOST(server,port,path,header,body,res,&len,false)!=0){
|
392
|
-
|
393
|
-
Serial.println(" file name send error");
|
394
|
-
|
395
|
-
}else {
|
396
|
-
|
397
|
-
Serial.print(" Completed send '"); Serial.println(fname);
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
cam.reset();
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
if (SD.exists(fname)) SD.remove(fname);//SDクリア
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
time = millis() - time;
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
Serial.print(time); Serial.println(" ms elapsed");
|
416
|
-
|
417
|
-
Serial.println("done!");
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
Serial.println("3G Shutdown..");
|
422
|
-
|
423
|
-
a3gs.end();
|
424
|
-
|
425
|
-
a3gs.shutdown();
|
426
|
-
|
427
|
-
Serial.println("----------------------------------");
|
428
|
-
|
429
|
-
delay(20000);
|
430
|
-
|
431
|
-
}
|
432
|
-
|
433
|
-
void set_filename(){
|
434
|
-
|
435
|
-
sprintf(fname, "IMG%02d.JPG", file_count++);
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
if( file_count > 10){
|
440
|
-
|
441
|
-
file_count = 1; // ファイルネーム上書き
|
442
|
-
|
443
|
-
}
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
459
|
|
450
460
|
|
451
461
|
```
|
452
462
|
|
453
|
-
|
454
|
-
|
455
|
-
###試したこと
|
456
|
-
|
457
|
-
・BODY_BUFFER の値を100~1000の間で変更しpostました。
|
458
|
-
|
459
|
-
結果はあまり値が小さすぎると1ループ目からファイルが壊れてしまい、500~850の間に設定しpostすると壊れたり壊れなかったりと安定しませんでした。
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
・resの値を変更してみました。こちらもpostすると壊れたり壊れなかったりで安定しませんでした。
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
・3Gに接続するタイミングをsetup内からloop内、SDメモリー読込み3GS書出しの直前に変更しました。
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
・while(fp.available())内のiの値が加算され続けているのかと思い、デバッグプリントで確認しましたが、問題ありませんでした。
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
・SD内に複数のデータがあると、postする時に目的のファイルを検知できないのかと思い、1ループ目で写真撮影→SD保存→撮影した写真を消去→2ループ目という流れにしました。
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
463
|
###補足情報
|
482
464
|
|
483
465
|
構成:
|
1
機器構成部TTLシリアルカメラ追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
-
![・画像にノイズが入ったり欠落を起こす](
|
21
|
+
![・画像にノイズが入ったり欠落を起こす](6ed9ea76ad6ca58e1f78dfb089bb5e9d.jpeg)
|
22
22
|
|
23
23
|
|
24
24
|
|
@@ -491,3 +491,5 @@
|
|
491
491
|
simカード soracom air
|
492
492
|
|
493
493
|
SDカード
|
494
|
+
|
495
|
+
TTLシリアルカメラ
|