1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.6k stars 793 forks source link

How to get temperature/Humidity from Mijia model LYWSD02 #412

Closed xenio closed 5 years ago

xenio commented 5 years ago

I flashed the release OpenMQTTGateway v0.9.1 on ESP32 and I am not getting the temperature and from the Clock Mijia model LYWSD02 as in this post: https://1technophile.blogspot.com/2019/06/integration-of-mijia-clock-temperature.html

I just get the id, rssi, distance and service data. Any Help?

1technophile commented 5 years ago

It is available from v0.9.2beta. You can take the code from the dev branch.

xenio commented 5 years ago

Perfect!!! Thanks you.

1technophile commented 5 years ago

Don't forget to take the libraries from the lib folder of the OMG repository. The ble one supplied with arduino esp32 env is missing an important functionnality.

jamesyym commented 5 years ago

It is available from v0.9.2beta. You can take the code from the dev branch.

I tried the development branch with ESP8266 and HM-10(FW v608) , but it still only get the id, rssi, distance and service data.

3F59C8828829 is the MAC address of LYWSD02 and I set the whitelist for it. Am I right?

Thank you.

captured

1technophile commented 5 years ago

Could you copy/paste on this issue different exempla of service data you are seeing for the LYWSD02 please

jamesyym commented 5 years ago

From the serial monitor:

Uptime (s)
120
Remaining memory
40856
RSSI
-39
SSID
James
Activated modules
BT
4f4b2b444953413afbc96899bb9800a40e0d09536d6172745068696c616d700d0a4f4b2b4449534345
Creating BLE buffer
HomePresenceId
98:BB:99:68:C9:FB
BLErssi
-92
txPower
-59
BLE DISTANCE :
27.75
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"98:BB:99:68:C9:FB","rssi":-92,"distance":27.75274}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/98BB9968C9FB
{"id":"98:BB:99:68:C9:FB","rssi":-92,"distance":27.75274,"servicedata":"5068696c616d70"}
4f4b2b444953413afbc96899bb9800a51d0201060b02031802180f180a18f5fe0dff5048494c414dfbc96899bb980d0a
Creating BLE buffer
HomePresenceId
98:BB:99:68:C9:FB
BLErssi
-91
txPower
-59
BLE DISTANCE :
25.52
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"98:BB:99:68:C9:FB","rssi":-91,"distance":25.51913}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/98BB9968C9FB
{"id":"98:BB:99:68:C9:FB","rssi":-91,"distance":25.51913,"servicedata":"02180f180a18f5fe0dff5048494c414dfbc96899bb98"}
4f4b2b444953413a0ed7cc343e6800a80a09ff006052572d424c450d0a
4f4b2b444953413a0ed7cc343e6800a91f02010609ff903a138d728daa6a1109e9ad85e6978fe981a5e68ea7e599a8000d0a
Creating BLE buffer
HomePresenceId
68:3E:34:CC:D7:0E
BLErssi
-87
txPower
-59
BLE DISTANCE :
18.08
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"68:3E:34:CC:D7:0E","rssi":-87,"distance":18.07764}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/683E34CCD70E
{"id":"68:3E:34:CC:D7:0E","rssi":-87,"distance":18.07764,"servicedata":"138d728daa6a1109e9ad85e6978fe981a5e68ea7e599a800"}
4f4b2b444953413a298882c8593f00a01c02010603021a18141695fe70205b0461298882c8593f09061002d0020d0a
Creating BLE buffer
HomePresenceId
3F:59:C8:82:88:29
BLErssi
-96
txPower
-59
BLE DISTANCE :
38.49
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"3F:59:C8:82:88:29","rssi":-96,"distance":38.4873}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/3F59C8828829
{"id":"3F:59:C8:82:88:29","rssi":-96,"distance":38.4873,"servicedata":"141695fe70205b0461298882c8593f09061002d002"}
4f4b2b444953413afc0180fce40f02b41f1eff0600010920025e64c45a7dcba1d732d7298e35267f4a1756cc2cae66700d0a
Creating BLE buffer
HomePresenceId
0F:E4:FC:80:01:FC
BLErssi
-76
txPower
-59
BLE DISTANCE :
6.45
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"0F:E4:FC:80:01:FC","rssi":-76,"distance":6.44788}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/0FE4FC8001FC
{"id":"0F:E4:FC:80:01:FC","rssi":-76,"distance":6.44788,"servicedata":"025e64c45a7dcba1d732d7298e35267f4a1756cc2cae6670"}
4f4b2b444953413a6517f8d1746903ae0e02011a0aff4c00100501103b46900d0a
Creating BLE buffer
HomePresenceId
69:74:D1:F8:17:65
BLErssi
-82
txPower
-59
BLE DISTANCE :
11.49
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"69:74:D1:F8:17:65","rssi":-82,"distance":11.4949}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/6974D1F81765
{"id":"69:74:D1:F8:17:65","rssi":-82,"distance":11.4949,"servicedata":"100501103b4690"}
4f4b2b444953413aaa1bd353905303d70e02011a0aff4c0010050310db1cb40d0a
Creating BLE buffer
HomePresenceId
53:90:53:D3:1B:AA
BLErssi
-41
txPower
-59
BLE DISTANCE :
0.03
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"53:90:53:D3:1B:AA","rssi":-41,"distance":0.026261}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/539053D31BAA
{"id":"53:90:53:D3:1B:AA","rssi":-41,"distance":0.026261,"servicedata":"10050310db1cb4"}
4f4b2b444953413a1f1e8e923b2d02c60f02011b0bff4c000906033fc0a802150d0a
Creating BLE buffer
HomePresenceId
2D:3B:92:8E:1E:1F
BLErssi
-58
txPower
-59
BLE DISTANCE :
0.84
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"2D:3B:92:8E:1E:1F","rssi":-58,"distance":0.842869}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/2D3B928E1E1F
{"id":"2D:3B:92:8E:1E:1F","rssi":-58,"distance":0.842869,"servicedata":"0906033fc0a80215"}
4f4b2b444953413a40584f87007803c60e02011a0aff4c00100507141153740d0a
Creating BLE buffer
HomePresenceId
78:00:87:4F:58:40
BLErssi
-58
txPower
-59
BLE DISTANCE :
0.84
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"78:00:87:4F:58:40","rssi":-58,"distance":0.842869}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/7800874F5840
{"id":"78:00:87:4F:58:40","rssi":-58,"distance":0.842869,"servicedata":"10050714115374"}
4f4b2b444953413a7b4ad66f00d901b31b11072753706865726f2d5475a02b6f74bb22080942422d344137420d0a
Creating BLE buffer
HomePresenceId
D9:00:6F:D6:4A:7B
BLErssi
-77
txPower
-59
BLE DISTANCE :
7.12
Pub json into:
home/home_presence/OpenMQTTGateway
{"id":"D9:00:6F:D6:4A:7B","rssi":-77,"distance":7.119795}
Pub json into:
home/OpenMQTTGateway/BTtoMQTT/D9006FD64A7B
{"id":"D9:00:6F:D6:4A:7B","rssi":-77,"distance":7.119795,"servicedata":"726f2d5475a02b6f74bb22080942422d34413742"}
4f4b2b444953413a7b4ad66f00d901b40a02010603ff3330020af60d0a

And the whitelist seems still not working with the last commit in the development branch.

jamesyym commented 5 years ago

Sorry for the wrong whitelist pattern I've made. The whitelist works well in mqtt but still only get the id, rssi, distance and service data. Below the message shows in mqtt explorer.

{
  "id": "3F:59:C8:82:88:29",
  "rssi": -65,
  "distance": 2.009448,
  "servicedata": "595753443032"
}

And the sevicedata changes like "595753443032" "141695fe70205b04cd298882c8593f09041002ff00" "141695fe70205b0469298882c8593f090410020301"

1technophile commented 5 years ago

@jamesyym thanks for pointing this error with HM10 use. It has been corrected into the dev branch