This is my first post on the Spark community and while I don’t have my Spark Cores yet, they should be in by next week and I’m very excited to start working with them. Some background info:
I’ve been using the Arduino and the Intel Edison for about 3 and 2 weeks respectively I’m pretty comfortable with Arduino now; also I have a good background in electronics and general “coding”. But I can get pretty lost and caught up in all the internet/WiFi/server gerble and I’m just looking for a good place to start.
Overall goal : (at the moment) to read one piece of data from a sensor with the Spark Core and push it to a server that I will be using (don’t know which yet) where the data will be saved on some sort of text file. Then eventually use the Tinker feature to control some pins, nothing too crazy at the moment.
I saw on the docs page from spark some reference to curl and Json, which I have no idea what either are, do I need to learn about these to achieve my overall goal? Generally my question is: Is there any documentation or anywhere I can be directed that shows, not exactly, but explains how to work with things like Rest APIs , curl, Json or any other tools that I need to achieve my “Overall goal”? WiFi development for dummies?
Any insight or direction would be greatly appreciated
It sounds like you have a great background for doing project on Spark!
First some terminology jargon busting:
Curl is a program that runs on your PC/Linux/Mac that can do the kinds of web requests a web browser does, but from the command line. Using curl, you can fetch a web page which is a GET request or do what your browser does when you click a button on a web page form to submit something to a website which is a POST request. This is super useful for dealing with web stuff and testing out the Spark cloud. Once you have tested things out, you will like move on past curl.
JSON is Javascript web programming language data-structure. It is very flexible and designed to be carried around the web and is used under the hood a lot on web pages. But at its core, it is just a named field and value data-structure that you use to pass values around.
I would recommend you start by reading the Getting Started by of the doc here:
and then move on to the Tutorial section of the forum here:
I have a JSON Spark.publish() tutorial in there that shows you how to create a JSON on your core (it’s easy) and then how to parse and use one on a web page that receives your published data.
Thank you for the speedy response really appreciate it! I read most of the get started docs yesterday so the tutorial section should be a great place to look; and I will for sure check out your JSON tutorial
Just one question when you said:
Did you mean that once I learn curl, then I'll move onto JSON; I thought they were both needed together? If JSON is the step up from curl I might just try jumping into your JSON tutorial and see if I get the hang of it.
Once you have mastered curl on the command line, you will want to have real programs for testing. These include things like your own web pages or NodeJS programs or python or other languages on PC/Mac/Linux.
The core can do a lot by itself, but the internet connected part of the core need to interact with the world via these types of programs.
Just to clarify; CURL and JSON have absolutely NOTHING to do with each other. CURL is a command line program you use to create REST requests. JSON is JavaScript Object Notation. It’s a syntax which is used to communicate data which is easy to parse. It’s used all over the web, and with nodeJS getting increasingly bigger, it will go on to play an even more important role. This data type is also being used when you do a REST request to Spark. The server answers you with data, formatted in the JSON syntax. It exists as {“key”:“value”} pares! which can be easily parsed be almost all programming languages, JavaScript in particular.
As to the usage of CURL; personally, I could get it to work properly, and it wasn’t worth the hassle to go on with it. There are some excellent online services which can generate these requests for you. The ‘postman’ plugin for chrome is an excellent example of this. It can do everything CURL can, and is more user friendly, so definitely worth checking out. Also, depending on which programming language you’re comfortable with, there’s almost certainly a method to generate those request using that language.
Appreciate the extra info, I’ve read the word Postman somewhere in a thread; I’ll definitely give it a look especially for the user friendly aspect. So programs like Curl and Postman are meant to create REST requests which interface with REST APIs like the Spark Cloud?
Hopefully I got that right, cause I think I’m beginning to understand a little better. Then @bko 's tutorial on JSON should clarify your info further for me.
That sounds about right. Both programs can make those requests, just like your internet browser does. Since your browser is not as easy to use to create those requests, additional programs are often prefered (like here). Although there are even friendlier services out there, I’d recommend playing around with the REST stuff before using those. If you are to implement the relevant commands in your application later on, it really helps to know how such a command is issued. Once you’ve got that figured out, you could use something like this perhaps, which makes it even easier. That one is also useful for debugging. When your POSTMAN command doesn’t work, you can use it to verify whether or not it works at all.
Anyhow, definitely check out the tutorials by @bko, they’re amazing, and you’ll learn a lot (I know I did!)
Don’t hesitate to ask for help or clarification, should you require any further information!
Don't mean to jump as soon as I don't understand what you said; but when you said "here" did you mean to link something? Playing with what "REST stuff" , curl and Json? Also "those" is referring to the friendlier services? xD
Don't mean to be so nit picky and annoying but could help with an action plan on what to tackle first. I also agree with what you said, it's much better in the long run to understand the fundamentals then switch to an easier way and understand why exactly it's easier. Diving into @bko's tutorial right now, just had to do something before I did. Thanks again!
You’re not nit picky, nor are you annoying. Upon re-reading I noticed I was indeed a bit vague. What I meant to say was that addidtional programs are often prefered over your browser, in cases where you need more flexibility, when you’re programming things like the Spark for example.
With “REST stuff” I meant familiarising yourself with making REST requests, and the way they are structured. This will ensure you’ll be more capable when you need to work with them later on. CURL is good for this since it’s probably the most elementary form in which you can make these requests, but postman should suffice. How you choose to get up to par is up to you, as long as you get a basic grip of how REST works.
Just for clarification purposes; JSON has absolutely nothing to do with REST. Although they’re often used together, they do not depend on each other. CURL is a program, JSON a syntax. It’s like comparing internet explorer with a .CSV document. One is a program which allows you to interact with the REST protocol, the other is merely a data format, much like CURL/JSON.
“those” was indeed referencing the friendlier services.