정보나눔

오픈소스하드웨어 프로젝트에 대한 다양한 정보를 나누는 공간입니다.

아두이노 ->php 전송문제
서명식 | 2016-09-06
/***************************************************
  This is an example for the Adafruit CC3000 Wifi Breakout & Shield
 
  Designed specifically to work with the Adafruit WiFi products:
  ----> https://www.adafruit.com/products/1469
 
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!
 
  Written by Limor Fried & Kevin Townsend for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/
 
 /*
This example does a test of the TCP client capability:
  * Initialization
  * Optional: SSID scan
  * AP connection
  * DHCP printout
  * DNS lookup
  * Optional: Ping
  * Connect to website and print out webpage contents
  * Disconnect
SmartConfig is still beta and kind of works but is not fully vetted!
It might not work on all networks!
*/
#include
#include
#include
#include
#include "utility/debug.h"
 
// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed
 
#define WLAN_SSID       "와이파이이름"           // cannot be longer than 32 characters!
#define WLAN_PASS       "비밀번호"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
 
#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data
                                   // received before closing the connection.  If you know the server
                                   // you're accessing is quick to respond, you can reduce this value.
 
 
 
// 아래의  PhpServerIP는 전송하고자하는 우분투 서버IP의 주소입니다.
IPAddress PhpServerIP = cc3000.IP2U32((uint8_t)xx ,(uint8_t)xx ,(uint8_t)xxx , (uint8_t)xx);
//uint32_t PhpServerIP = cc3000.IP2U32(xx,xx,xxx,xx); 
 
 

int state1=12343;  //전송하고자하는 값 state1
 

void setup()
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n"));
  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
  /* Initialise the module */
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
 
  // Optional SSID scan
  // listSSIDResults();
 
  Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  
  Serial.println(F("Connected!"));
 
  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  } 
}
 
 
 
//전송부분입니다. 에러없구 연결에 성공했다고나옵니다. 다만 전송이되질않습니다 ㅠㅠ
void loop()
{
 Adafruit_CC3000_Client client = cc3000.connectTCP(PhpServerIP, 22);
 if(client.connected()){
     Serial.println("sucess") ;
     client.print("GET /two.php?");
     client.print("state1=");
     client.println(state1);
     client.print("HTTP/1.1");
    
     delay(10000) ;
     client.close() ;
     Serial.println("close");
  } 
   else
   {
    Serial.println("false");
    delay(5000) ;
  }
}
 
 
아두이노코드로 작성하였는데 와이파이쉴드 연결되고 아이피와 연결까지되는데 state1 값이 전송이되질않습니다.
무슨문제있나요 코드에 ㅠㅠㅠ
이전글   |    안드로이드와 아두이노 연결을 어떻게 해야하나요... 2016-09-06
다음글   |    string 조건문 2016-09-07