Addition of pinMode sends Spark Core to red blink loop [solved]

I am writing a program for the Spark Core. It (1) fetches a text file from an URL, (2) extracts parts from every line, and (3) should blink some attached LEDs accordingly. I just started with part 3.

Now every time I add a simple pinMode(D0, OUTPUT); to the code and update the firmware accordingly, it sends the board to SOS panic mode, with eight blinks (#8 Out of heap memory). The actual code does not run.

Why does the addition of pinmode prevents my sketch from running? What can I do to fix it?

UPDATE: Reduced buffer size in Http Client library to 512, now it works. Considering to use REST client lib instead of Http Client.

@akrusen,

i don’t think that might caused the issue?

You are fetching a .txt file and that requires some buffer which might be the cause.

Can you compile and check the RAM usage in the WEB IDE?

You will be able to determine if pinMode(D0, OUTPUT); is indeed the culprit.

Hi Kenneth, I checked the RAM usage:

  • without pinMode: 79.9 %
  • with pinMode: 82.4 %

Could this miniscule addition be the reason?

Maybe this is of concern: For .txt retrieval I use Http Client Library by @nmattisson

Can you try without the httpclient and compile with all the pinMode you need?

That should not cause any SOS.

Thank you. Do you know of a simple way to clone an entire project in the web IDE? Refactoring would feel so much safer actually :smiley:

@akrusen,

as of now, we have yet to implement a mechanism to pull in an entire project!

But i will have your feedback on my list :wink:

It will most likely be a mechanism to pull in all the files in a Github repo and become an App in the Web IDE

WOW speaking of that… Now that the library import function works that way…i don’t think it will be difficult to do this :smiley:

All references to Http Client Library removed: 76.1% RAM used.
Unfortunately, the project is not very useful without the http part. Any ideas are greatly appreciated.

@akrusen,

the suggestion to remove is simply to isolate the code and make sure it’s only the http client is causing the SOS code.

Once you determine that the code is ok without the http client, the other community members can step in to help you work on the SOS. :wink:

hope this helps!

1 Like

Try this REST client, I've had good luck with it... also... can you build locally? If so you can revert back to an older version of code that has more available RAM.

Could you should us where you are adding the pinMode() to?


Also, are you using sprintf() anywhere in your code? If so you can reduce flash memory and most likely ram usage as well by doing a little work:

1 Like

Great help, thank you! I was just about to introduce sprintf, but now I certainly won’t :blush:
pinMode is added to the first lines of setup. I could build locally, that is: I never tried and have not found a good HOWTO. RestClient looks promising, I’ll check it out.

Update: I found a 1024 byte buffer allocation in HttpClient.h, changed it to 512 for now. Spark Core is running again! @nmattisson hope this does not break anything

1 Like