Last change
on this file since 214 was 175, checked in by ertl-honda, 8 years ago |
ライブラリを Arduino IDE 1.7.9 にupdate
|
File size:
1.4 KB
|
Rev | Line | |
---|
[175] | 1 | #include <Wire.h>
|
---|
| 2 | #include <Ciao.h>
|
---|
| 3 |
|
---|
| 4 | /*
|
---|
| 5 |
|
---|
| 6 | This example show the interaction between the Ciao Library and the Thingspeak Cloud.
|
---|
| 7 | To run the example you need to register an account on thingspeak.com.
|
---|
| 8 | After that, you need to create a new channel and a new talkback app.
|
---|
| 9 | To create a new channel click the "Channels" section in the website (Channels -> My Channels -> New Channel).
|
---|
| 10 | To create a new talkback click the "Apps" section in the website (Apps -> TalkBack -> New TalkBack).
|
---|
| 11 | Replace the APIKEY_TALKBACK and ID_TALKBACK values with the values reported in the API section of the site.
|
---|
| 12 |
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | #define CONNECTOR "rest"
|
---|
| 16 | #define SERVER_ADDR "api.thingspeak.com"
|
---|
| 17 |
|
---|
| 18 | #define APIKEY_TALKBACK "XXXXXXXXXXXXX"
|
---|
| 19 | #define ID_TALKBACK "XXXX"
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | void setup() {
|
---|
| 23 |
|
---|
| 24 | Ciao.begin(); // CIAO INIT
|
---|
| 25 |
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | void loop() {
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | String request = "/talkbacks/";
|
---|
| 32 | request += ID_TALKBACK;
|
---|
| 33 | request += "/commands/execute?api_key=";
|
---|
| 34 | request += APIKEY_TALKBACK;
|
---|
| 35 |
|
---|
| 36 | Ciao.println("Read cmd from TalkBack Queue");
|
---|
| 37 | CiaoData data = Ciao.read(CONNECTOR, SERVER_ADDR, request);
|
---|
| 38 |
|
---|
| 39 | String state = data.get(1);
|
---|
| 40 | String response = data.get(2);
|
---|
| 41 |
|
---|
| 42 | if (!data.isEmpty()){
|
---|
| 43 | Ciao.println( "State: " + String (data.get(1)) );
|
---|
| 44 | Ciao.println( "Response: " + String (data.get(2)) );
|
---|
| 45 | }
|
---|
| 46 | else{
|
---|
| 47 | Ciao.println ("Read Error OR EmptyQueue");
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | delay(30000); // Thinkspeak policy
|
---|
| 51 |
|
---|
| 52 | }
|
---|
| 53 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.