Exosite Library for Arduino Author: Patrick Barrett Contact: support@exosite.com
Description | Download | Methods | Examples
This library enables an Arduino board equipped with a network connection (Ethernet Shield, WiFi Shield, Yun, etc.) to send and receive data to and from the cloud by using Exosite's Cloud Data Platform.
The Exosite Arduino Library is tested on Arduino UNO and Duemillanove with Arduino Ethernet Shield and Arduino WiFi Shield with Arduino v1.0.5.
Download the full source code from https://github.com/exosite-garage/arduino_exosite_library.
int boolean Exosite(String _cik, Client *_client);
Initialize the Exosite object.
The CIKof the device generated by the Exosite Platform.
The Client object of your network interface.
int boolean Exosite::writeRead(char* writeString, char* readString, char** returnString) int boolean Exosite::writeRead(String writeString, String readString, String &returnString)
Read and write data in one step with the Exosite Cloud Platform.
This sets the values to write to certain datasources. eg. "alias3=value3&alias4=value4"
This selects which datasources to read by their alias. eg. "alias1&alias2"
This is the string returned with the values requested in readString. eg. "alias1=value1&alias2=value2"
For More Examples See: https://github.com/exosite-garage/arduino_exosite_library/tree/master/examples
This example writes the millis() timer to the "uptime" data source and reads both "uptime" and "command" and displays the result. See the Quick Start for more information.
//***************************************************************************** // // EthernetReadWriteString - A Simple read/write to the Exosite Cloud API // for the Arduino Ethernet shield using the // String library // // Copyright (c) 2013 Exosite LLC. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of Exosite LLC nor the names of its contributors may // be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // //***************************************************************************** #include <SPI.h> #include <EEPROM.h> #include <Ethernet.h> #include <Exosite.h> /*============================================================================== * Configuration Variables * * Change these variables to your own settings. *=============================================================================*/ String cikData = "0000000000000000000000000000000000000000"; // <-- Fill in your CIK here! (https://portals.exosite.com -> Add Device) byte macData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // <-- Fill in your Ethernet shield's MAC address here. // Use these variables to customize what datasources are read and written to. String readString = "command&uptime"; String writeString = "uptime="; String returnString; /*============================================================================== * End of Configuration Variables *=============================================================================*/ class EthernetClient client; Exosite exosite(cikData, &client); /*============================================================================== * setup * * Arduino setup function. *=============================================================================*/ void setup(){ Serial.begin(115200); Serial.println("Boot"); Ethernet.begin(macData); // wait 10 seconds for connection: delay(1000); } /*============================================================================== * loop * * Arduino loop function. *=============================================================================*/ void loop(){ //Write to "uptime" and read from "uptime" and "command" datasources. if ( exosite.writeRead(writeString+String(millis()), readString, returnString)){ Serial.println("OK"); Serial.println(returnString); }else{ Serial.println("Error"); } delay(5000); }