Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 693b4a2

Browse files
committed
3083 Added example sketches for custom widgets.
1 parent 384b543 commit 693b4a2

File tree

12 files changed

+334
-0
lines changed

12 files changed

+334
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Cayenne 2 State Widget Example
3+
4+
This sketch shows how to set up a 2 State Widget with Cayenne.
5+
6+
Steps:
7+
1. In the Cayenne Dashboard add a new 2 State Custom Widget.
8+
2. Select a digital pin number.
9+
3. Attach a digital input device (e.g. a button) to the digital pin on your Arduino matching the selected pin.
10+
4. Set the token variable to match the Arduino token from the Dashboard.
11+
5. Compile and upload this sketch.
12+
6. Once the Arduino connects to the Dashboard it should automatically update the 2 State widget with data.
13+
14+
Notice that there isn't much coding involved to interact with the digital pins.
15+
Most of it is handled automatically from the Cayenne library.
16+
17+
For further examples of how to send data to Cayenne see the example sketches under Sensors.
18+
*/
19+
20+
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
21+
#include <CayenneEthernet.h>
22+
23+
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
24+
char token[] = "AuthenticationToken";
25+
26+
void setup()
27+
{
28+
Serial.begin(9600);
29+
Cayenne.begin(token);
30+
}
31+
32+
void loop()
33+
{
34+
Cayenne.run();
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Cayenne 2 State Widget Example
2+
3+
This sketch shows how to set up a 2 State Widget with Cayenne.
4+
5+
###### Steps:
6+
1. In the Cayenne Dashboard add a new 2 State Custom Widget.
7+
2. Select a digital pin number.
8+
3. Attach a digital input device (e.g. a button) to the digital pin on your Arduino matching the selected pin.
9+
4. Set the token variable to match the Arduino token from the Dashboard.
10+
5. Compile and upload this sketch.
11+
6. Once the Arduino connects to the Dashboard it should automatically update the 2 State widget with data.
12+
13+
Notice that there isn't much coding involved to interact with the digital pins.
14+
Most of it is handled automatically from the Cayenne library.
15+
16+
For further examples of how to send data to Cayenne see the example sketches under Sensors.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Cayenne Button Widget Example
3+
4+
This sketch shows how to set up a Button Widget with Cayenne.
5+
6+
Steps:
7+
1. In the Cayenne Dashboard add a new Button Custom Widget.
8+
2. Select a digital pin number.
9+
3. Attach a digital output device (e.g. a LED) to the digital pin on your Arduino matching the selected pin.
10+
4. Set the token variable to match the Arduino token from the Dashboard.
11+
5. Compile and upload this sketch.
12+
6. Once the Arduino connects to the Dashboard you should be able to control the digital output device with the Button widget.
13+
14+
Notice that there isn't much coding involved to interact with the digital pins.
15+
Most of it is handled automatically from the Cayenne library.
16+
17+
For further examples of how to receive data from Cayenne see the example sketches under Actuators.
18+
*/
19+
20+
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
21+
#include <CayenneEthernet.h>
22+
23+
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
24+
char token[] = "AuthenticationToken";
25+
26+
void setup()
27+
{
28+
Serial.begin(9600);
29+
Cayenne.begin(token);
30+
}
31+
32+
void loop()
33+
{
34+
Cayenne.run();
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Cayenne Button Widget Example
2+
3+
This sketch shows how to set up a Button Widget with Cayenne.
4+
5+
###### Steps:
6+
1. In the Cayenne Dashboard add a new Button Custom Widget.
7+
2. Select a digital pin number.
8+
3. Attach a digital output device (e.g. a LED) to the digital pin on your Arduino matching the selected pin.
9+
4. Set the token variable to match the Arduino token from the Dashboard.
10+
5. Compile and upload this sketch.
11+
6. Once the Arduino connects to the Dashboard you should be able to control the digital output device with the Button widget.
12+
13+
Notice that there isn't much coding involved to interact with the digital pins.
14+
Most of it is handled automatically from the Cayenne library.
15+
16+
For further examples of how to receive data from Cayenne see the example sketches under Actuators.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Cayenne Gauge Widget Example
3+
4+
This sketch shows how to set up a Gauge Widget with Cayenne.
5+
6+
Steps:
7+
1. In the Cayenne Dashboard add a new Gauge Custom Widget.
8+
3. Select Virtual I/O and a virtual pin number.
9+
4. Set VIRTUAL_PIN to the pin number you selected.
10+
5. Select a data type and unit, e.g. Temperature, Celsius.
11+
6. Attach an analog input device (e.g. a temperature sensor) to your Arduino.
12+
7. Set the token variable to match the Arduino token from the Dashboard.
13+
8. Modify the CAYENNE_OUT(VIRTUAL_PIN) function to send data from your sensor.
14+
8. Compile and upload this sketch.
15+
9. Once the Arduino connects to the Dashboard it should automatically update the Gauge widget with data.
16+
17+
For further examples of how to send data to Cayenne see the example sketches under Sensors.
18+
*/
19+
20+
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
21+
#include <CayenneEthernet.h>
22+
23+
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
24+
char token[] = "AuthenticationToken";
25+
26+
void setup()
27+
{
28+
Serial.begin(9600);
29+
Cayenne.begin(token);
30+
}
31+
32+
void loop()
33+
{
34+
Cayenne.run();
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Cayenne Gauge Widget Example
2+
3+
This sketch shows how to set up a Gauge Widget with Cayenne.
4+
5+
###### Steps:
6+
1. In the Cayenne Dashboard add a new Gauge Custom Widget.
7+
3. Select Virtual I/O and a virtual pin number.
8+
4. Set VIRTUAL_PIN to the pin number you selected.
9+
5. Select a data type and unit, e.g. Temperature, Celsius.
10+
6. Attach an analog input device (e.g. a temperature sensor) to your Arduino.
11+
7. Set the token variable to match the Arduino token from the Dashboard.
12+
8. Modify the CAYENNE_OUT(VIRTUAL_PIN) function to send data from your sensor.
13+
8. Compile and upload this sketch.
14+
9. Once the Arduino connects to the Dashboard it should automatically update the Gauge widget with data.
15+
16+
For further examples of how to send data to Cayenne see the example sketches under Sensors.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Cayenne Line Chart Widget Example
3+
4+
This sketch shows how to set up a Line Chart Widget with Cayenne.
5+
6+
Steps:
7+
1. In the Cayenne Dashboard add a new Line Chart Custom Widget.
8+
3. Select Virtual I/O and a virtual pin number.
9+
4. Set VIRTUAL_PIN to the pin number you selected.
10+
5. Select a data type and unit, e.g. Temperature, Celsius.
11+
6. Attach an analog input device (e.g. a temperature sensor) to your Arduino.
12+
7. Set the token variable to match the Arduino token from the Dashboard.
13+
8. Modify the CAYENNE_OUT(VIRTUAL_PIN) function to send data from your sensor.
14+
8. Compile and upload this sketch.
15+
9. Once the Arduino connects to the Dashboard it should automatically update the Line Chart widget with data.
16+
17+
For further examples of how to send data to Cayenne see the example sketches under Sensors.
18+
*/
19+
20+
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
21+
#include <CayenneTemperature.h>
22+
#include <CayenneEthernet.h> // Change this to use a different communication device. See Communications examples.
23+
24+
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
25+
char token[] = "AuthenticationToken";
26+
27+
// Virtual Pin of the Thermistor widget.
28+
#define VIRTUAL_PIN V1
29+
30+
void setup()
31+
{
32+
Serial.begin(9600);
33+
Cayenne.begin(token);
34+
}
35+
36+
void loop()
37+
{
38+
Cayenne.run();
39+
}
40+
41+
// This function is called when the Cayenne widget requests data for the Virtual Pin.
42+
CAYENNE_OUT(VIRTUAL_PIN)
43+
{
44+
// Read data from the sensor and send it to the virtual channel here.
45+
// For example, this command writes a temperature in Celsius to the Virtual Pin.
46+
Cayenne.celsiusWrite(VIRTUAL_PIN, 25.5);
47+
// You can also write data using virtualWrite:
48+
//Cayenne.virtualWrite(VIRTUAL_PIN, 25.5, CELSIUS, TEMPERATURE);
49+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Cayenne Line Chart Widget Example
2+
3+
This sketch shows how to set up a Line Chart Widget with Cayenne.
4+
5+
###### Steps:
6+
1. In the Cayenne Dashboard add a new Line Chart Custom Widget.
7+
3. Select Virtual I/O and a virtual pin number.
8+
4. Set VIRTUAL_PIN to the pin number you selected.
9+
5. Select a data type and unit, e.g. Temperature, Celsius.
10+
6. Attach an analog input device (e.g. a temperature sensor) to your Arduino.
11+
7. Set the token variable to match the Arduino token from the Dashboard.
12+
8. Modify the CAYENNE_OUT(VIRTUAL_PIN) function to send data from your sensor.
13+
8. Compile and upload this sketch.
14+
9. Once the Arduino connects to the Dashboard it should automatically update the Line Chart widget with data.
15+
16+
For further examples of how to send data to Cayenne see the example sketches under Sensors.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Cayenne Slider Widget Example
2+
3+
This sketch shows how to set up a Slider Widget with Cayenne.
4+
5+
###### Steps:
6+
1. In the Cayenne Dashboard add a new Slider Custom Widget.
7+
2. Select a digital PWM pin number (3, 5, 6, 9, 10, and 11 on most Arduino boards).
8+
3. Attach an ouput device to the PWM pin on your Arduino matching the selected pin.
9+
4. Set the token variable to match the Arduino token from the Dashboard.
10+
5. Compile and upload this sketch.
11+
6. Once the Arduino connects to the Dashboard you should be able to control the analog output device with the Slider widget.
12+
13+
Notice that there isn't much coding involved to interact with the PWM pins.
14+
Most of it is handled automatically from the Cayenne library.
15+
16+
For further examples of how to receive data from Cayenne see the example sketches under Actuators.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Cayenne Slider Widget Example
3+
4+
This sketch shows how to set up a Slider Widget with Cayenne.
5+
6+
Steps:
7+
1. In the Cayenne Dashboard add a new Slider Custom Widget.
8+
2. Select a digital PWM pin number (3, 5, 6, 9, 10, and 11 on most Arduino boards).
9+
3. Attach an ouput device to the PWM pin on your Arduino matching the selected pin.
10+
4. Set the token variable to match the Arduino token from the Dashboard.
11+
5. Compile and upload this sketch.
12+
6. Once the Arduino connects to the Dashboard you should be able to control the analog output device with the Slider widget.
13+
14+
Notice that there isn't much coding involved to interact with the PWM pins.
15+
Most of it is handled automatically from the Cayenne library.
16+
17+
For further examples of how to receive data from Cayenne see the example sketches under Actuators.
18+
*/
19+
20+
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
21+
#include <CayenneEthernet.h>
22+
23+
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
24+
char token[] = "AuthenticationToken";
25+
26+
void setup()
27+
{
28+
Serial.begin(9600);
29+
Cayenne.begin(token);
30+
}
31+
32+
void loop()
33+
{
34+
Cayenne.run();
35+
}

0 commit comments

Comments
 (0)