These slides were presented at the #startathon2.0 pre-workshop on 20 September covering technology topics. For more information, please contact veera@sl2square.org.
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).
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
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
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¡±+