Closed 885narrow closed 1 year ago
Hallo,
sorry, dass ich mich erst jetzt melde. Hast du es inzwischen zum Laufen gebracht? Ich gebe zu, dass ich letzte Versionen nicht mit esp8266 getestet habe. Reicht dir der Arbeitspeicher von dem esp8266, der ist schon recht knapp. Hast du mal den Beispielcode ohne WiFi/MQTT mal getestet? Funktioniert es dann? Ich gehe davon aus, dass dein WiFi/MQTT Code ohne der WeatherStationDataRx richtig funktioniert.
Hallo , Danke fuer deine Antwort , Es zeigt sich das das eigentlich kein Fehler ist ...er findet dann die Stationen und auch die Daten werden ordentlich geliefert. Vielen Dank!
Hi, I am using your example and tried to get it working with mqtt and wifi. I am not that good in programming and your code gives me even with delay very fast a lot of:
WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test WeatherStationDataRx Test
**does it mean it is restarting my esp8266? because the delay (5000) is not used.i also do not know why PairedDeviceAdded2 is calling itself? looped? for my understanding I renamed the function to see the difference.**
`void PairedDeviceAdded2(byte newID) {
if defined(ESP8266) || defined(ESP32)
Serial.printf("esp New device paired %d\r\n", newID);
else
Serial.print("New device paired "); Serial.println(newID, DEC);
endif
wsdr.pair(PairedDeviceAdded2);
// If you already have a sensor ID for your device, you can set it as follows. //byte myDeviceIDs[] = {236, 65};
//wsdr.pair(myDeviceIDs, sizeof(myDeviceIDs)); //byte myDeviceIDs[] = { 98, 67 }; //wsdr.pair(myDeviceIDs, sizeof(myDeviceIDs)); } ` Due to my low knowledge I did not get the known IDS to pair as well, where do I need to set these?
somehow I get my data in IOBROKER via MQTT, but not reliable. I use a RXB6 with Antenna
I will add my code here, maybe somebody can use it too, or give me a hint why not reliable.
`
define wifi etc. here.
define ESP8266
include
include
include
define MQTT_ALIVE_TOPIC "Wetterstation/%s/alive"
define MQTT_DATA_TOPIC "Wetterstation/%s/%s"
define MQTT_KEEPALIVE 10
String value;
WiFiClient wifiClient; byte mac[6]; char sensorId[7]; char topicBuffer[255]; char messageBuffer[255];
PubSubClient mqttClient(wifiClient);
void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(WIFI_SSID);
WiFi.mode(WIFI_STA); // disable hotspot WiFi.begin(WIFI_SSID, WIFI_PASSWORD); wdt_reset(); // Watchdock resetten
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); }
extern const char MQTT_FALSE = "0"; extern const char MQTT_TRUE = "1";
char MQTT_CLIENT_ID[15]; void setup_mqtt() {
mqttClient.setServer(MQTT_HOST, MQTT_PORT);
byte mac[6];
WiFi.macAddress(mac);
sprintf(MQTT_CLIENTID, "ESP8266%02X%02X%02X", mac[3], mac[4], mac[5]); }
void connect_mqtt(char* MQTT_TOPIC) {
// Loop until we're reconnected
while (!mqttClient.connected()) {
if defined(MQTT_ALIVE_TOPIC)
else
endif
} }
ifdef ESP8266
define DATA_PIN D5
else
define DATA_PIN 2
endif
WeatherStationDataRx wsdr(DATA_PIN, false, ARMUseAsConfirmation, false);
void PairedDeviceAdded2(byte newID) {
if defined(ESP8266) || defined(ESP32)
Serial.printf("esp New device paired %d\r\n", newID);
else
Serial.print("New device paired "); Serial.println(newID, DEC);
endif
wsdr.pair(PairedDeviceAdded2);
// If you already have a sensor ID for your device, you can set it as follows. //byte myDeviceIDs[] = {236, 65};
//wsdr.pair(myDeviceIDs, sizeof(myDeviceIDs)); //byte myDeviceIDs[] = { 98, 67 }; //wsdr.pair(myDeviceIDs, sizeof(myDeviceIDs)); }
void setup() { Serial.begin(57600); delay(5000); Serial.println("WeatherStationDataRx Test"); wsdr.begin(); wsdr.pair(PairedDeviceAdded2);
wdt_enable(WDTO_8S);
WiFi.macAddress(mac); sprintf(sensorId, "%02X%02X%02X", mac[3], mac[4], mac[5]); wdt_reset(); setup_wifi(); wdt_reset(); // Watchdog resetten setup_mqtt(); wdt_reset(); // Watchdog resetten
}
void loop() { wdt_reset(); // Watchdog resetten connect_mqtt(0); wdt_reset(); // Watchdog resetten mqttClient.loop();
byte newDataState = wsdr.readData(true); if (mqttClient.connected() && (newDataState > 0)) { Serial.print("SensorID "); Serial.println(wsdr.sensorID());
} } `
herzlichen Dank! auch fuer die viele Arbeit die du in dieses Projekt gesteckt hast. LG