That helped a ton.
I’ve gone ahead and included the HTTPClient library and now my test is successfully inserting rows into the database.
Here’s the working code so far. My new confusion is how do i put my sensor variables into the actual GET request?
// This #include statement was automatically added by the Particle IDE.
#include <HttpClient.h>
sensor example values, which i’m not sure how to include in the request.path or the request.body
int lightsensor = 10;
int tempsensor = 5;
HttpClient http;
// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
// { "Content-Type", "application/json" },
// { "Accept" , "application/json" },
{ "Accept" , "*/*"},
{ NULL, NULL } // NOTE: Always terminate headers will NULL
};
http_request_t request;
http_response_t response;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println();
Serial.println("Application>\tStart of Loop.");
// Request path and body can be set at runtime or at setup.
request.hostname = "www.example.com";
request.port = 80;
request.path = "/write-datas.php";
// The library also supports sending a body with your request:
//request.body = "{\"key\":\"value\"}";
// Get request
http.get(request, response, headers);
Serial.print("Application>\tResponse status: ");
Serial.println(response.status);
Serial.print("Application>\tHTTP Response Body: ");
Serial.println(response.body);
delay(5000);
}