Loading...
Exosite Library for Arduino
Author:  Wing Hui
Contact: garage@exosite.com


Navigation


History

1.0 2012-06-5: initial release


Description

This project is a simple example of using an Andruino board equipped with an Ethernet Shield to send and receive data to/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 1.01 firmware.


Download

Download source code from here: https://github.com/exosite-garage/arduino_exosite_library


Constructor

The constructor.

Exosite::Exosite(EthernetClass *eth, byte* _mac, String _cik);


Method

The constructor.

void Exosite::init(void); Run in the setup() to initialize library.

int Exosite::sendToCloud(String res, int value);

  Send data to Exosite cloud.

int Exosite::readFromCloud(String res ,String* pResult);

  Get data from Exosite Cloud.


Examples

This "cloud_read_write" reads a data from the cloud, adds 100 to it and sends back to the cloud.

#include <SPI.h>
#include <Ethernet.h>
#include <Exosite.h>

byte macData[] = { "PUTYOURMACHERE }; // <-- Fill in your MAC here! (e.g. {0x90, 0xA2, 0xDA, 0x00, 0x22, 0x33}) 

String cikData = "PUTYOURCIKHERE";    // <-- Fill in your CIK here! (https://portals.exosite.com -> Add Device)

Exosite exosite(&Ethernet, macData, cikData);

void setup()
{
  exosite.init();
}

void loop()
{
  String retVal;

  //Read the alias (resource name) "onoff"
  if ( exosite.readFromCloud("onoff", &retVal)) 
  {
    //Send a value + 100 to Exosite, use the alias (resource name) "1"
    exosite.sendToCloud("1", retVal.toInt() + 100);
  }

  delay(3000);
}