Using Lelylan with the core

I tried to use the example code on lelylan’s site (http://lelylan.github.io/lab-projects/spark-core-light/), but it can’t compile. (http://pastebin.com/uT6d20fP)

Anyone got an idea on what is wrong with it? Also, to me it looks like this can only handle one function, sounds a bit of a waste if that is the case.

In mqtt.cpp you can remove #include <string.h>

In mqtt.h you can replace #pragma GCC diagnostic ignored "-Wwrite-strings" with #include "application.h" and it will compile :wink:

Thank you! It did indeed compile, and it also successfully flashed the core. However after flashing, the blue led on the core turns on, while the led is continuing to breathe, and the core seems to be out of reach.

Any idea what could cause that?

Did you add the external switch and press it before that D7 LED turned on?

void loop() {
  lelylanConnection();
 
  char* value;
  reading = digitalRead(inPin);  // read the button state
 
  // if the input just went from LOW and HIGH and we've waited long enough to ignore
  // any noise on the circuit, toggle the output pin and remember the time
  if (reading == HIGH && previous == LOW && millis() - t > debounce) {
    if (state == LOW) {
      Serial.println("[PHYSICAL] Led turned on");
      lelylanPublish("on");
      state = HIGH;
    } else {
      Serial.println("[PHYSICAL] Led turned off");
      lelylanPublish("off");
      state = LOW;
    }
 
    t = millis();
  }
  // effectively update the light status
  digitalWrite(outPin, state);
  previous = reading;
}

I didn’t fully dive into this yet, but I would want this line pinMode(inPin, INPUT); // button pin setup to be

pinMode(inPin, INPUT_PULLUP); // button pin setup

Doesn’t it need to be pinMode(inPin, INPUT_PULLDOWN ); ? it seems to check if it got pulled high, from low.

I already tried with the pulldown, and it didnt work. I tried to reset to firmware, change pins to output D0, it then turns D0 on instead.

It takes about 30 seconds from it is powered up, until it turns the pin high. After going high, it stays there for about 30 seconds, then starts flashing the led red, and the cycle restarts…

(I am also really learning my wifi credentials again again again…)

I tried to totally remove the part where it checks for a button, so it isn’t that part. Looks like it just takes a long time to connect to their service. Then a bit time passes, and it then restarts…

Oh I see, the Fritzing schematic shows an external 220 ohm pull-down resistor, and the switch connects 3.3V to D3 when pressed. So if you have it wired that way you can leave it as INPUT only. I have no idea why it would get hung up as I’m not very familiar with that MQTT library… but it sounds like it might be possibly seeing a hard fault or running out of memory. You should see an SOS light pattern, followed by a certain number of flashes from 1 or 8 typically. Here are all of the codes:
http://docs.spark.io/troubleshooting/#troubleshoot-by-color-flashing-red

Could look like a SOS

Yeah that’s SOS followed by 1 flash, hard fault. Likely some bad code. Try chopping out sections like the calls to Lelylan first… and see if the button press can make the LED turn on and off first… and then add pieces back slowly.

Great… So far I had nothing but problems with every single thing I tried to make with my Spark Core, so I ended up with lelylean as the thing I could use my spark core with, without having to use my own code which apparently does something wrong, even when it is super simple… aaaand then the example code from lelylan is broken, and got even worse bugs…

Wish the “remember wifi credentials” was in the app… already written it in so many times today… drives me insane having to do it over and over

Hey Mikey, sorry you’re having trouble. What other things have you tried?

Also, maybe you’d like to give IFTTT Beta a try:
https://community.spark.io/t/ifttt-beta-testers-needed/8552