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.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 "XXXXXXXXXXXXXX"
|
---|
| 19 | #define ID_TALKBACK "XXXX"
|
---|
| 20 |
|
---|
| 21 | String cmd = "D13_ON";
|
---|
| 22 |
|
---|
| 23 | void setup() {
|
---|
| 24 |
|
---|
| 25 | Ciao.begin(); // CIAO INIT
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | void loop() {
|
---|
| 29 |
|
---|
| 30 | String uri = "/talkbacks/";
|
---|
| 31 | uri += ID_TALKBACK;
|
---|
| 32 | uri += "/commands?api_key=";
|
---|
| 33 | uri += APIKEY_TALKBACK;
|
---|
| 34 | uri += "&command_string=";
|
---|
| 35 | uri += cmd;
|
---|
| 36 |
|
---|
| 37 | Ciao.println("Write cmd on TalkBack Queue");
|
---|
| 38 | CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri,"POST");
|
---|
| 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 | }
|
---|
| 51 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.