Unfortunately, nothing helped. Otherwise, I have already used it connected like this before in a combination of Arduiono IDE and Cayenne and everything worked. (see code below)
#include <NTPClient.h>
#include <CayenneMQTTESP8266.h>
#include <WiFiUdp.h>
#include <TimeLib.h>
#include <time.h>
#include <Timezone.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <TM1650.h>
TM1650 d;
// FLASH 0
// TX 1
// RX 3
// SDA 4
// SCL 5
#define Fotobunka A0 // Signalizace zapnuti sauny
#define Dvere 12 // Dvere
#define Teplota 13 // DS18B20
#define Rele 14 // Rele
int ldr = A0; // analogovy pin kde je pripojen fotorezistor
int ldr_value = 0; // promenna pro zaznam hodnot z fotorezistoru
OneWire oneWire(Teplota);
DallasTemperature sensors(&oneWire);
char username[] = "6c40f970-f7a9-11e6-9728-67156ca35db4";
char password[] = "6ef9aaf21f1b0782b8e6a854ebe6f88f3aa0370d";
char clientID[] = "87ee2980-bc3e-11ed-b0e7-e768b61d6137";
const char* ssid = "IoT";
const char* wifipassword = "Pr1pojen1prosmartdevice";
//const char* ssid = "Host_2.4GHz";
//const char* wifipassword = "Pripojeniprohosty";
static tm getDateTimeByParams(long time){
struct tm *newtime;
const time_t tim = time;
newtime = localtime(&tim);
return *newtime;
}
static String getDateTimeStringByParams(tm *newtime, char* pattern = (char *)"%d/%m/%Y %H:%M:%S"){
char buffer[30];
strftime(buffer, 30, pattern, newtime);
return buffer;
}
static String getEpochStringByParams(long time, char* pattern = (char *)"%d/%m/%Y %H:%M:%S"){
tm newtime;
newtime = getDateTimeByParams(time);
return getDateTimeStringByParams(&newtime, pattern);
}
WiFiUDP ntpUDP;
int GTMOffset = 2; // nastaveni posunu casu
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", GTMOffset*60*60, 60*60*1000);
// Central European Time (Frankfurt, Paris)
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 0}; // Central European Summer Time
TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, -60}; // Central European Standard Time
Timezone CE(CEST, CET);
void setup(){
Serial.begin(9600);
Wire.begin();
d.init();
Cayenne.begin(username, password, clientID, ssid, wifipassword);
timeClient.begin();
//delay (1000);
if (timeClient.update()){
Serial.print ( "Nastaveny mistni cas" );
unsigned long epoch = timeClient.getEpochTime();
setTime(epoch);
}else{
Serial.print ( "NTP Update nefunguje!!!" );
}
pinMode(Fotobunka, INPUT);
pinMode(Dvere, INPUT);
pinMode(Rele, OUTPUT);
digitalWrite(Rele, LOW);
sensors.begin();
}
void loop(){
Serial.println(getEpochStringByParams(CE.toLocal(now())));
char waktu[5];
timeClient.update();
sprintf(waktu, "%02d%02d", timeClient.getHours(), timeClient.getMinutes());
d.displayOn();
d.setBrightness(1);
d.displayString(waktu);
for (int i = 1; i<2; i++) {
d.setDot(i,true);
}
Cayenne.loop(); //spusteni Cayenne
}
///////////////
//--Teplota--//
///////////////
CAYENNE_OUT(1){
// Send the command to get temperatures.
sensors.requestTemperatures();
Serial.print("Teplota: ");
Serial.print(sensors.getTempCByIndex(0));
Serial.println("*C");
// This command writes the temperature in Celsius to the Virtual Channel.
Cayenne.celsiusWrite(1, sensors.getTempCByIndex(0));
}
/////////////
//--Dvere--//
/////////////
CAYENNE_OUT(2){
if (digitalRead(Dvere) == LOW) {
Cayenne.virtualWrite(2, 1, "digital_sensor", "d");
Serial.println("Dvere: otevreno...");
}
else {
Cayenne.virtualWrite(2, 0, "digital_sensor", "d");
Serial.println("Dvere: zavreno...");
}
}
////////////
//--Rele--//
////////////
CAYENNE_IN(3){
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 1 && digitalRead(Dvere) == HIGH) { //pokud je Cayenne zapnute a dvere zavrene sepni rele
digitalWrite(Rele, HIGH);
Cayenne.virtualWrite(3, 1, "digital_sensor", "d");
}
else {
digitalWrite(Rele, LOW);
Cayenne.virtualWrite(3, 0, "digital_sensor", "d");
}
}
/////////////
//--Wi-Fi--//
/////////////
CAYENNE_OUT_DEFAULT(){
Cayenne.virtualWrite(4, WiFi.RSSI()); //zobrazeni signalu WiFi
}
/////////////////
//--Fotobunka--//
/////////////////
CAYENNE_OUT(5){
ldr_value = analogRead(ldr); // čte hodnoty LDR
Serial.print("HODNOTA FOTOBUNKY = ");
Serial.println(ldr_value); // zobrazí hodnoty LDR na seriove lince
Cayenne.virtualWrite(6, ldr_value, "analog_sensor", "null");
if(analogRead(Fotobunka) >= 25){ // pokud fotobunka vidi světlo
Cayenne.virtualWrite(5, 1, "digital_sensor", "d");
}
else {
Cayenne.virtualWrite(5, 0, "digital_sensor", "d");
}
}
It’s just if I add Dallas to my code, it always blocks the whole device, then nothing works at all. Any other ideas?
Thanks