Last active
May 2, 2019 01:37
-
-
Save hocarm/0a8d2e67ab2b259503d87dbae7e93639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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