This Arduino sketch will read the current value of a point This sample requires an Arduino ethernet shield that is connected to your LAN with internet access. The ACTION parameter is what tells nimbits what to do with the point, other options are action=delete, and action=update to delete or apply changes to a point. Using update assumes you are also providing a point in json format using the json={} parameter.
You'll also need to provide an access key with privileges to read from a point Read about creating access keys on your account here
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x11, 0x15};
char serverName[] = "google.com";
EthernetClient client;
void setup() {
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while(true);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(serverName, 80)) {
Serial.println("connected");
client.println("GET /service/currentvalue?point=TempF&email=test@exmple.com&key=areadablekey HTTP/1.1");
client.println("Host:nimbits1.appspot.com");
client.println();
}
else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println("disconnecting.");
client.stop();
while(true);
}
}
This is an example of doing a GET to the point service to confirm a point exists.