ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
#startathon2.0 - Spark Core
Spark Core
Spark Core?
Spark Core 
?What is it? 
?Why is it special? 
?How is it implemented? WiFion the front 
ARM on the back 
For more info visit https://www.spark.io/dev-kits
Specs 
?8 digital, 8 analogI/O pins 
?PWM, UART, SPI, I2C, and JTAG 
?Programmed wirelessly (through Spark Cloud), via USB or JTAG. 
?3.3V DCsupply voltage (on board power regulator), USB Mini A powered. 
?Low power consumption (300 mA).
Comparison 
between
Setup Requirement 
USB
Examples
Examples
YoutubeExamples 
?WolowitzLamp -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
Web IDE - Arduino-ishProgramming
Before starting 
?Visit http://docs.spark.io/start/ to setup your Spark Core for the first time.
Web IDE 
?Go to: https://www.spark.io/buildor https://www.spark.io/login 
?For more info visit http://docs.spark.io/build/
Arduinobasics 
?See examples at http://docs.spark.io/examples/ 
?Breadboard connection in RED
Arduino coding 
?Input -pinmode(#,INPUT); 
¨CdigitalRead(); 
¨CanalogRead(); 
?Output -pinmode(#,OUTPUT); 
¨CdigitalWrite(); 
¨CanalogWrite(); 
?Variable (data types) 
¨CContainer for data 
¨Cint, float, char, string 
?Function 
¨Cvoidsetup() {...} 
¨CintdigitalRead() {...} To learn more about coding in arduino, visithttp://www.arduino.cc
Wireless Communication
Communicating with your Spark Core 
?What medium and protocol? 
?Whycommunications protocols? 
?How to use protocols? Internet & HTTPProtocol system of digital rules for data exchange 
Is a technical standard, a common language
HTTP GET & POST methods 
?HTTP= Hyper Text Transfer Protocol 
¨CEnables communication between client and server 
¨CA request-response protocol 
?HTTP requests 
¨CGET = request data fromresource 
¨CPOST = request to senddata toresource 
Default action of the address bar in browser
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 
?jFlasherfor spark core, http://jflasher.github.io/spark-helper/ 
?Spark App on mobile device
One question... 
?What do you need to know before creating your own user interface or tool to remotely control and monitor your Spark Core?
How to use HTTP GET ¨CThe Easy Way 
?Easy way 
¨COpen browser 
¨CType in address bar (be sure to include https://) : https://www.google.com 
?Accessing Spark Core status: 
¨Chttps://api.spark.io/v1/devices/?access_token=[Your Access Token]
How to use HTTP GET ¨CThe Cool Way 
?Cool way ( The Pro¡¯s Way) 
¨CFor Google Chrome browser (recommended): google search for ¡°advanced rest client¡± and click the ¡°+Free¡± button
How to use HTTP GET ¨CThe Cool Way (Cont.) 
?How to use GET to check Spark Core Connection? 
¨CType 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 
¨CYou can do the same in the REST client with Get checked.
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
Get Variables on Spark Core (Cont.) 
Inputs: 
external variable name, variable address, 
data type 
Don¡¯t forget to Flash Device!
?How to get variable? 
¨CSame 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.)
How to use HTTP POST 
?Can you POST through address bar in browser? 
¨CQuery strings ¡ÙPOST variables 
?When to use POST method? 
¨CSending parameters e.g. params=¡°Hello World¡± 
¨CSending large chunks of data e.g. files, webpages, etc... 
?Example of using POST Method
How to use HTTP POST (Example) 
?Open Advance REST client 
¨CType: https://www.posttestserver.com/post.php 
¨CIn payloadtext box, type: params=¡°Hello my name is...¡± 
Don¡¯t forget to check POST
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
Call Function on Spark Core (Cont.)
?Calling the function through the internet 
¨CIn 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 
¨CIn the Payload field, type: 
params=[An integer value] 
e.g. params=200 
Call function on Spark Core (Cont.)
So now what? 
?On Chip 
¨CLearn to use Web IDE 
¨CFlash the core with an Arduino Sketch 
¨CRead sensors and activate actuators 
?Off Chip 
¨CAsk for an exposed variable 
¨CRun a function remotely 
?What about a UI (User Interface)?
UI for the Spark Core - Ideas for making a front end
Spark-CLI 
?http://docs.spark.io/cli/
jFlasher 
?http://jflasher.github.io/spark-helper/
Spark Mobile App 
?Android/IPhone user: 
¨CDownload from Google Play/App Store ¨CSpark CoreApp by Spark Labs 
¨CMake sure Thinker is flashed into Spark Core using app
MIT App Inventor 
?http://appinventor.mit.edu/explore/
Thank you! 
Here¡¯s how you can get connected: 
1 
Facebookpage: www.facebook.com/sl2square 
¡°Maker Circle¡± Facebookgroup 
Email Farah at farah@sl2square.org 
23 
Q & A or 
Start playing with your Spark Core!
Important Points (Summary) 
?Tutorials, examples, help, and get started: 
¨Chttps://docs.spark.io/ 
?The web IDE: 
¨Chttps://www.spark.io/build 
?Spark API: 
¨Chttp://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¡±+

More Related Content

#startathon2.0 - Spark Core

  • 4. Spark Core ?What is it? ?Why is it special? ?How is it implemented? WiFion the front ARM on the back For more info visit https://www.spark.io/dev-kits
  • 5. Specs ?8 digital, 8 analogI/O pins ?PWM, UART, SPI, I2C, and JTAG ?Programmed wirelessly (through Spark Cloud), via USB or JTAG. ?3.3V DCsupply voltage (on board power regulator), USB Mini A powered. ?Low power consumption (300 mA).
  • 10. YoutubeExamples ?WolowitzLamp -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
  • 11. Web IDE - Arduino-ishProgramming
  • 12. Before starting ?Visit http://docs.spark.io/start/ to setup your Spark Core for the first time.
  • 13. Web IDE ?Go to: https://www.spark.io/buildor https://www.spark.io/login ?For more info visit http://docs.spark.io/build/
  • 14. Arduinobasics ?See examples at http://docs.spark.io/examples/ ?Breadboard connection in RED
  • 15. Arduino coding ?Input -pinmode(#,INPUT); ¨CdigitalRead(); ¨CanalogRead(); ?Output -pinmode(#,OUTPUT); ¨CdigitalWrite(); ¨CanalogWrite(); ?Variable (data types) ¨CContainer for data ¨Cint, float, char, string ?Function ¨Cvoidsetup() {...} ¨CintdigitalRead() {...} To learn more about coding in arduino, visithttp://www.arduino.cc
  • 17. Communicating with your Spark Core ?What medium and protocol? ?Whycommunications protocols? ?How to use protocols? Internet & HTTPProtocol system of digital rules for data exchange Is a technical standard, a common language
  • 18. HTTP GET & POST methods ?HTTP= Hyper Text Transfer Protocol ¨CEnables communication between client and server ¨CA request-response protocol ?HTTP requests ¨CGET = request data fromresource ¨CPOST = request to senddata toresource Default action of the address bar in browser
  • 19. 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 ?jFlasherfor spark core, http://jflasher.github.io/spark-helper/ ?Spark App on mobile device
  • 20. One question... ?What do you need to know before creating your own user interface or tool to remotely control and monitor your Spark Core?
  • 21. How to use HTTP GET ¨CThe Easy Way ?Easy way ¨COpen browser ¨CType in address bar (be sure to include https://) : https://www.google.com ?Accessing Spark Core status: ¨Chttps://api.spark.io/v1/devices/?access_token=[Your Access Token]
  • 22. How to use HTTP GET ¨CThe Cool Way ?Cool way ( The Pro¡¯s Way) ¨CFor Google Chrome browser (recommended): google search for ¡°advanced rest client¡± and click the ¡°+Free¡± button
  • 23. How to use HTTP GET ¨CThe Cool Way (Cont.) ?How to use GET to check Spark Core Connection? ¨CType 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 ¨CYou can do the same in the REST client with Get checked.
  • 24. 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
  • 25. Get Variables on Spark Core (Cont.) Inputs: external variable name, variable address, data type Don¡¯t forget to Flash Device!
  • 26. ?How to get variable? ¨CSame 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.)
  • 27. How to use HTTP POST ?Can you POST through address bar in browser? ¨CQuery strings ¡ÙPOST variables ?When to use POST method? ¨CSending parameters e.g. params=¡°Hello World¡± ¨CSending large chunks of data e.g. files, webpages, etc... ?Example of using POST Method
  • 28. How to use HTTP POST (Example) ?Open Advance REST client ¨CType: https://www.posttestserver.com/post.php ¨CIn payloadtext box, type: params=¡°Hello my name is...¡± Don¡¯t forget to check POST
  • 29. 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
  • 30. Call Function on Spark Core (Cont.)
  • 31. ?Calling the function through the internet ¨CIn 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 ¨CIn the Payload field, type: params=[An integer value] e.g. params=200 Call function on Spark Core (Cont.)
  • 32. So now what? ?On Chip ¨CLearn to use Web IDE ¨CFlash the core with an Arduino Sketch ¨CRead sensors and activate actuators ?Off Chip ¨CAsk for an exposed variable ¨CRun a function remotely ?What about a UI (User Interface)?
  • 33. UI for the Spark Core - Ideas for making a front end
  • 36. Spark Mobile App ?Android/IPhone user: ¨CDownload from Google Play/App Store ¨CSpark CoreApp by Spark Labs ¨CMake sure Thinker is flashed into Spark Core using app
  • 37. MIT App Inventor ?http://appinventor.mit.edu/explore/
  • 38. Thank you! Here¡¯s how you can get connected: 1 Facebookpage: www.facebook.com/sl2square ¡°Maker Circle¡± Facebookgroup Email Farah at farah@sl2square.org 23 Q & A or Start playing with your Spark Core!
  • 39. Important Points (Summary) ?Tutorials, examples, help, and get started: ¨Chttps://docs.spark.io/ ?The web IDE: ¨Chttps://www.spark.io/build ?Spark API: ¨Chttp://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¡±+