Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting started with the spark core

Getting started with the spark core

For Hackware v0.3

claudiomettler

January 14, 2015
Tweet

More Decks by claudiomettler

Other Decks in Technology

Transcript

  1. 2

  2. hardware • 72MHz ARM Cortex M3 • TI CC3000 WiFi

    • 7 analog IO (pwm out), 7 digital IO • ~ S$ 55 • coming soon: Photon, 120MHz, Broadcom Wifi, half the price 3
  3. setup, the easy and unreliable way • install smartphone app

    • power up spark • use smartphone app to create cloud account and register the core 4
  4. the tinker firmware • default firmware of spark core •

    allows access to all inputs/outputs 7
  5. let’s ask the cloud curl -H "Authorization: Bearer $SPARK_ACCESS_TOKEN” https://

    api.spark.io/v1/devices/$SPARK_CORE_ID/
 
 Alternatively include the token in the URL:
 
 https://api.spark.io/v1/devices/$SPARK_CORE_ID/?access_token= $SPARK_ACCESS_TOKEN 9
  6. output { "id": "53ff71065075535128311587", "name": "schnitzel", "connected": true, "variables": {},

    "functions": [ "digitalread", "digitalwrite", "analogread", "analogwrite" ], "cc3000_patch_version": "1.29" 10
  7. using functions curl https://api.spark.io/v1/devices/$SPARK_CORE_ID/ digitalwrite?access_token=$SPARK_ACCESS_TOKEN -d params=D7,LOW or include access_token

    in POST data: curl https://api.spark.io/v1/devices/$SPARK_CORE_ID/ digitalwrite -d access_token=$SPARK_ACCESS_TOKEN -d params=D7,LOW 11
  8. the javascript API • runs in browser and in nodejs

    • (npm|bower) install spark • http://docs.spark.io/javascript/ 14
  9. voodoospark • alternative firmware • faster communication through local TCP

    connection • npm client module • still uses cloud for facilitating local connection 15
  10. DIY, hardcore mode brew tap PX4/homebrew-px4 brew update brew install

    gcc-arm-none-eabi-48 brew install dfu-util
 git clone https://github.com/spark/core-firmware.git git clone https://github.com/spark/core-common-lib.git git clone https://github.com/spark/core-communication-lib.git 19
  11. flash via USB • press&hold mode button, tap and release

    RST button until LED flashes yellow • spark core is now in DFU mode 22
  12. app structure #include "application.h"
 int example(String command); void setup(){ //

    set up cloud functions & variables, IO pin modes Spark.function("example", example); pinMode(D7, OUTPUT); } void loop(){ // called continuously } int example(String command){ digitalWrite(D7, HIGH); delay(2000); digitalWrite(D7, LOW); return 1; } 26
  13. app structure { "id": "53ff71065075535128311587", "name": "schnitzel", "connected": true, "variables":

    {}, "functions": [ "example" ], "cc3000_patch_version": "1.29" 27
  14. my current project • websockets • static site hosted on

    S3 • direct connection from browser to spark • https://github.com/ponyfleisch/cloudlamp 30