#startathon2.0 - Spark Core
description
Transcript of #startathon2.0 - Spark Core
![Page 1: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/1.jpg)
![Page 2: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/2.jpg)
Spark Core
![Page 3: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/3.jpg)
Spark Core?
![Page 4: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/4.jpg)
Spark Core
• What is it?
• Why is it special?
• How is it implemented?
WiFi on the front ARM on the back
For more info visit https://www.spark.io/dev-kits
![Page 5: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/5.jpg)
Specs
• 8 digital, 8 analog I/O pins• PWM, UART, SPI, I2C, and JTAG • Programmed wirelessly
(through Spark Cloud), via USB or JTAG.
• 3.3V DC supply voltage (on board power regulator), USB Mini A powered.
• Low power consumption (300 mA).
![Page 6: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/6.jpg)
Comparison between
![Page 7: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/7.jpg)
Setup Requirement
USB
![Page 8: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/8.jpg)
Examples
![Page 9: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/9.jpg)
Examples
![Page 10: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/10.jpg)
Youtube Examples
• Wolowitz Lamp - http://www.youtube.com/watch?v=BW9FbjjkKo4
• RC Car- http://www.youtube.com/watch?v=D6k7bMYXRiU
• Snake game - http://www.youtube.com/watch?v=7EJ-d9rizAE
• RFID Locker - http://www.youtube.com/watch?v=BLVLL3qkTlU
![Page 11: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/11.jpg)
Web IDE -Arduino-ish Programming
![Page 12: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/12.jpg)
Before starting
• Visit http://docs.spark.io/start/to setup your Spark Core for the first time.
![Page 13: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/13.jpg)
Web IDE
• Go to: https://www.spark.io/build or https://www.spark.io/login
• For more info visit http://docs.spark.io/build/
![Page 14: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/14.jpg)
Arduino basics
• See examples at http://docs.spark.io/examples/
• Breadboard connection in RED
![Page 15: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/15.jpg)
Arduino coding
• Input - pinmode(#,INPUT);
– digitalRead();
– analogRead();
• Output - pinmode(#,OUTPUT);
– digitalWrite();
– analogWrite();
• Variable (data types)
– Container for data
– int, float, char, string
• Function
– void setup() {...}
– int digitalRead() {...}
To learn more about coding in arduino, visit
http://www.arduino.cc
![Page 16: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/16.jpg)
Wireless Communication
![Page 17: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/17.jpg)
Communicating with your Spark Core
• What medium and protocol?
• Why communications protocols?
• How to use protocols?
Internet & HTTPProtocol system of digital rules
for data exchange
Is a technical standard, a common language
![Page 18: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/18.jpg)
HTTP GET & POST methods
• HTTP = Hyper Text Transfer Protocol
– Enables communication between client and server
– A request-response protocol
• HTTP requests
– GET = request data from resource
– POST = request to send data to resource
Default action of the address bar in
browser
![Page 19: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/19.jpg)
Requirement for remote Spark Core
• Expose internal variables or function to cloud• Spark.variabe(“*exposed name+”, &*internal variable+,*data type+);
• Spark.function(“*exposed name+”, [internal function]);
• A tool or user interface to remotely interact with Spark Core
• jFlasher for spark core, http://jflasher.github.io/spark-helper/
• Spark App on mobile device
![Page 20: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/20.jpg)
One question...
• What do you need to know before creating your own user interface or tool to remotely control and monitor your Spark Core?
![Page 21: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/21.jpg)
How to use HTTP GET – The Easy Way
• Easy way
– Open browser
– Type in address bar (be sure to include https://) : https://www.google.com
• Accessing Spark Core status:– https://api.spark.io/v1/devices/?access_token=[Your Access Token]
![Page 22: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/22.jpg)
How to use HTTP GET – The Cool Way
• Cool way ( The Pro’s Way)
– For Google Chrome browser (recommended): google search for “advanced rest client” and click the “+Free” button
![Page 23: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/23.jpg)
How to use HTTP GET – The Cool Way (Cont.)
• How to use GET to check Spark Core Connection?
– Type in browser address bar:
https://api.spark.io/v1/devices/[Device ID]/?access_token=[Access Token]
e.g. https://api.spark.io/v1/devices/4...7/?access_token=5...5
– You can do the same in the REST client with Get checked.
![Page 24: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/24.jpg)
Get Variables on Spark Core
• Easiest way to obtain variables on the Spark Core is to:
1. Expose the variable to the cloud
2. Use the HTTP Get method to request for variable
![Page 25: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/25.jpg)
Get Variables on Spark Core (Cont.)
Inputs: external variable name,
variable address, data type
Don’t forget to Flash Device!
![Page 26: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/26.jpg)
• How to get variable?
– Same as before, type in browser or REST Client: https://api.spark.io/v1/devices/[Device ID]/[External Variable]?access_token=[Access Token]
e.g. https://api.spark.io/v1/devices/4...7/exposed_dly?access_token=5...5
Get Variables on Spark Core (Cont.)
![Page 27: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/27.jpg)
How to use HTTP POST
• Can you POST through address bar in browser?
– Query strings ≠ POST variables
• When to use POST method?
– Sending parameters e.g. params=“Hello World”
– Sending large chunks of data e.g. files, webpages, etc...
• Example of using POST Method
![Page 28: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/28.jpg)
How to use HTTP POST (Example)
• Open Advance REST client
– Type: https://www.posttestserver.com/post.php
– In payload text box, type: params=“Hello my name is...”
Don’t forget to check
POST
![Page 29: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/29.jpg)
Call Function on Spark Core
• Calling functions on the Spark Core requires POST method:
1. Expose the function to the cloud
2. Use the HTTP Post method to call the function
Same Example
![Page 30: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/30.jpg)
Call Function on Spark Core (Cont.)
![Page 31: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/31.jpg)
• Calling the function through the internet
– In REST Client, type: https://api.spark.io/v1/devices/[Device ID]/[Exposed Function name]?access_token=[Access Token]
e.g. https://api.spark.io/v1/devices/4...7/chgDlyFunc?access_token=5...5
– In the Payload field, type:
params=[An integer value]
e.g. params=200
Call function on Spark Core (Cont.)
![Page 32: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/32.jpg)
So now what?
• On Chip
– Learn to use Web IDE
– Flash the core with an Arduino Sketch
– Read sensors and activate actuators
• Off Chip
– Ask for an exposed variable
– Run a function remotely
• What about a UI (User Interface)?
![Page 33: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/33.jpg)
UI for the Spark Core -Ideas for making a front end
![Page 35: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/35.jpg)
jFlasher
• http://jflasher.github.io/spark-helper/
![Page 36: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/36.jpg)
Spark Mobile App
• Android/IPhone user:
– Download from Google Play/App Store – Spark Core App by Spark Labs
– Make sure Thinker is flashed into Spark Core using app
![Page 37: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/37.jpg)
MIT App Inventor
• http://appinventor.mit.edu/explore/
![Page 38: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/38.jpg)
Thank you!
Here’s how you can get connected:
1 Facebook page: www.facebook.com/sl2square
“Maker Circle” Facebook group
Email Farah at [email protected]
2
3
Q & A or Start playing with your Spark Core!
![Page 39: #startathon2.0 - Spark Core](https://reader033.fdocuments.net/reader033/viewer/2022060120/55933fc11a28ab97138b467e/html5/thumbnails/39.jpg)
Important Points (Summary)• Tutorials, examples, help, and get started:
– https://docs.spark.io/
• The web IDE:– https://www.spark.io/build
• Spark API:– http://docs.spark.io/api/
• Request list of available cores:• GET https://api.spark.io/v1/devices/?access_token=[Your Access Token]
• Request status of core:• GET https://api.spark.io/v1/devices/[Device ID]/?access_token=[Access Token]
• Request variable of core:• GET https://api.spark.io/v1/devices/[Device ID]/[Exposed Variable]?access_token=[Access Token]
• Activate function in core:• POST https://api.spark.io/v1/devices/[Device ID]/[Exposed Function]?access_token=[Access Token]
• Payload: params=*value or “string”+