Dear adam,
It has not been offered new credentials to me, but it could be a problem on my browserâs side. Currently I am happy with Cayenne, I could been add a new device and it works well.
The only function I could not realize properly the âpush buttonâ. Here I quote the whole code I have made and I hope you may suggest some solution or workaround (or just suggests to open a new topic
) /Sorry for the weirdly formatted text!/
Zoltan
//Home IoT solution with Wemos D1 Mini ver 2.2
//#define CAYENNE_DEBUG
//#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <Adafruit_BME280.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <PCF8574.h>
//Port extender addresses
PCF8574 PCF_01(0x20); //For the outputs/relays
PCF8574 PCF_02(0x27); //For the inputs (0/1)
// My DS18B20's addresses
// 0x28, 0xA0, 0x63, 0x23, 0x07, 0x00, 0x00, 0x9F //1. temperature sensor
// 0x28, 0xFF, 0xD1, 0x5C, 0x52, 0x15, 0x01, 0x68
// 0x28, 0xDA, 0xED, 0x23, 0x07, 0x00, 0x00, 0xA1 //2. temperature sensor
// 0x28, 0x8B, 0xC6, 0x23, 0x07, 0x00, 0x00, 0x30
// 0x28, 0xFF, 0x92, 0xF5, 0x44, 0x16, 0x03, 0x87
// 0x28, 0x90, 0x97, 0x23, 0x07, 0x00, 0x00, 0xCB
// 0x28, 0xCD, 0x8D, 0x23, 0x07, 0x00, 0x00, 0x6E
// 0x28, 0xFF, 0x84, 0x28, 0x65, 0x15, 0x01, 0x2D
DeviceAddress gtemp1 = { 0x28, 0xA0, 0x63, 0x23, 0x07, 0x00, 0x00, 0x9F }; //1.
DeviceAddress gtemp2 = { 0x28, 0xDA, 0xED, 0x23, 0x07, 0x00, 0x00, 0xA1 }; //2.
OneWire oneWire(D5); //Ezeken a låbakon megy: 8, 9 - NEM MEGY 12-en, LEFAGY a 10,11 és 13 esetén
DallasTemperature sensors(&oneWire);
// WiFi and MQTT credentials
char ssid[] = "";
char wifiPassword[] = "";
char username[] = "";
char password[] = "";
char clientID[] = "";
unsigned long lastMillis = 0;
unsigned long lastMillis2 = 0;
unsigned long lastMillis3 = 0;
int S0 = 0;
int S0e = 0;
int S1 = 0;
int S1e = 0;
int S2 = 0;
int S2e = 0;
int S3 = 0;
int S3e = 0;
int S4 = 0;
int S4e = 0;
int S5 = 0;
int S5e = 0;
int S6 = 0;
int S6e = 0;
int S7 = 0;
int S7e = 0;
//BMP280 setup, create instance
Adafruit_BME280 bme;
void setup() {
// pinMode(D4, OUTPUT);
pinMode(D5, INPUT_PULLUP); //One Wire bus pullup to avoid using any external resistor.
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
bme.begin();
sensors.begin();
//Set the DS18B20 resolution to 12 bit
sensors.setResolution(gtemp1, 12);
sensors.setResolution(gtemp2, 12);
//I2C portextender start
PCF_01.begin(); // 8pcs output
PCF_02.begin(); // 8pcs input
//Reset/clean up Cayenne dashboard after power failure or reset.
Cayenne.loop();
Cayenne.celsiusWrite(0, bme.readTemperature());
Cayenne.virtualWrite(1, bme.readHumidity(), TYPE_RELATIVE_HUMIDITY, UNIT_PERCENT); //There is no predefined Write command.
Cayenne.hectoPascalWrite(2, bme.readPressure()/100);
sensors.requestTemperatures();
Cayenne.celsiusWrite(3, sensors.getTempC(gtemp1));
Cayenne.celsiusWrite(4, sensors.getTempC(gtemp2));
Cayenne.digitalSensorWrite(9, PCF_02.readButton(0));
Cayenne.digitalSensorWrite(10, PCF_02.readButton(1));
Cayenne.digitalSensorWrite(11, PCF_02.readButton(2));
Cayenne.digitalSensorWrite(12, PCF_02.readButton(3));
Cayenne.digitalSensorWrite(13, PCF_02.readButton(4));
Cayenne.digitalSensorWrite(14, PCF_02.readButton(5));
Cayenne.digitalSensorWrite(15, PCF_02.readButton(6));
Cayenne.digitalSensorWrite(16, PCF_02.readButton(7));
Cayenne.virtualWrite(20,0);
Cayenne.virtualWrite(21,0);
Cayenne.virtualWrite(22,0);
Cayenne.virtualWrite(23,0);
Cayenne.virtualWrite(24,0);
Cayenne.virtualWrite(25,0);
Cayenne.virtualWrite(26,0);
Cayenne.virtualWrite(27,0);
}
void loop() {
Cayenne.loop();
// 8pcs input - PCF8574
// No status change, no message - try to avoid any unnecessary status update.
S0 = PCF_02.readButton(0);
if (S0 != S0e) {
Cayenne.digitalSensorWrite(9, S0);
S0e = S0;
}
S1 = PCF_02.readButton(1);
if (S1 != S1e) {
Cayenne.digitalSensorWrite(10, S1);
S1e = S1;
}
S2 = PCF_02.readButton(2);
if (S2 != S2e) {
Cayenne.digitalSensorWrite(11, S2);
S2e = S2;
}
S3 = PCF_02.readButton(3);
if (S3 != S3e) {
Cayenne.digitalSensorWrite(12, S3);
S3e = S3;
}
S4 = PCF_02.readButton(4);
if (S4 != S4e) {
Cayenne.digitalSensorWrite(13, S4);
S4e = S4;
}
S5 = PCF_02.readButton(5);
if (S5 != S5e) {
Cayenne.digitalSensorWrite(14, S5);
S5e = S5;
}
S6 = PCF_02.readButton(6);
if (S6 != S6e) {
Cayenne.digitalSensorWrite(15, S6);
S6e = S6;
}
S7 = PCF_02.readButton(7);
if (S7 != S7e) {
Cayenne.digitalSensorWrite(16, S7);
S7e = S7;
}
**//Reset the status of the three (3) "push buttons" on channel 22, 23 & 24.**
**//Unfortunately it should be updated frequently, since I cannot "reset" them from "CAYENNE_IN" directly**.
if(millis() - lastMillis3 > 3000) {
lastMillis3 = millis();
Cayenne.virtualWrite(22,0);
Cayenne.virtualWrite(23,0);
Cayenne.virtualWrite(24,0);
}
//Data need just slow update.
if(millis() - lastMillis2 > 120000) {
lastMillis2 = millis();
//BMP/BME280 szenzor
Cayenne.celsiusWrite(0, bme.readTemperature());
Cayenne.virtualWrite(1, bme.readHumidity(), TYPE_RELATIVE_HUMIDITY, UNIT_PERCENT); ////There is no predefined Write command.
Cayenne.hectoPascalWrite(2, bme.readPressure()/100);
//DS18B20 szenzorok
sensors.requestTemperatures(); // Send the command to get temperatures.
Cayenne.celsiusWrite(3, sensors.getTempC(gtemp1));
Cayenne.celsiusWrite(4, sensors.getTempC(gtemp2));
}
}
//Relay controls (8ch).
CAYENNE_IN(20) //GM
{
PCF_01.write(0, !getValue.asInt());
}
CAYENNE_IN(21) //KM
{
PCF_01.write(1, !getValue.asInt());
}
CAYENNE_IN(22) //GA - Should be a "push button", holding time 777ms, reset in the loop
{
PCF_01.write(2, !getValue.asInt());
delay(777);
PCF_01.write(2, HIGH);
}
CAYENNE_IN(23) //GK - Should be a "push button", holding time 777ms, reset in the loop
{
PCF_01.write(3, !getValue.asInt());
delay(777);
PCF_01.write(3, HIGH);
}
CAYENNE_IN(24) //BK - Should be a "push button", holding time 777ms, reset in the loop
{
PCF_01.write(4, !getValue.asInt());
delay(777);
PCF_01.write(4, HIGH);
}
CAYENNE_IN(25) //Relé 6.
{
PCF_01.write(5, !getValue.asInt());
}
CAYENNE_IN(26) //Relé 7.
{
PCF_01.write(6, !getValue.asInt());
}
CAYENNE_IN(27) //Relé 8.
{
PCF_01.write(7, !getValue.asInt());
}
//It might be useful for later.
/*
CAYENNE_IN(6)
{
pinMode(2, OUTPUT);
if (getValue.asInt() == 1) //check the 0/1 value coming from the Cayenne widget
{
digitalWrite(2, HIGH);
}
else
{
digitalWrite(2, LOW);
}
}
*/
// tslfunc(VIRTUAL_PIN);
// ds18b20func(VIRTUAL_PINT);
//Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);