Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #include <CayenneMQTTEthernet.h>
- // Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
- char username[] = "";
- char password[] = "";
- char clientID[] = "";
- #define SENSOR_PIN 2 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
- OneWire oneWire(SENSOR_PIN);
- DallasTemperature sensors(&oneWire);
- void setup()
- {
- Serial.begin(9600);
- Cayenne.begin(username, password, clientID);
- sensors.begin();
- }
- void loop()
- {
- Cayenne.loop();
- }
- // This function is called at intervals to send sensor data to Cayenne.
- CAYENNE_OUT_DEFAULT()
- {
- // Send the command to get temperatures.
- sensors.requestTemperatures();
- // This command writes the temperature in Celsius to the Virtual Channel.
- Cayenne.celsiusWrite(0, sensors.getTempCByIndex(0));
- Cayenne.celsiusWrite(1, sensors.getTempCByIndex(1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement