gumslone / tehybug

Low Power WIFI weather stations and environmental data loggers based on ESP8266/ESP8285 Module
https://www.tindie.com/stores/gumslone/
27 stars 7 forks source link

Format of MQTT server #7

Closed LukeMondy closed 1 week ago

LukeMondy commented 2 years ago

https://github.com/gumslone/tehybug/blob/45a030cf6eaa593474a7cc86b2bd36e26733e07f/tehybug_co2_firmware/README.md?plain=1#L58

Does the MQTT server need to have a port specified?

e.g., will mqtt.home.com work, or would it need to be: mqtt.home.com:1883

Could you also specify some more details about what topics it will publish? I'm having trouble getting it to talk to my mqtt server, but I'm not sure what to look for.

gumslone commented 2 years ago

Hi,

you have to provide only the tld like mqtt.home.com or the IP address, without a port.

Port 1883 will be used for the MQTT communication, there is no way to define a custom port with current firmware.

Thanks

gumslone commented 2 years ago

the sensor data is located inside the homeassistant topic, you can browse the topic with a MQTT Explorerr App

LukeMondy commented 2 years ago

Great, thanks!

I've done a packet capture, and I can see the device talking to my MQTT server - but unfortunately, now it's saying that the "Connection Refused: not authorized"

I simply copied and pasted the mqtt password from my password manager to the wifi configure screen, and it works OK on Tasmota devices (for example).

The password is quite long though: it's 64 characters (I think that was what was generated by Home Assistant). Is there is a limit for the TeHyBug?


Actually, I just checked my packet capture, and it has the MQTT connect command. Notably it says:

User Name Length: 0
User Name :
Password Length: 24
Password: (the first 24 chars of the mqtt password)

Not sure why the username is 0 length, but yes, the password is missing 40 chars too.

LukeMondy commented 2 years ago

Ah, I see :sweat_smile: https://github.com/gumslone/tehybug/blob/45a030cf6eaa593474a7cc86b2bd36e26733e07f/tehybug_co2_firmware/Config.h#L10

gumslone commented 2 years ago

Hi, I have increased the password size to 65 charactes

LukeMondy commented 2 years ago

Hey, thanks,

I've updated the firmware, but for some reason the bug is not letting me reset the wifi settings.

When I hold the mode button for 15 seconds, the LED goes blue, but then after a little while (20 seconds), it goes back to green, and no wifi from the bug shows up. It also comes back on to the network, so I can reach it for the /update page or other functions.

But since I can't reset the wifi details, I can't test if I can put in a longer password for the mqtt server.

If I look at the serial output when I do a wifi reset, I get:

long click                                                                                                        

reset wifi                                                                                                        

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)                                                                     

load 0x4010f000, len 3460, room 16                                                                                
tail 4                                                                                                            
chksum 0xcc                                                                                                       
load 0x3fff20b8, len 40, room 4                                                                                   
tail 4                                                                                                            
chksum 0xc9                                                                                                       
csum 0xc9                                                                                                         
v0006e360                                                                                                         
~ld                                                                                                               
Scanning...                                                                                                       
I2C device found at address 0x38  !                                                                               
I2C device found at address 0x62  !                                                                               
I2C device found at address 0x77  !                                                                               
done                                                                                                              

Sensor type: BMP280     

Button Demo                                                                                                       
 Longpress Time: 1000ms                                                                                           
 DoubleClick Time: 400ms                  +-----------------------------+                                         
 Longpress Time: 1000ms                   |                             |                                         
 DoubleClick Time: 400ms                  |  Cannot open /dev/ttyUSB0!  |                                         
 Longpress Time: 15000ms                  |                             |                                         
 DoubleClick Time: 400ms                  +-----------------------------+                                         

Hello from esp8266-tehybug-co2-sensor                                                                             
Core Version: 3.0.2                                                                                               
                   Boot Version: 31                                                                               
                                   Boot Mode: 1                                                                   
                                               CPU Frequency: 80 MHz                                              
                                                                    Reset reason: Software/System restart         
                                                                                                         HostnameA
                                                                                                                 7
                                                                                                                 e
                                                                                                                 C
Pressure:    969 hPa                                                                                              
Altitude:    482.95 m                                                                                             

humidity: 34%    temperature: 24.2                                                                                

CO2(ppm):670    Temperature(C):36.2     Humidity(%RH):19.5                                                        
Temperature: 25.10 C                                                                                              
Pressure:    969 hPa                                                                                              
Altitude:    482.95 m                                 

(don't worry about the Cannot open /dev/ttyUSB0!, that's just from the program I'm using)

I got the latest firmware from today: https://github.com/gumslone/tehybug/blob/f0ead97b1b2bafae8d778b305eb4ba2f8d2ac7f6/tehybug_co2_firmware/tehybug_co2_firmware.ino.esp8285.bin

LukeMondy commented 2 years ago

Latest firmware fixes it! It shows up in Home Assistant now - great, thanks!