Author Topic: Help with HTTPClient  (Read 2288 times)


  • Newbie
  • *
  • Posts: 3
Help with HTTPClient
« on: October 10, 2016, 12:22:44 pm »
I finally decided to use one of my Oaks to do a project and was inspired by this

However, I'm getting stuck on getting the HTTPClient working for HTTPS connections.  This is essentially the code I've been trying to get working and having difficulty wit:

Code: [Select]
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

String gmapjson = ",-123.0525&destinations=49.31197,-123.02888&key=[mykey]";
String gmapfingerprint = "3F AE 17 DA 03 65 45 BE CE 77 2F 8A DC 5B C9 08 98 7E 9E E7";

void setup() {
  // put your setup code here, to run once:
  Particle.println("Hello world!");
  while (WiFi.status() != WL_CONNECTED)
  Particle.println("WiFi connected");
  Particle.println("IP address: ");

void loop() {
  Particle.println("In the loop!");
  HTTPClient http;
  Particle.print("URL: ");
  http.begin(gmapjson, gmapfingerprint);
  int httpCode = http.GET();
  Particle.print("Status code: ");
 // String response = http.getString();
 // Particle.println(response);
  for (int i=1; i < 10; i++) {
    digitalWrite(1, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(1000);               // wait for a second
    digitalWrite(1, LOW);    // turn the LED off by making the voltage LOW
    delay(1000);               // wait for a second

When I try running this it chokes and then must be put in safe mode to be recovered.  I think it happens at "HTTPClient http;".

If anyone can point me to what I have done wrong, it would be appreciated. 

I also noticed that the Particle.println are all adding garbage at the end of the string.  Any idea why that is happening?



  • Full Member
  • ***
  • Posts: 135
Re: Help with HTTPClient
« Reply #1 on: October 17, 2016, 01:43:57 pm »
Might be worth checking which version of esp8266httpclient you are using, because it looks like some versions had issues with https.

Regarding the garbage, I'd be wanting to find a way to confirm if the garbage is there on the Oak, or just being added by Particle (or on the way to Particle)?

Maybe concatenate two strings together into a new string, then particle.println one after the other the two original strings, and the joined string. See if the garbage remains at the end, or follows into the middle of the merged string, or just occurs once at the end of the merged string. Also does the garbage change between string and concatenated version?

Then next time try changing the order so you print the original two before concatenating and printing joined string. In case the particle.println is corrupting the strings.

Then try doing particle.println for all variables, followed by another set of printing all variables again to see if the printed strings match each other, and if the garbage the 2nd time matches the first time.

These tests should hopefully let you confirm definitively whether the problem is occurring on the Oak and is possibly related to https problems, or whether it is just random garbage being put there by particle. Hopefully it is just Particle, and your strings have integrity on the Oak (eg they are not screwing up you url string etc)



  • Newbie
  • *
  • Posts: 3
Re: Help with HTTPClient
« Reply #2 on: December 04, 2016, 12:28:35 am »
I never was able to get https working.  Tried a few different things, but consistently caused it to hang. 

Eventually decided to use a webserver I have to relay it through.  This had the added advantage of being able to do some of the parsing/processing in PHP.

I also wanted to mention in case others find this posting, that the WiFi.begin() etc... is not necessary.