daily pastebin goal
35%
SHARE
TWEET

Untitled

arekem Feb 2nd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
  2. #include <OneWire.h>
  3. #include <DallasTemperature.h>
  4. #include <CayenneMQTTEthernet.h>
  5. #include <Wire.h>
  6. #include <LiquidCrystal_PCF8574.h>
  7.  
  8. // Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
  9. char username[] = "";
  10. char password[] = "";
  11. char clientID[] = "";
  12.  
  13. #define SENSOR_PIN 2 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
  14.  
  15. OneWire oneWire(SENSOR_PIN);
  16. DallasTemperature sensors(&oneWire);
  17. LiquidCrystal_PCF8574 lcd(0x27);  // set the LCD address to 0x27 for a 16 chars and 2 line display
  18. int show;
  19.  
  20. void setup()
  21. {
  22.   int error;
  23.  
  24.   Serial.begin(115200);
  25.   Serial.println("LCD...");
  26.  
  27.   while (! Serial);
  28.  
  29.   Serial.println("Dose: check for LCD");
  30.   Wire.begin();
  31.   Wire.beginTransmission(0x27);
  32.   error = Wire.endTransmission();
  33.   Serial.print("Error: ");
  34.   Serial.print(error);
  35.  
  36.   if (error == 0) {
  37.     Serial.println(": LCD found.");
  38.  
  39.   } else {
  40.     Serial.println(": LCD not found.");
  41.   } // if
  42.  
  43.   lcd.begin(16, 2); // initialize the lcd
  44.   show = 0;
  45.  
  46.  // Serial.begin(9600);
  47.   Cayenne.begin(username, password, clientID);
  48.   sensors.begin();
  49. }
  50.  
  51. void loop()
  52. {
  53.   Cayenne.loop();
  54. }
  55.  
  56. // This function is called at intervals to send sensor data to Cayenne.
  57. CAYENNE_OUT_DEFAULT()
  58. {
  59.   // Send the command to get temperatures.
  60.   sensors.requestTemperatures();
  61.   // This command writes the temperature in Celsius to the Virtual Channel.
  62.   Cayenne.celsiusWrite(0, sensors.getTempCByIndex(0));
  63.   Cayenne.celsiusWrite(1, sensors.getTempCByIndex(1));
  64.  
  65.   lcd.setBacklight(255);    
  66.   float temperature0 = sensors.getTempCByIndex(0);
  67.   float temperature1 = sensors.getTempCByIndex(1);
  68.   lcd.home(); lcd.clear();
  69.   lcd.setCursor(0, 0);
  70.   lcd.print(F("Zasilanie "));
  71.   lcd.print(temperature0);
  72.   lcd.print(F("C"));
  73.   lcd.setCursor(0, 1);
  74.   lcd.print(F("Powrot    "));
  75.   lcd.print(temperature1);
  76.   lcd.println(F("C"));
  77. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top