Spark Core: Initial Thoughts

As with the Pebble smartwatch, I also backed another project called Spark Core, which promised the idea of a small, compact and easy to use Wi-Fi-enabled Arduino like device. And I must say, they certainly delivered!

IMG_20131223_140517

After a few initial problems programming the device from the Spark Cloud (a browser based IDE) which turned out to be mainly my fault (The device appears to rely on a rapid loop() completion to stay in contact with the Spark Cloud and I was inhibiting it with a habitual while(true) loop within that loop, preventing Cloud access) I have succeeded in my first very minor project – interfacing with an Arduino Uno.

The idea is simple: The Adruino sends the characters ‘1’, ‘2’ and ‘3’ in sequence and the Core flashes an attached LED the corresponding number of times.

The Arduino sketch:

void flash(int pin)
{
  digitalWrite(pin, HIGH);
  delay(50);
  digitalWrite(pin, LOW);
  delay(50);
}

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop()
{
  Serial.print('1');
  flash(13);
  delay(1000);
  Serial.print('2');
  flash(13);
  delay(1000);
  Serial.print('3');
  flash(13);
  delay(1000);
}

And the Core code:

int output_led = D0;
int onboard_led = D7;

void flash(int pin);

void setup()
{
    Serial1.begin(9600);
    pinMode(output_led, OUTPUT);
    pinMode(onboard_led, OUTPUT);
}

void loop()
{
    if(Serial1.available() > 0)
    {
        flash(onboard_led);

        char c = (char)Serial1.read();

        switch(c) {
            case '1':
            {
                flash(output_led);
                break;
            }
            case '2':
            {
                flash(output_led);
                flash(output_led);
                break;
            }
            case '3':
            {
                flash(output_led);
                flash(output_led);
                flash(output_led);
            }
        }
    }
}

void flash(int pin)
{
    digitalWrite(pin, HIGH);
    delay(50);
    digitalWrite(pin, LOW);
    delay(50);
}

And finally a video!

Aside from taking a while to discover that the TX RX pins are actually Serial1 and not Serial, the project was simple enough to implement. The Spark Cloud IDE is easy to use and satisfyingly hands-free!

Advertisements
3 comments
  1. E.fried said:

    Cloud vs Privacy? Cloud solutions are not sure against code theft, aren’t they?
    But most important: Is the Spark Core able to work with cut off internet. communicating locally with several Spark cores?

    thanks

    • bonsitm said:

      Hi E.

      Google any news story about big companies being hacked and you’ll find that cloud solutions are not invulnerable to theft.

      As for your question about the Spark Core, take a look at their Cloud API. I’m not sure myself.

      • E.fried said:

        I guess using the cloud is better if they provide end to end encryption. Using Cortex A8 based controllers instead of M3 would however allow using encryption libraries yourself- so I’m still unsure whether using the pcDuino or RaspBerry..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: