Official Arduino client for SlicingDice - Data Warehouse and Analytics Database as a Service.
SlicingDice is a serverless, SQL & API-based, easy-to-use and really cost-effective alternative to Amazon Redshift and Google BigQuery.
If you are new to SlicingDice, check our quickstart guide and learn to use it in 15 minutes.
Please refer to the SlicingDice official documentation for more information on how to create a database, how to insert data, how to make queries, how to create columns, SlicingDice restrictions and API details.
SlicingDice's Arduino client currently supports only data insert commands. Let us know if you application requires Arduino to query data from SlicingDice and we'll make sure to add this feature to our backlog.
Click here to download our Arduino client as a zip
file. After downloading it, you only need to import the zipped contents into your project path.
#include <SlicingDice.h>
#include <ArduinoJson.h>
// If you need a demo API key visit: https://docs.slicingdice.com/docs/try-before-you-buy
String apiKey = String("YOUR_API_KEY");
// if false will use test end-point, otherwise production end-point
boolean useProduction = false;
SlicingDice sd = SlicingDice(apiKey, useProduction);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
}
// Arduino network settings, should match your internet connection properties
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 10 };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };
byte dns[] = { 8, 8, 8, 8 };
Ethernet.begin(mac, ip, dns, gateway, subnet);
}
// Send an insert command to Slicing Dice API and print the result
void loop() {
StaticJsonBuffer<200> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
JsonObject& nestedInsertion = data.createNestedObject("user1@slicingdice.com");
nestedInsertion["age"] = 22;
// Auto create non-existent fields
JsonArray& autoCreate = data.createNestedArray("auto-create");
autoCreate.add("table");
autoCreate.add("column");
// Insert object
sd.insert(data);
// Print result for debugging
Serial.print("Status code: ");
Serial.println(sd.statusCode);
Serial.println(sd.response);
}
Whether you want to test the client installation or simply check more examples on how the client works, take a look at tests directory.
SlicingDice
encapsulates logic for sending requests to the insert endpoint.
statusCode (int)
- HTTP status code after inserting to SlicingDice. Should be200
in ordinary circumstances or one of the HTTP requests defined at the API errors section.response (String)
- Response after inserting data. Useful for debugging purposes.
SlicingDice(const char* apiKey, boolean production, const char* host, int port)
apiKey (const char*)
- API key to authenticate requests with the SlicingDice API.production(boolean)
- (Default: true) If true the client will send requests to production end-point, otherwise to tests end-point.host (const char*)
- (Default: api.slicingdice.com) Connection endpoint to use when generating requests to SlicingDice.port (int)
- (Default: 80) Port to connect to when generating requests. Particularly useful when connect tohttp://localhost
.
Insert data to existing entities or create new entities, if necessary. This method corresponds to a POST request at /insert.
#include <SlicingDice.h>
#include <ArduinoJson.h>
// If you need a demo API key visit: https://docs.slicingdice.com/docs/try-before-you-buy
String apiKey = String("YOUR_API_KEY");
// if false will use test endpoint, otherwise production endpoint
boolean useProduction = false;
SlicingDice sd = SlicingDice(apiKey, useProduction);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
}
// Arduino network settings, should match your internet connection properties
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 10 };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };
byte dns[] = { 8, 8, 8, 8 };
Ethernet.begin(mac, ip, dns, gateway, subnet);
}
// Send an insertion request to Slicing Dice API and print the result
void loop() {
StaticJsonBuffer<200> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
JsonObject& nestedInsertion = data.createNestedObject("user1@slicingdice.com");
nestedInsertion["age"] = 22;
// Auto create non-existent fields
JsonArray& autoCreate = data.createNestedArray("auto-create");
autoCreate.add("table");
autoCreate.add("column");
// Insert object
sd.insert(data);
// Print result for debugging
Serial.print("Status code: ");
Serial.println(sd.statusCode);
Serial.println(sd.response);
}
Status code: 200
{
"status": "success",
"inserted-entities": 1,
"inserted-fields": 1,
"took": 0.023
}