I’m working on a little project where I wanted to use my Adafruit I2C 16x2 RGB LCD (click here for product page) with one of Spark Cores.
I have a good bit of experience with Arduinos and programming but I’m not anywhere near being a master–if I make a simple mistake, you’ll have to forgive me.
I found a GitHub for the appropriate Adafruit library that was modified by pkourany to work with the Spark Core. You can find it here.
I loaded the Hello World.ino example found on the GitHub repository and I flashed it to the Core. The flash worked perfectly but now I am not getting to the Cloud. The core is breathing green. I hit the reset button, it breathes white for 2 cycles, blinks green quickly and then starts to breathe green rather than cyan.
It was breathing cyan correctly before I flashed and I haven’t had this problem before (though I’m not very good with Spark Cores and haven’t made a project work on them like I have with Arduinos).
I haven’t made any modifications to what is on the GitHub repository, so, I added the hyperlink rather than posting my code. The way I have it structured in the IDE is like this:
I am also getting a significant amount of instability in the compiled program and it starts printing a scrolling jumbled mess after running for 5 minutes or so. I also can’t get the display to show unless I type “particle identify” in command shell on my computer (Spark Core is connected via USB). I’ll make another post regarding those issues. I want to keep this post in the realms of why it is breathing green.
I am using Spark Cores. I believe it was either their first or second batch. Kind of old, I know, but I fell in love with them immediately (I refuse to make a joke involving love at first byte–I’m above that).
I have done a ton of projects with Arduinos and stand-alone applications in other languages but, for some reason, I have the hardest time using Cores. I understand the process but when it comes to actually making things work, I always end up scratching my head and putting it away until a more experienced version of myself comes along to break it out and try it again. I feel I’m at that point and I want to overcome each hurdle I come to.
So, do invocations to the Particle.process() need to be done each time?
I’m guessing that explains why my LCD wouldn’t show anything until I sent a serial command to it. Is there any reason to keep the line of code that holds until something is sent via serial? Does that have any purpose or function and if I remove it, will it destabilize the sketch?
Particle.process() is a way to trigger the background task (like cloud houskeeping) which would otherwise happen between iterations of loop().
Since that while() would keep the code flow from dropping out of setup() the background tasks would never be executing, resulting in a loss of cloud connection. To prevent that, you call Particle.process() whenever your code might be “blocking” the background for more than 10sec.
The reason for this line to be present in multiple samples is to make sure you’ve got time to spin up your serial monitor to see the debug output form the beginning of your code. Once it runs without issues, you’d comment that line (or wrap it in a #ifdef DEBUGGING ... #endif along with other debug blocks).
BTW, if you get stuck, we are here to get you unstuck - and usually quite quickly too, as you may have noticed