Hi,
I was try to mae the MQTT, because the dashboard said: Upgrade to Arduino Legacy agent 2.0 required
So i was but, i have a porblem. When i want to complie, thats the masages:
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Alaplap:“WeMos D1 R2 & mini, 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200”
Felépítés beállítások megváltoztak, egész újraépítése
In file included from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:21:0,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP8266.h:23,
from C:\Users\Ĺ?ryGábor\Documents\Arduino\mqtt_szell2\mqtt_szell2.ino:6:
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneArduinoMQTTClient.h: In instantiation of ‘static void CayenneArduinoMQTTClient::publishData(CayenneTopic, unsigned int, const T&, const char*, const char*) [with T = void(int); CayenneTopic = CayenneTopic]’:
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneArduinoMQTTClient.h:144:52: required from ‘void CayenneArduinoMQTTClient::virtualWrite(unsigned int, const T&, const char*, const char*) [with T = void(int)]’
C:\Users\Ĺ?ryGábor\Documents\Arduino\mqtt_szell2\mqtt_szell2.ino:205:42: required from here
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneArduinoMQTTClient.h:345:3: error: call of overloaded ‘add(const char*&, void (&)(int))’ is ambiguous
values.add(subkey, data);
^
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneArduinoMQTTClient.h:345:3: note: candidates are:
In file included from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/CayenneMQTTClient.h:24:0,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMessage.h:32,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneHandlers.h:29,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneArduinoDefines.h:131,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneArduinoMQTTClient.h:21,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:21,
from C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP8266.h:23,
from C:\Users\Ĺ?ryGábor\Documents\Arduino\mqtt_szell2\mqtt_szell2.ino:6:
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:106:15: note: void CayenneMQTT::DataArray<BUFFER_SIZE, MAX_VALUES>::add(const char*, int) [with int BUFFER_SIZE = 64; int MAX_VALUES = 4]
inline void add(const char* unit, const int value) {
^
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:106:15: note: no known conversion for argument 2 from ‘void(int)’ to ‘int’
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:121:15: note: void CayenneMQTT::DataArray<BUFFER_SIZE, MAX_VALUES>::add(const char*, unsigned int) [with int BUFFER_SIZE = 64; int MAX_VALUES = 4]
inline void add(const char* unit, const unsigned int value) {
^
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:121:15: note: no known conversion for argument 2 from ‘void(int)’ to ‘unsigned int’
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:136:15: note: void CayenneMQTT::DataArray<BUFFER_SIZE, MAX_VALUES>::add(const char*, long int) [with int BUFFER_SIZE = 64; int MAX_VALUES = 4]
inline void add(const char* unit, const long value) {
^
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:136:15: note: no known conversion for argument 2 from ‘void(int)’ to ‘long int’
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:151:15: note: void CayenneMQTT::DataArray<BUFFER_SIZE, MAX_VALUES>::add(const char*, long unsigned int) [with int BUFFER_SIZE = 64; int MAX_VALUES = 4]
inline void add(const char* unit, const unsigned long value) {
^
C:\Users\ŐryGábor\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:151:15: note: no known conversion for argument 2 from ‘void(int)’ to ‘long unsigned int’
exit status 1
Hiba a(z) WeMos D1 R2 & mini alaplapra fordításra.
Here is my code:
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
//#include “CayenneWiFiClient.h”
//#include “CayenneMQTTClient/CayenneMQTTClient.h”
//#include “CayenneMQTTWiFi.h”
//#include “CayenneDefines.h”
#include “DHT.h”
//#include “SimpleTimer.h”
//#include “Wire.h”
#include “SoftwareSerial.h”
//#include <MQTTPacket.h>
// WiFi network info.
char ssid = “DIGI-01093812”;
char wifiPassword = “25ff3h53”;
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “5b9ad610-fb57-11e7-8e1f-631f7dc7614e”;
char password = “c32522cbbd03367d6365d2a25d3934f14543ee4c”;
char clientID = “09c79860-121c-11e8-9beb-4d400e603e7e”;
#define DHT1PIN D5
#define DHT1TYPE DHT22 // DHT 22 elszívott
#define DHT2PIN D1
#define DHT2TYPE DHT22 // DHT 22 befújt
#define DHT3PIN D2
#define DHT3TYPE DHT22 // DHT 22 friss
#define DHT4PIN D3
#define DHT4TYPE DHT22 // DHT 22 kifújt
// Virtual Pin of the widget.
const int VIRTUAL_PIN1 = 1; //temp elszívott
const int VIRTUAL_PIN2 = 2; //hum elszívott
const int VIRTUAL_PIN3 = 3; //temp befújt
const int VIRTUAL_PIN4 = 4; //hum befújt
const int VIRTUAL_PIN5 = 5; //temp friss
const int VIRTUAL_PIN6 = 6; //hum friss
const int VIRTUAL_PIN7 = 7; //temp kifújt
const int VIRTUAL_PIN8 = 8; //hum kifújt
const int VIRTUAL_PIN9 = 9; //co2 elszívott
#define pwmPin D4 //co2pwm narancs
#define PWM_DIGITAL_PIN1 D6 //elszívó vent
#define PWM_DIGITAL_PIN2 D7 //befújó vent
const int PWM_VIRTUAL_PIN10 = 10; //elszívó vent speed
const int PWM_VIRTUAL_PIN11 = 11; //befújó vent speed
const int PWM_VIRTUAL_PIN12 = 12; //hatásfok % 1
const int PWM_VIRTUAL_PIN13 = 13; //hatásfok % 2
SoftwareSerial mySerial(D7, D8); // RX, TX co2 zöld fehér
byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
unsigned char response[9];
unsigned long th, tl, ppm, ppm2, ppm3, eff, eff2 = 0;
DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);
DHT dht3(DHT3PIN, DHT3TYPE);
DHT dht4(DHT4PIN, DHT4TYPE);
unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
// initialize digital pin 2 as an output.
pinMode(2, OUTPUT);
dht1.begin();
dht2.begin();
dht3.begin();
dht4.begin();mySerial.begin(9600);
pinMode(pwmPin, INPUT);
pinMode(PWM_DIGITAL_PIN1, OUTPUT);
pinMode(PWM_DIGITAL_PIN2, OUTPUT);
//pinMode(PWM_VIRTUAL_PIN, INPUT);
}
void loop() {
Cayenne.loop();
//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if(millis() - lastMillis > 5000) {
lastMillis = millis();
Cayenne.virtualWrite(0, millis());
float t1 = dht1.readTemperature(); //temp elszívott
float t2 = dht2.readTemperature(); //temp befújt
float t3 = dht3.readTemperature(); //temp friss
float t4 = dht4.readTemperature(); //temp kifújt
float h1 = dht1.readHumidity(); //temp elszívott
float h2 = dht2.readHumidity(); //temp befújt
float h3 = dht3.readHumidity(); //temp friss
float h4 = dht4.readHumidity(); //temp kifújt
float eff = (t2-t3)/(t1-t3)*100;
float eff2 = (t1-t4)/(t1-t3)*100;
mySerial.write(cmd, 9);
mySerial.readBytes(response, 9);
unsigned int responseHigh = (unsigned int) response[2];
unsigned int responseLow = (unsigned int) response[3];
ppm = (256 * responseHigh) + responseLow;
//CO2 via pwm
do {
th = pulseIn(pwmPin, HIGH, 1004000) / 1000;
tl = 1004 - th;
ppm2 = 2000 * (th - 2) / (th + tl - 4);
ppm3 = 5000 * (th - 2) / (th + tl - 4);
} while (th == 0);
Serial.println(ppm);
Serial.println(th);
Serial.println(ppm2);
Serial.println(ppm3);
Serial.println(“-----------”);
Serial.print(“Humidity 1: “);
Serial.print(h1);
Serial.print(” %\t”);
Serial.print(“Temperature 1: “);
Serial.print(t1);
Serial.println(” *C”);
Serial.print(“Humidity 2: “);
Serial.print(h2);
Serial.print(” %\t”);
Serial.print(“Temperature 2: “);
Serial.print(t2);
Serial.println(” *C”);
Serial.print(“Humidity 3: “);
Serial.print(h3);
Serial.print(” %\t”);
Serial.print(“Temperature 3: “);
Serial.print(t3);
Serial.println(” *C”);
Serial.print(“Humidity 4: “);
Serial.print(h4);
Serial.print(” %\t”);
Serial.print(“Temperature 4: “);
Serial.print(t4);
Serial.println(” *C”);
Serial.print(“Eff:” );
Serial.print(eff);
Serial.print(“Eff2:” );
Serial.print(eff2);
delay(5000);
effa(PWM_VIRTUAL_PIN12);
effb(PWM_VIRTUAL_PIN13);
temp_el(VIRTUAL_PIN1);
hum_el(VIRTUAL_PIN2);
temp_be(VIRTUAL_PIN3);
hum_be(VIRTUAL_PIN4);
temp_friss(VIRTUAL_PIN5);
hum_friss(VIRTUAL_PIN6);
temp_ki(VIRTUAL_PIN7);
hum_ki(VIRTUAL_PIN8);
co2_el(VIRTUAL_PIN9);
}
}
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
//CAYENNE_OUT_DEFAULT()
//{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
// Cayenne.virtualWrite(0, millis());
// 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);
//}
// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
//CAYENNE_IN_DEFAULT()
//{
// CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
//}
CAYENNE_IN(PWM_VIRTUAL_PIN11)
{
// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 255
analogWrite(D3, currentValue); // analogWrite accepts a value from 0 to 255
// Serial.println(currentValue);
}
CAYENNE_IN(PWM_VIRTUAL_PIN12)
{
// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 255
analogWrite(D3, currentValue); // analogWrite accepts a value from 0 to 255
// Serial.println(currentValue);
}
void effa(int VIRTUAL_PIN12)//hatásfok
{
//float t4 = dht4.readTemperature();
float t1 = dht1.readTemperature();
float t2 = dht2.readTemperature();
float t3 = dht3.readTemperature();
float eff = (t2-t3)/(t1-t3)*100;
Cayenne.virtualWrite(VIRTUAL_PIN12, effa);
}
void effb(int VIRTUAL_PIN13)//hatásfok2
{
float t1 = dht1.readTemperature();
float t4 = dht4.readTemperature();
float t3 = dht3.readTemperature();
float eff2 = (t1-t4)/(t1-t3)*100;
Cayenne.virtualWrite(VIRTUAL_PIN13, effb);
}
void temp_el(int VIRTUAL_PIN1) //temp elszívott
{
// Read data from the sensor and send it to the virtual channel here.
// You can write data using virtualWrite or other Cayenne write functions.
// For example, to send a temperature in Celsius you can use the following:
float t1 = dht1.readTemperature();
Cayenne.virtualWrite(VIRTUAL_PIN1, t1);
}
void hum_el(int VIRTUAL_PIN2)//hum elszívott
{
float h1 = dht1.readHumidity();
Cayenne.virtualWrite(VIRTUAL_PIN2, h1);
}
void temp_be(int VIRTUAL_PIN3)//temp befújt
{
float t2 = dht2.readTemperature();
Cayenne.virtualWrite(VIRTUAL_PIN3, t2);
}
void hum_be(int VIRTUAL_PIN4)//hum befújt
{
float h2 = dht2.readHumidity();
Cayenne.virtualWrite(VIRTUAL_PIN4, h2);
}
void temp_friss(int VIRTUAL_PIN5)//temp friss
{
float t3 = dht3.readTemperature();
Cayenne.virtualWrite(VIRTUAL_PIN5, t3);
}
void hum_friss(int VIRTUAL_PIN6)//hum friss
{
float h3 = dht3.readHumidity();
Cayenne.virtualWrite(VIRTUAL_PIN6, h3);
}
void temp_ki(int VIRTUAL_PIN7)//temp kifújt
{
float t4 = dht4.readTemperature();
Cayenne.virtualWrite(VIRTUAL_PIN7, t4);
}
void hum_ki(int VIRTUAL_PIN8)//hum kifújt
{
float h4 = dht4.readHumidity();
Cayenne.virtualWrite(VIRTUAL_PIN8, h4);
}
void co2_el(int VIRTUAL_PIN9) //co2 elszívott
{
//int ppm = readCO2();
Cayenne.virtualWrite(VIRTUAL_PIN9, ppm3);
}