Skip to content

Instantly share code, notes, and snippets.

@m25lazi
Last active March 24, 2016 17:55
Show Gist options
  • Save m25lazi/f83688b21ee3e2c34c5c to your computer and use it in GitHub Desktop.
Save m25lazi/f83688b21ee3e2c34c5c to your computer and use it in GitHub Desktop.
Bloq Example 1 (Control Digital/Analog Arduino pins via Bloq Server)
/*
Should include these additional libraries:
* Ethernet
* SPI
* ArduinoJson by bblanchon (https://github.com/bblanchon/ArduinoJson)
Bloq Library includes Arduino-RestClient Library by csquared (https://github.com/csquared/arduino-restclient)
Device Type - 0 : Appliance, 1 : Sensor
Data Type - 0 : Digital, 1 : Analog
*/
#include <SPI.h>
#include <Ethernet.h>
#include <ArduinoJson.h>
#include <Bloq.h>
#define BloqDeviceID "-KAotASJuLJ6ZXaFeuYc"
#define BloqUserID "-K9r9OuJ4LRc49lE-q7Y"
#define BloqDeviceType 0
#define BloqDataType 0
#define BloqSensorPin 3
Bloq theBloq = Bloq(BloqDeviceID, BloqDeviceType, BloqDataType);
void setup() {
pinMode(BloqSensorPin, OUTPUT);
Serial.begin(9600);
int bloqStatus = theBloq.init(BloqUserID, BloqSensorPin);
while(bloqStatus){} //If bloq init is a failure, no need to proceed
}
void loop() {
theBloq.monitor();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment