2016-09-10 58 views

回答

1

一旦你輕鬆表和Arduino的傳感器數據準備好,使用下面的代碼在循環:

char *server = "your-service.azurewebsites.net"; 
int value = arduino-data; 
if (client.connect(server, 80)) { 

    Serial.print("sending "); 
    Serial.println(value); 

    // POST URI 
    sprintf(buffer, "POST https://your-service.azurewebsites.net/Tables/easy-table-name HTTP/1.1"); 
    client.println(buffer); 

    // Host header 
    sprintf(buffer, "Host: %s", server); 
    client.println(buffer); 

    client.println("Accept: application/json"); 
    // JSON content type 
    client.println("Content-Type: application/json"); 

    sprintf(buffer, "{\"value\": %d}", value); 

    client.print("Content-Length: "); 
    client.println(strlen(buffer)); 
    client.println("ZUMO-API-VERSION: 2.0.0"); 
    // End of headers 
    client.println(); 

    // Request body 
    client.println(buffer); 

    } else { 
    Serial.println("connection failed"); 
    } 
相關問題