Skip to content

Instantly share code, notes, and snippets.

@hocarm
Last active May 2, 2019
Embed
What would you like to do?
#include <ESP8266WiFi.h>
#include <AmazonIOTClient.h>
#include "ESP8266AWSImplementations.h"
Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;
AmazonIOTClient iotClient;
ActionError actionError;
char *ssid="HocARM";
char *password="12345678";
void setup() {
Serial.begin(115200);
delay(10);
// Connect to WAP
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
iotClient.setAWSRegion("us-east-1");
iotClient.setAWSEndpoint("amazonaws.com");
iotClient.setAWSDomain("a1yldg4jxcj5mx.iot.us-east-1.amazonaws.com");
iotClient.setAWSPath("/things/IotTestDevice/shadow");
iotClient.setAWSKeyID("AKIAIFYKE3UKXDGJIYGA");
iotClient.setAWSSecretKey("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");
iotClient.setHttpClient(&httpClient);
iotClient.setDateTimeProvider(&dateTimeProvider);
}
void loop(){
char shadow[100];
strcpy(shadow, "{\"state\":{\"reported\":{\"test_value1\":123, \"test_value2\":234}}}");
Serial.println("Trying to send data");
Serial.print(shadow);
char* result = iotClient.update_shadow(shadow, actionError);
Serial.print(result);
delay(10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment