I am trying to register an arduino nano IoT and send data to aws.
I can't quite figure out how to register it. I tried following this tutorial but it seems outdated.
https://docs.arduino.cc/tutorials/mkr-wifi-1010/securely-connecting-an-arduino-mkr-wifi-1010-to-aws-iot-core?_gl=11swxraj_gaNzIwNDk2MzgyLjE2OTkzNzgyNDc._ga_NEXN8H46L5MTcwMTEwMjk0Mi44LjEuMTcwMTEwMjk0Mi4wLjAuMA.._fplc*N3g3c2ZJRnM3d0dIS3BXUDhqYjlIcG9tbWJWJTJCN0clMkZmcGlUN05YRGVQNFFGUm5MRVFEdXlydWNiZzB6b3JEYU55NUppcFF0eXpuV2NiUjM4OGQ1V052eXg1VWdwJTJCZTRrQ092UWhpaXJSOXZTNkhUaGJPaGh4Y0hTQjFUTk93JTNEJTNE.
I want to be able to upload real time vibration data from dozen's of devices to s3 bucket for reporting.
void loop() {
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
if (WiFi.status() == WL_CONNECTED) {
wifiClient.stop(); // Explicitly close the previous connection
delay(10); // Short delay to ensure the close command is processed
// Prepare the JSON payload
String jsonPayload = "{\"x\":" + String(x, 4) + ",\"y\":" + String(y, 4) + ",\"z\":" + String(z, 4) + "}";
// Make an HTTP POST request
httpClient.beginRequest();
httpClient.post(resourcePath);
httpClient.sendHeader(HTTP_HEADER_CONTENT_TYPE, "application/json");
httpClient.sendHeader(HTTP_HEADER_CONTENT_LENGTH, jsonPayload.length());
httpClient.beginBody();
httpClient.print(jsonPayload);
httpClient.endRequest();
// Normally, we would read the response here, but it's omitted for speed
} else {
Serial.println("WiFi Disconnected");
}
}
// Avoid using delay() in the loop if you want to catch every accelerationAvailable event.
}