(fixed) Particle.function() not working correctly when SPI is active

I’m having an issue with particle.function when SPI is active with ILI9341 device attached.

Using a web app to send commands to the Photons.

If I run my Photon with no device actually connected, The function is called as desired, and the argument String is passed in. Once I shut down the unit, and attach a device, repower the Photon, then when the function is called, an empty String is passed to it. Works this way with multiple Photons. Switch back, disconnecting the tft display, and it starts working again.

A week ago (while I was waiting for more displays), it worked just the opposite way … Photon with tft display attached would see the String argument, and one without would not, even though it handled the function.

I would post sample code, but the app is over 900 lines and has a bunch of libraries it uses. I’m using the IDE.

Same code on all the Photons, and the whole publish() and funtion() process is working perfectly, except for the empty command string being passed to the function when an actual ILI9341 tft is attached.

@brianD, you could post your code to a repo in github or zip it up and post on Dropbox or similar. It sounds like you may be going out of bounds on a string array or you are using local instead of global declarations. We really can’t help without seeing any code but I can tell you that SPI and Particle.function don’t conflict so the issue is somewhere in your code. :wink:

1 Like

It did not make sense that there would be a conflict, so I’ll create a simple mini version to test it out. Pretty darn sure I don’t have local/global or String issues, but one never knows for sure.

OK, made a mini version to test, and it works both ways. Time to do some serious code review.
Just too bad that the ILI9341 and mfGFX libraries in the IDE do not compile for the Photon. The latest github version sure is nice. Copy and paste has become my best buddy in the IDE.

WAIT … Not working with the attached display no, I’ll post my code

[quote=“brianD, post:4, topic:19273”]
Just too bad that the ILI9341 and mfGFX libraries
[/quote] The mfGFX library DOES compile for the Photon. The ILI9341 library is not mine and should be updated. I’m assuming you are using my updated photon compatible version here:

Here is the small code example.

// needed to include locally, since these do not build in IDE
// This #include statement was automatically added by the Particle IDE.
#include "fonts.h"

// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_mfGFX.h"

// Needed to get from gitHub, since the IDE version does not compile, and this one is fast
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_ILI9341.h"

Adafruit_ILI9341 tft = Adafruit_ILI9341(A2, A6, A0);

int myFunctionEvent(String command) {
    Particle.publish("myFunctionEvent", command);

void setup() {
    Particle.function("MyFuntion", myFunctionEvent);

	pinMode(A7, OUTPUT);
	analogWrite(A7, 128); // set brightness on screen



void loop() {
    String message;
    message = String::format("%d elapsed seconds", millis()/1000);
    Particle.publish("myLoop", message);


Yep, using your version :innocent:

1 Like

results form the log when no display connected:

event: myFunctionEvent
data: {“data”:“xx”,“ttl”:“60”,“published_at”:“2016-01-20T17:09:34.583Z”,“coreid”:“xxxxxxxxxxxxxxx”}

results when a display is connected. Does not show on screen either

event: myFunctionEvent
data: {“data”:“null”,“ttl”:“60”,“published_at”:“2016-01-20T17:06:47.059Z”,“coreid”:“xxxxxxxxxxxxxx”}

Meant to say the command string is also null on the screen

Went back and looked in more detail at the log. The unit with the screen attached displayed the command String during the first few minutes, then no longer sees the data, but still sees the event.

The unit with no display attached continues to work fine.


Just call me humiliated. Turns out the problem is in the dashboard I’m using to send messages. After moving the display between units, doing a bunch more tests, and more checking … found the real problem.

I was beginning to think it was an issue with one of my six Photons, but no … just a software bug on my part.

1 Like