Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#define CAYENNE_DEBUG // Uncomment to show debug messages
- #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
- #include <CayenneMQTTEthernet.h>
- #include <Wire.h>
- #include <LiquidCrystal_PCF8574.h>
- #include <OneWire.h>
- #include <DS18B20.h>
- // Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
- char username[] = "removed";
- char password[] = "removed";
- char clientID[] = "removed";
- #define ONEWIRE_PIN 3
- #define SENSORS_NUM 2
- const byte address[SENSORS_NUM][8] PROGMEM = {
- 0x28, 0xFF, 0xA0, 0xD0, 0x47, 0x16, 0x3, 0x95,
- 0x28, 0xFF, 0x73, 0x12, 0x47, 0x16, 0x3, 0xBB
- };
- OneWire onewire(ONEWIRE_PIN);
- DS18B20 sensors(&onewire);
- LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
- int show;
- int error;
- float temperature0;
- float temperature1;
- void setup() {
- Serial.begin(115200);
- Serial.println("LCD...");
- while (! Serial);
- Serial.println("Dose: check for LCD");
- // See http://playground.arduino.cc/Main/I2cScanner
- 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);
- sensors.begin();
- sensors.request();
- Cayenne.begin(username, password, clientID);
- }
- CAYENNE_OUT(V0)
- {
- Cayenne.virtualWrite(V0, temperature0); //virtual pin
- }
- CAYENNE_OUT(V1)
- {
- Cayenne.virtualWrite(V1, temperature1); //virtual pin
- }
- void loop() {
- lcd.setBacklight(255);
- if (sensors.available())
- {
- temperature0 = sensors.readTemperature(FA(address[0]));
- temperature1 = sensors.readTemperature(FA(address[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"));
- delay(5000);
- sensors.request();
- }
- Cayenne.loop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement