matthias-bs / BresserWeatherSensorReceiver

Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver for Arduino based on CC1101, SX1276/RFM95W or SX1262
MIT License
118 stars 21 forks source link

No connection to MQTT Broker possible #47

Closed stundenblume closed 1 year ago

stundenblume commented 1 year ago

After some trouble I got the basic and callback examples running successfully.

But if I try to connect to a unsecured Mosquitto broker it won't connect.

Opened the MQTT example and modified it to:

#define SLEEP_EN        false

and

#ifndef SECRETS
    const char ssid[] = "xxxxxxxx";
    const char pass[] = "yyyyyyyy";

    #define HOSTNAME "ESPWeather"
    #define APPEND_CHIP_ID

    #define    MQTT_PORT     1883 // checked by pre-processor!
    const char MQTT_HOST[] = "192.168.123.186";
    const char MQTT_USER[] = ""; // leave blank if no credentials used
    const char MQTT_PASS[] = ""; // leave blank if no credentials used

After compiling and uploading, I get this massage:

sdd��|�$�|�l�c|����{�c�#��'o�dog���bx��l{lsdp�g��d��co�|���b��ng�$��$`�ogl`'{���o#l�d8�o�{������cn�|�c��og�d`�gnl`o;���gc��`;��ob��`���|�l�d`��g�l
SDK:2.2.2-dev(38a443e)/Core:3.1.1=30101000/lwIP:STABLE-2_1_3_RELEASE/glue:1.2-65-g06164fb/BearSSL:b024386

BresserWeatherSensorMQTT 20221024

Attempting to connect to SSID: xxxxxxxxfpm close 1 
mode : sta(84:cc:a8:b1:e7:10)
add if0
...scandone
state: 0 -> 2 (b0)
.state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt 

connected with xxxxxxxx, channel 1
dhcp client start...
ip:192.168.123.119,mask:255.255.255.0,gw:192.168.123.1
connected!
Setting time using SNTP done!
Current time: Mon Mar 13 08:45:42 2023

Checking wifi...
MQTT connecting... .........pm open,type:2 0
..............................

I tried two simple sketches to verify a connection to the broker is possible. This very simple code also won't connect.

{$lܟ<�l�|�d�c<����s�#�c��g'�l'o���cp��dsdrlx�o��d��cn�|���#��no�d��$`�g'l n{���obd�dp�g�;������co�<�c��g'�l`�og$`gs�ۓnc��`sۓnc��`��s��l`��o�l
SDK:2.2.2-dev(38a443e)/Core:3.1.1=30101000/lwIP:STABLE-2_1_3_RELEASE/glue:1.2-65-g06164fb/BearSSL:b024386
fpm close 1 
mode : sta(84:cc:a8:b1:e7:10)
add if0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt 

connected with xxxxxxxxxx, channel 1
dhcp client start...
ip:192.168.123.119,mask:255.255.255.0,gw:192.168.123.1
192.168.123.119
pm open,type:2 0

But this code runs as expected.

sd$��|�l�|�d�#|����;�c�c��og�$gn���c8�lrl{lp�'��l��#g�|���c��g'�l��l �'od`o;Ǜ�gcd�lp�'�s��ܜ��#g�|�c��gn�l �ogl`gs�ۓnc��`sۓnc��`���pl`��n�$
SDK:2.2.2-dev(38a443e)/Core:3.1.1=30101000/lwIP:STABLE-2_1_3_RELEASE/glue:1.2-65-g06164fb/BearSSL:b024386

Connecting to xxxxxxxx
fpm close 3 
mode : sta(84:cc:a8:b1:e7:10)
add if0
.....scandone
state: 0 -> 2 (b0)
.state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt 

connected with xxxxxxxxx, channel 1
dhcp client start...
ip:192.168.123.119,mask:255.255.255.0,gw:192.168.123.1
.
WiFi connected
IP address: 
192.168.123.119
Attempting MQTT connection...connected
subscribed to : wemos/esp-84:cc:a8:b1:e7:10/in
pm open,type:2 0
Publish topic: wemos/esp-84:cc:a8:b1:e7:10/out
Publish message: {"micros":20001068,"counter":1,"client":esp-84:cc:a8:b1:e7:10}

Maybe this issue is related? I will try to find out why no connection to the broker is established.

stundenblume commented 1 year ago

After changing this:

//#define USE_SECUREWIFI          // use secure WIFI
#define USE_WIFI              // use non-secure WIFI

everything works as expected.

�������������������������
SDK:2.2.2-dev(38a443e)/Core:3.1.1=30101000/lwIP:STABLE-2_1_3_RELEASE/glue:1.2-65-g06164fb/BearSSL:b024386

BresserWeatherSensorMQTT 20221024

Attempting to connect to SSID: xxxxxxxxfpm close 1 
mode : sta(84:cc:a8:b1:e7:10)
add if0
...scandone
state: 0 -> 2 (b0)
.state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt 

connected with xxxxxxxxx, channel 1
dhcp client start...
ip:192.168.123.119,mask:255.255.255.0,gw:192.168.123.1
connected!
Checking wifi...
MQTT connecting... connected!
ESPWeather-B1E710/status: online
[CC1101] Initializing ... 
success!
[CC1101] Setup complete - awaiting incoming messages...