The use of the ESP8266 in the world of IoT

User avatar
By Kumaran G
#78104 Hi Experts,

Source: NoceMCU ESP8266
Target: SAP IoT cockpit (https://host:port/iot/gateway/rest/measures/<Client_ID>)
Protocol: Https (certificate based)

I am new to this forum and an beginner in Arduino programming. I am using a Nodemcu (ESP8266) to collect data from few sensors and trying to update data to SAP IoT Cockpit using API via HTTPS connectivity.

I already went through couple of blogs which updates SAP HCP from Arduino/ESP8266, but I still couldn't post data. Most of them have Oauth configuration, but I don't have that as my client doesn't provide one.

As mine is a secured connectivity and have a pem file (certificate), I converted the same to ".crt" and copied the finger print to my code as shown below.

const char* fingerprint = "‎e7:43:65:6e:d4:b3:9f:7f:d5:.........";

if (client.verify(fingerprint, host)) {
Serial.println("certificate matches");
} else {
Serial.println("certificate doesn't match");
}

The endpoint URL (target URL) of IoT cockpit has a different certificate when compared to the certificate provided by my client (gateway certificate of device). Anyone tell me which one to use?.

I tried using both finger prints -
* Doesn't work with gateway certificate's fingerprint (throws "doesn't match.." error)
* Finger print (Certificate) of Target URL Says "Certificate matches", but it doesn't update data to IoT cockpit.


And my post command is as below..

client.print(String("POST ") + url + " HTTP/1.0\r\n" +
"Host: " + host + ":" + "8883" + "\r\n" +
"Content-Type: application/json;charset=utf-8\r\n" +
"Content-Length: " + post_payload.length() + "\r\n\r\n" +
post_payload + "\r\n\r\n");

Could someone please advice if they have idea about this and what I am missing in my code?. I will update the complete code as attachment.

Thanks in advance for help!.


Regards,
Kumaran