MQTT - pierwsze kroki

User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Inicjuję clienta, podaję user, pass, serwer, jedynie nigdzie nie wpisuję protokołu, ale może jest domyślny. Rejestracja aplikacja aktywna. Nie łączy się... O czym zapomniałem?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Używam libsa pubsubclient.
Opis:
https://pubsubclient.knolleary.net/api

mam:

Code: Select all

const char* ssid = "xx";
const char* password = "xx";
const char* mqtt_server = "mqttxx.supla.org";
const char* mqtt_user = "8d0xxx956";
const char* mqtt_pass = "cQ)xxxQInDypoWP";
potem

Code: Select all

Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str(), mqtt_user, mqtt_pass)) {
    
wreszcie:

Code: Select all

client.setServer(mqtt_server, 8883);
Czyli raczej ok..
literówek nie zrobiłem
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
klew
Posts: 13907
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

SOYER wrote: Fri Dec 20, 2024 6:23 pm Używam libsa pubsubclient.
Opis:
https://pubsubclient.knolleary.net/api

mam:

Code: Select all

const char* ssid = "xx";
const char* password = "xx";
const char* mqtt_server = "mqttxx.supla.org";
const char* mqtt_user = "8d0xxx956";
const char* mqtt_pass = "cQ)xxxQInDypoWP";
potem

Code: Select all

Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str(), mqtt_user, mqtt_pass)) {
    
wreszcie:

Code: Select all

client.setServer(mqtt_server, 8883);
Czyli raczej ok..
literówek nie zrobiłem
Sprawdzałeś czy ta biblioteka ma szyfrowane połączenia? I czy dobrze ustawiłeś szyfrowanie?
Czasem wystarczy ustawienie portu, a czasem trzeba coś więcej
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

fakt szyfrowanie, sprawdzę
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Zrobiłem na
WiFiClientSecure client1;
PubSubClient client(client1);
jednak dalej nic, tylko kod zmienił się z -4 na -2.
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
klew
Posts: 13907
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Mosquito ma gdzieś publiczny serwer do testowania. Spróbuj znaleźć na niego namiary i się z nim połączyć
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Dzisiaj już to zostawię. Jutro dalej.
Czy czasem nie muszę też ustawić czasu na moim device?
Druga rzecz, próbuję to zrobić na esp8266, nie dotarło jeszcze esp32. Wiem, że z szyfrowanymi połączeniami na esp8266 był problem przy supli, z powodu małej ilości pamięci, ale nie wiem czy to też dotyczy "zwykłego" mqtt...
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79

Return to “MQTT”