전체상품목록 바로가기

본문 바로가기


현재 위치
  1. home
  2. community
  3. 기술문의 :)

기술문의 :)

기술문의 게시판 입니다.

상품 게시판 상세
subject cc3000 wifi + arduino uno + jpeg ttl serial camera질문드립니다.
writer 김창용 (ip:)
  • date 2015-09-22 11:32:57
  • like 추천하기
  • view 757
rating 0점

 

안녕하세요 다름이 아니라

오토홈 오토메이션이라는 곳에서 와이파이 아두이노 카메라 연동하는 오픈소소를 한번 해봤는데 질문드립니다.


8
 
9 // Include camera  
10 #include <Adafruit_VC0706.h>
11 #include <SoftwareSerial.h>
12 #include <Adafruit_CC3000.h>
13 #include <ccspi.h>
14 #include <SPI.h>
15 #include < string.h>
16 #include "utility/debug.h"
17 #include<stdlib.h>
18
 
19 // Software serial
20 SoftwareSerial cameraconnection = SoftwareSerial(A0, A1);
21 Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
22
 
23 // Define CC3000 chip pins
24 #define ADAFRUIT_CC3000_IRQ   3
25 #define ADAFRUIT_CC3000_VBAT  5
26 #define ADAFRUIT_CC3000_CS    10
27
 
28 // WiFi network (change with your settings !)
29 #define WLAN_SSID       "yourNetwork"        // cannot be longer than 32 characters!
30 #define WLAN_PASS       "yourPassword"

31 #define WLAN_SECURITY   WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
32
 
33 // Create CC3000 instances
34 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
35                                          SPI_CLOCK_DIV2);
36                                          
37 // Local server IP, port, and repository (change with your settings !)
38 uint32_t ip = cc3000.IP2U32(192,168,0,1);
39 int port = 80;
40 String repository = "/arduino-camera-wifi/";                                         
41                                       
42 void setup() {
43  
44   Serial.begin(115200);
45   Serial.println("Camera test");
46   
47   // Try to locate the camera
48   if (cam.begin()) {
49     Serial.println("Camera found:");
50   } else {
51     Serial.println("Camera not found !");
52     return;
53   }
54   
55   // Set picture size
56   cam.setImageSize(VC0706_640x480);
57   
58   // Initialise the module
59   Serial.println(F("\nInitializing..."));
60   if (!cc3000.begin())
61   {
62     Serial.println(F("Couldn't begin()! Check your wiring?"));
63     while(1);
64   }
65
 
66   // Connect to  WiFi network
67   cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
68   Serial.println(F("Connected!"));
69     
70   // Display connection details
71   Serial.println(F("Request DHCP"));
72   while (!cc3000.checkDHCP())
73   {
74     delay(100); // ToDo: Insert a DHCP timeout!
75   }
76   
77   cc3000.printIPdotsRev(ip);
78
 
79   if (! cam.takePicture()) 
80     Serial.println("Failed to snap!");
81   else 
82     Serial.println("Picture taken!");
83   
84   // Get the size of the image (frame) taken  
85   uint16_t jpglen = cam.frameLength();
86   Serial.print("Storing ");
87   Serial.print(jpglen, DEC);
88   Serial.print(" byte image.");
89   
90   // Prepare request
91   String start_request = "";
92   String end_request = "";
93   start_request = start_request + "\n" + "--AaB03x" + "\n" + "Content-Disposition: form-data; name=\"picture\"; filename=\"CAM.JPG\"" + "\n" + "Content-Type: image/jpeg" + "\n" + "Content-Transfer-Encoding: binary" + "\n" + "\n";  
94   end_request = end_request + "\n" + "--AaB03x--" + "\n";
95   
96   uint16_t extra_length;
97   extra_length = start_request.length() + end_request.length();
98   Serial.println("Extra length:");
99   Serial.println(extra_length);
100   
101   uint16_t len = jpglen + extra_length;
102   
103    Serial.println("Full request:");
104    Serial.println(F("POST /arduino-camera-wifi/camera.php HTTP/1.1"));
105    Serial.println(F("Host: 192.168.0.1:80"));
106    Serial.println(F("Content-Type: multipart/form-data; boundary=AaB03x"));
107    Serial.print(F("Content-Length: "));
108    Serial.println(len);
109    Serial.print(start_request);
110    Serial.print("binary data");
111    Serial.print(end_request);
112  
113   Serial.println("Starting connection to server...");
114   Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);
115   
116   // Connect to the server, please change your IP address !
117   if (client.connected()) {
118       Serial.println(F("Connected !"));
119       client.println(F("POST /arduino-camera-wifi/camera.php HTTP/1.1"));
120       client.println(F("Host: 192.168.0.1:80"));
121       client.println(F("Content-Type: multipart/form-data; boundary=AaB03x"));
122       client.print(F("Content-Length: "));
123       client.println(len);
124       client.print(start_request);
125             
126       // Read all the data up to # bytes!
127       byte wCount = 0; // For counting # of writes
128       while (jpglen > 0) {
129         
130         uint8_t *buffer;
131         uint8_t bytesToRead = min(64, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
132         
133         buffer = cam.readPicture(bytesToRead);
134         client.write(buffer, bytesToRead);
135     
136         if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
137           Serial.print('.');
138           wCount = 0;
139         }
140         jpglen -= bytesToRead; 
141       }
142       
143       client.print(end_request);
144       client.println();
145       
146   Serial.println("Transmission over");
147   } 
148   
149   else {
150       Serial.println(F("Connection failed"));    
151     }
152     
153      while (client.connected()) {
154
 
155       while (client.available()) {
156
 
157     // Read answer
158         char c = client.read();
159         Serial.print(c);
160         //result = result + c;
161       }
162     }
163     client.close();
164   
165 }
166
 
167 void loop() {
168 }
169

이게 소스코드입니다.

위 코드와 동일하게 코드를 짜고 실행을 해보았습니다.

연결이 다 되고 확인하기 위해


http://192.168.0.1:80/arduino-camra-wifi/ 로 출력값이 나오는걸로 알고있습니다.

확인하기 위해 들어갔는데 페이지를 찾을 수 없다고 뜹니다.


제가 본 자료는 https://www.openhomeautomation.net/wireless-camera/ 이 홈페이지 입니다.

첨부자료는 홈페이지의 결과값입니다.

첨부자료와 동일하게 시리얼 모니터에서 결과값은 다 읽었습니다.

다른게 있다면 맨 아랫줄에 sever ip와 연결됬다는 문구만 없습니다.


ssid와 password도 다 설정을 해 주었습니다 답변 부탁드립니다




file
password 삭제하려면 비밀번호를 입력하세요.
댓글 수정

password :

/ byte

비밀번호 : 확인 취소

댓글 입력

commentsname : password : 관리자 답변 보기

/ byte

왼쪽의 문자를 공백없이 입력하세요.(대소문자구분)

회원에게만 댓글 작성 권한이 있습니다.

관련 글 보기

관련글 모음
번호 상품명 제목 작성자 작성일 조회
16922 [배송안내] 설연휴 배송 아트로봇CT 2019-02-01 220
16646 usb2serial보드 문의 (주)프라임소프트 2018-03-14 234
16654 usb2serial보드 문의 아트로봇CT 2018-03-18 216
16638 [ 설연휴 및 배송 ] 휴무 및 택배배송 일정 안내 아트로봇CT 2018-02-13 230
16624 구매 관련 문의드립니다. 강민구 2018-01-25 3