Hallo allerseits,
ich brauche mal Eure Hilfe.
Wie muss ich die Ausgabe von Value umwandeln, damit client.publish daten sendet ?
Ich bekomme immer die Meldung:
invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
Ich lese mit dem ESP8622 einen 433MHz Sender aus und möchte den Code an MQTT übertragen.
Die Serielle Ausgabe klappt.
Hier ist mein Code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <PubSubClient.h>
#include <RCSwitch.h>
#define ssid "idefix"
#define password "wlanpw"
#define mqtt_server "192.168.178.111"
#define mqtt_port 1883
#define topic "/home/data"
RCSwitch mySwitch = RCSwitch();
IPAddress ip(192,168,178,96);
IPAddress gateway(192,168,178,1);
IPAddress subnet(255,255,255,0);
WiFiClient espClient;
PubSubClient client(espClient);
void setup()
{
Serial.begin(115200);
mySwitch.enableReceive(D5);
WiFi.setAutoConnect(false);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
WiFi.config(ip, gateway, subnet);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
client.setServer(mqtt_server, mqtt_port);
}
void reconnect() {
while (!client.connected()) {
// Attempt to connect
if (client.connect("ESP8266ButtonClient")) {
} else {
delay(5000);
}
}
}
void loop(void) {
// HW Raum Tür
int value = mySwitch.getReceivedValue();
if (!client.connected()) { reconnect(); }
client.loop();
if (mySwitch.available()) {
Serial.println(value);
client.publish(topic, value, true);
client.disconnect();
}
mySwitch.resetAvailable();
}
Vielen Dank für EUre Hilfe.
Gruß
Stefan