-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue connecting esp8266_aws_iot #21
Comments
Elie4, I'm not sure exactly, check that you loaded the certs into the ESP8266 using the "ESP826 Sketch data upload" command in the "tools" menu of the sketch. |
hello fixingthingsguy, Thanks for replying. |
Looks like we need to step back. |
One additional point to the "Yes" answer (needs to be done anyhow no matter the answer!) |
Thank you very much my problem is solved. |
@Elie4 I'm getting the same error, How is your problem resolved? |
Please follow the link provided [https://electronicsinnovation.com/how-to-connect-nodemcu-esp8266-with-aws-iot-core-using-arduino-ide-mqtt/] |
hey brother do you solve this error |
The only thing I can think of is1. verify you have enabled or a activated the certs in AWS.2. verify that your data directory for the certs is in same directory as yout .ino .3. Else, please recheck your steps.Goid luck
Sent from Yahoo Mail on Android
On Tue, May 17, 2022 at 8:55 AM, Sai kishore ***@***.***> wrote:
@Elie4 I'm getting the same error, How is your problem resolved?
hey brother do you solve this error
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Above is not correct I believe, it should be afdlkajfj.der not afdlkajfj .der.der
On Tuesday, May 17, 2022, 10:44:22 AM CDT, S B ***@***.***> wrote:
The only thing I can think of is1. verify you have enabled or a activated the certs in AWS.2. verify that your data directory for the certs is in same directory as yout .ino .3. Else, please recheck your steps.Goid luck
Sent from Yahoo Mail on Android
On Tue, May 17, 2022 at 8:55 AM, Sai kishore ***@***.***> wrote:
@Elie4 I'm getting the same error, How is your problem resolved?
hey brother do you solve this error
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Hello Guys, I am new here,
I have a problem with arduino when opening certification files .der type, they don't open i dont know why. here's what i got when opening serial monitor :
...scandone
state: 0 -> 2 (b0)
.state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 10
cnt
connected with Nakhle..., channel 6
dhcp client start...
ip:192.168.2.227,mask:255.255.255.0,gw:192.168.2.1
.
WiFi connected
IP address:
192.168.2.227
Heap: 40504
Failed to open cert file
cert not loaded
Failed to open private cert file
private key not loaded
Failed to open ca
ca failed
Heap: 40504
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
WiFiClientSecure SSL error: Chain could not be linked to a trust anchor.
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
WiFiClientSecure SSL error: Chain could not be linked to a trust anchor.
My Code is the following:
#include "FS.h"
#include <ESP8266WiFi.h>
#include <PubSubClient.h> //https://www.arduinolibraries.info/libraries/pub-sub-client
#include <NTPClient.h> //https://www.arduinolibraries.info/libraries/ntp-client
#include <WiFiUDP.h>
//#define LISTEN_PORT 8883
// Update these with values suitable for your network.
#define MQTT_TOPIC "$aws/things/ESP8266-FYP-test1/shadow/update" //topic for the MQTT
const char* ssid = "Nakhle...";
const char* password = "My Wifi Password ";
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
const char* AWS_endpoint = "a3rbwtuy3wpxaf-ats.iot.us-east-2.amazonaws.com"; //MQTT broker ip
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]); // Pring payload content
}
char led = (char)payload[62]; // Extracting the controlling command from the Payload to Controlling LED from AWS
Serial.print("led command=");
Serial.println(led);
if(led==49) // 49 is the ASCI value of 1
{
digitalWrite(D5, HIGH);
Serial.println("LED_State changed to HIGH");
}
else if(led==48) // 48 is the ASCI value of 0
{
digitalWrite(D5, LOW);
Serial.println("LED_State changed to LOW");
}
Serial.println();
}
WiFiClientSecure espClient;
PubSubClient client(AWS_endpoint, 8883, callback, espClient); //set MQTT port number to 8883 as per //standard
long lastMsg = 0;
char msg[50];
int value = 0;
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
espClient.setBufferSizes(512, 512);
Serial.println();
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());
timeClient.begin();
while(!timeClient.update()){
timeClient.forceUpdate();
}
espClient.setX509Time(timeClient.getEpochTime());
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("ESPthing")) {
Serial.println("connected");
// Once connected, publish an announcement...
client.publish("outTopic", "hello world");
// ... and resubscribe
client.subscribe("inTopic");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
}
}
void setup() {
Serial.begin(9600);
Serial.setDebugOutput(true);
// initialize digital pin LED_BUILTIN as an output.
pinMode(D5, OUTPUT);
setup_wifi();
delay(1000);
if (!SPIFFS.begin()) {
Serial.println("Failed to mount file system");
return;
}
Serial.print("Heap: "); Serial.println(ESP.getFreeHeap());
// Load certificate file
File cert = SPIFFS.open("C:/Users/User/Desktop/ESP8266_AWS-IOTCore/data/cert.der", "r"); //replace cert.crt eith your uploaded file name
if (!cert) {
Serial.println("Failed to open cert file");
}
else
Serial.println("Success to open cert file");
delay(1000);
if (espClient.loadCertificate(cert))
Serial.println("cert loaded");
else
Serial.println("cert not loaded");
// Load private key file
File private_key = SPIFFS.open("C:/Users/User/Desktop/ESP8266_AWS-IOTCore/data/private.der", "r"); //replace private eith your uploaded file name
if (!private_key) {
Serial.println("Failed to open private cert file");
}
else
Serial.println("Success to open private cert file");
delay(1000);
if (espClient.loadPrivateKey(private_key))
Serial.println("private key loaded");
else
Serial.println("private key not loaded");
Serial.print("Heap: "); Serial.println(ESP.getFreeHeap());
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
}
The text was updated successfully, but these errors were encountered: