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>
- #include <Wire.h>
- #include <LiquidCrystal_PCF8574.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);
- LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
- int show;
- void setup()
- {
- int error;
- Serial.begin(115200);
- Serial.println("LCD...");
- while (! Serial);
- Serial.println("Dose: check for LCD");
- Wire.begin();
- Wire.beginTransmission(0x27);
- error = Wire.endTransmission();
- Serial.print("Error: ");
- Serial.print(error);
- if (error == 0) {
- Serial.println(": LCD found.");
- } else {
- Serial.println(": LCD not found.");
- } // if
- lcd.begin(16, 2); // initialize the lcd
- show = 0;
- // 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));
- lcd.setBacklight(255);
- float temperature0 = sensors.getTempCByIndex(0);
- float temperature1 = sensors.getTempCByIndex(1);
- lcd.home(); lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print(F("Zasilanie "));
- lcd.print(temperature0);
- lcd.print(F("C"));
- lcd.setCursor(0, 1);
- lcd.print(F("Powrot "));
- lcd.print(temperature1);
- lcd.println(F("C"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement