#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* apiUrl = "https://api.orbitsensors.com/v1/ingest/YOUR_PROJECT_SLUG";
const char* deviceToken = "os_xxxxxxxxxxxxxxxxxxxxxx";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(apiUrl);
http.addHeader("Content-Type", "application/json");
http.addHeader("x-device-token", deviceToken);
// Replace with your sensor reading, e.g. temperature
float temp = 25.3; // readTemperature();
String body = "{\"sensorKey\":\"temperature\",\"value\":" + String(temp) + ",\"payload\":{\"unit\":\"C\"}}";
int code = http.POST(body);
Serial.println(code);
http.end();
}
delay(10000);
}