정보나눔

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

수박쨈님의 도어 알람이!!
JDK | 2016-12-13

안녕하세요.

수박쨈선생님의 도어 알람이 구현을 위해 무단히 노력중입니다ㅠㅠ

잘 안되는 부분이 있어서 질문 하겠습니다!!

알려주신 코드소스로 업로드하고 시리얼모니터를 확인하면 에러부분이 있습니다.

그리고 또 의문점이 드는건 pushingbox 사이트에서 Test Scenario를 눌러도 핸드폰에는 알람이 안 울립니다

그 전까지는 잘 따라하였습니다~

혹시 어디가 문제인지 알 수 있으실까요??ㅠ

 

 

사용한 코드입니다.

#include
#include "WizFi250.h"

#define DEVICEID      "deviceID"

char ssid[] = "iptime333";      
char pass[] = "*******";       
int status = WL_IDLE_STATUS;     

char server[] = "api.pushingbox.com";

unsigned long lastConnectionTime = 0;      
const unsigned long postingInterval = 5000L;

boolean getIsConnected = false;

String rcvbuf;


WiFiClient client;

void httpRequest();
void printWifiStatus();

void setup()
{

  Serial.begin(115200);
  Serial.println(F("\r\nSerial Init"));

  pinMode(8, INPUT_PULLUP);

  WiFi.init();

 
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");
  printWifiStatus();
}

void loop()
{
  while (client.available()) {
    char c = client.read();
    if ( c != NULL ) {
      if (rcvbuf.length() > 20)
        rcvbuf = "";
      rcvbuf += c;
      Serial.write(c);
    }
  }
  if (millis() - lastConnectionTime > postingInterval) {
    if (digitalRead(8)) {
      httpRequest();
    }
  }
  rcvbuf = "";
}


void httpRequest()
{
  Serial.println();

  client.stop();


  if (client.connect(server, 80)) {
    Serial.println("Connecting...");

    client.print(F("GET /pushingbox?devid=vEC5667668DE0745"));
    client.print(DEVICEID);
    client.print(F(" HTTP/1.1\r\n"));
    client.print(F("Host: api.pushingbox.com\r\n"));
    client.print(F("User-Agent: Arduino\r\n"));
    client.print(F("\r\n\r\n"));

    lastConnectionTime = millis();
    getIsConnected = true;
  }
  else {
    Serial.println("Connection failed");
    getIsConnected = false;
  }
}

void printWifiStatus() {
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);


  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

 

시리얼 모니터 에러 부분입니다.

[WizFi250] Connecting to api.pushingbox.com
Connecting...
HTTP/1.1 400 InvalidQueryParameterValue
Set-Cookie: 60gpBAK=R1224194687; path=/; expires=Tue, 13-Dec-2016 12:10:41 GMT
Date: Tue, 13 Dec 2016 11:05:49 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Set-Cookie: 60gp=R2337129332; path=/; expires=Tue, 13-Dec-2016 12:11:23 GMT
Server: Apache
Content-Location: pushingbox.php
Vary: negotiate,Accept-Encoding
TCN: choice
X-Powered-By: PHP/5.5.35

3e
<?xml version="1.0" encoding="UTF-8"?><error>Bad DevID</error>
0

프로필사진

수박쨈 2016-12-14 09:21:28

#define DEVICEID      "deviceID"

 

여기에 deviceID를 따로 입력해주신건가요?

Bad DevID가 뜨는 것을 보면 디바이스ID에러인거 같네요.

프로필사진

JDK 2016-12-14 12:00:06

#define DEVICEID      "deviceID"

 

헤더파일 이곳에는 따로 입력을 하지 않았습니다

저의 deviceID를 따로 입력해보겠습니다 감사합니다!!

이전글   |    아두이노 회로도 문제 2016-12-13
다음글   |    알코올센서로 음주측정기 코딩하기 2016-12-13