Skip to main content

Xiaomi Mijia LYWSD03MMC sensor library

Project description

LYWSD03MMC

A Python library for working with Xiaomi Mijia LYWSD03MMC bluetooth temperature and humidity sensors.

Updating the firmware on the devices is not required.

This package is built on top of the lywsd02 package, which may include additional useful information.

Installation

This relies on bluepy installed via python pip, which itself needs libglib2 to install:

sudo apt-get install python3-pip libglib2.0-dev

The LYWSD03MMC package can then be installed from PyPi, using the following command:

pip3 install lywsd03mmc

Finding the MAC address of the devices

From the Xiaomi Home app:

  1. Go into the details of the device
  2. Click on the three dots to get into the settings
  3. Click "About" (near the top of the list)
  4. And make a note of the MAC address shown.

It is also possible to find the addresses of all devices by running sudo hcitool lescan and looking for devices labelled "LYWSD03MMC"

Tools

Two helper commands are distributed here:

lywsd03mmc - Current data

This shows the current temperature, humidity and battery level of the device.

Example usage: lywsd03mmc A4:C1:38:12:34:56

lywsd03mmc2csv - Export history

This exports the history to a CSV file, containing the maximum and minimum temperature and humidity for each hour there is data for.

This can be very slow, and may take up to about 10 minutes to download all the data from the device.

Example usage: lywsd03mmc2csv A4:C1:38:12:34:56 --output data.csv

Library Usage

The library interface closely matches the LYWSD02 package, with the following changes:

  • Setting the time has been removed
  • Battery data is available from the main data export
  • An extra option has been included to estimate the time the device was started
  • History data times are calculated based on the start time of the device

Connecting and retrieving information

Here's an example of getting the basic information out of the device:

from lywsd03mmc import Lywsd03mmcClient
client = Lywsd03mmcClient("A4:C1:38:12:34:56")

data = client.data
print('Temperature: ' + str(data.temperature))
print('Humidity: ' + str(data.humidity))
print('Battery: ' + str(data.battery))
print('Display units: ' + client.units)

History

Times given in the history output are for the end of the hour in which data was recorded.

Downloading the history data can take a significant amount of time (up to about 10 minutes).

A property is available on the client to output data from each record retrieved, to allow you to see the progress:

# Create the client
from lywsd03mmc import Lywsd03mmcClient
client = Lywsd03mmcClient("A4:C1:38:12:34:56")

# Enable history output
client.enable_history_progress = True

# Retrieve the history data
history = client.history_data

Troubleshooting

Failed to connect to peripheral

Check you are connecting to the correct MAC address, and are in range of the device.

If those are correct, this can normally be fixed by retrying the connection.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lywsd03mmc-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

lywsd03mmc-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file lywsd03mmc-0.1.0.tar.gz.

File metadata

  • Download URL: lywsd03mmc-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for lywsd03mmc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 db8fa3a05142da547deec99d3d61573cc30d7999834cbb0983af91bf6261eacd
MD5 42f875cacd7e283d6f501ab1db948605
BLAKE2b-256 fdb64fa827239a54be8223727e3ca0ba1e6d21021175a6c1c142b745df64ad2c

See more details on using hashes here.

File details

Details for the file lywsd03mmc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lywsd03mmc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for lywsd03mmc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e512ffc7d48408dae7ec0055a71312c8dca60dcc9ffd8a1aafed789fb6eb6d2
MD5 ddc524cf9bdba7b225592b4ed70f0bb9
BLAKE2b-256 41a06ba677481c71f5858c84ab5e03c727a5cec28132824ccac3925306aaaf49

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page