ESP32 to NEST not connecting


#1

EDIT: I should also add that I am not able to get any of the postman snippets to generate the function that the postman itself generates. Any help would be greatly appreciated. At this point I am just trying to proof out the fact that I can generate the GET request by some means other than postman.

ORIGINAL:
You will have to excuse my inexperience. I am working to get a REST GET from my emulated NEST. I am able to get the desired GET response when using postman per the NEST developers tutorial. however, when I attempt to utilize the GET request from a ESP32 I am unable to connect. more precisely the HTTPSecureClient on the ESP32 is not able to connect to the following section always returns -11 or (not connected):

if (!client.connect(temp, 443))
Serial.println(“Connection failed!”);
else {
Serial.println(“Connected to server!”);
}

I do not see this being an issue with the esp32 as I am able to complete other HTTPS GET request for other environments that are not NEST related. (also, i’ve tried a number of different host configurations i.e. https://developer-api.nest.com, developer-api.nest.com, 52.87.123.90, etc with no luck).
Again I am very new to this so any detailed help would be greatly appreciated.


#2

Can you share the full code of your GET call?

I’ve never tried to access the API via ESP32, so I probably won’t have a definitive answer for you, but it’s hard to tell what you’re doing wrong without the code.


#3

jbumgarner:

I am not sure if there is a better way to include code snippets, but below is my redacted code structure. the current state is exactly as I executed except the removal of sensitive information:

Also, I have been looking at this more and am thinking that I need to get a ssl cert. but I am not sure. The esp32, ssl and https.


#4

here is the second image. the posting requirements are very restrictive…


#5

Are you passing all the required headers somewhere else? I don’t see them here, your connect call only seems to be using an IP address. A regular REST GET call will use a proper endpoint and the Authorization and Content-Type headers.


#6

Thanks for the response,

As I understand it (from the esp32 git examples) I should try to connect via client.connect(server,port) then I would input construct the GET request via the client.println(…). Ultimately, this is where I am putting the lines associated with the postman GET output. Currently I have that section commented out because I can not establish the connection to begin with:

Maybe I am missing something before the client.connect(server.port) section because it is failing there. i.e. returns “Connection Failed”… when I looked deeper into the function calls there was a returned value of -11 (or not connected).


#7

Okay I see. That’s not how our API works… you don’t connect to a server and then make a call. You simply make a GET call to whatever endpoint you want results from.

So all you need to do is get your ESP32 online, and make the GET call you want using the appropriate endpoint and headers. That WifiSecureClient library isn’t what you need. I think you just need HTTPClient. This should help: https://techtutorialsx.com/2017/05/19/esp32-http-get-requests/