source: rtos_arduino/trunk/arduino_lib/libraries/Ciao/examples/CiaoRestClient-ThingSpeak/CiaoRestClient-ThingSpeak.ino@ 175

Last change on this file since 175 was 175, checked in by ertl-honda, 8 years ago

ライブラリを Arduino IDE 1.7.9 にupdate

File size: 1.3 KB
Line 
1#include <Wire.h>
2#include <Ciao.h>
3
4/*
5
6This example show the interaction between the Ciao Library and the Thingspeak Cloud.
7To run the example you need to register an account on thingspeak.com and create a
8new channel by clicking "Channels" section in the website (Channels -> My Channels -> New Channel).
9In the new channel you need to add two fields. The first one refers to the humidity data and the second one to the temperature value.
10After that, replace the "XXXXXXXXX" value of APIKEY_THINGSPEAK with "Write API key" value reported in the API Keys section of the channel.
11
12*/
13
14#define CONNECTOR "rest"
15#define SERVER_ADDR "api.thingspeak.com"
16
17#define APIKEY_THINGSPEAK "XXXXXXXXXXXXX"
18
19short hum = 60;
20short temp = 22;
21
22void setup() {
23
24 Ciao.begin(); // CIAO INIT
25}
26
27void loop() {
28
29 String uri = "/update?api_key=";
30 uri += APIKEY_THINGSPEAK;
31 uri += "&field1=";
32 uri += String(hum);
33 uri += "&field2=";
34 uri += String(temp);
35
36 Ciao.println("Send data on ThingSpeak Channel");
37
38 CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);
39
40 if (!data.isEmpty()){
41 Ciao.println( "State: " + String (data.get(1)) );
42 Ciao.println( "Response: " + String (data.get(2)) );
43 }
44 else{
45 Ciao.println("Write Error");
46 }
47
48 delay(30000); // Thinkspeak policy
49
50}
Note: See TracBrowser for help on using the repository browser.