The Mi Flora sensor is a small Bluetooth Low Energy device that monitors soil moisture, air temperature and water conductivity. It is useful for agriculture, and due to its low price, it can be easily reach by small farms. On the other hand, it worths for us to invest more software support for it.
My idea is to make a Python asyncio-based library to help access it.
Objective:
- asyncio
- Python 3
- Installable via
pip
. - Lightweight enough to run on embedded computer.
What already exists in the market
-
miflora already exists. But it is synchronous code.
-
There are some Python libraries for BLE (Bluetooth Low Energy), but they all are synchronous code.
-
There exists asyncio library for BlueZ, but it is just a wrapper around BlueZ's binary tools. It means that, every time we call a function, some external process have to be launched, causing much overhead.
-
There are some asyncio libraries to access D-Bus, which we can use to call BlueZ.
What is the direction for solution
Let's build a library which:
- Based on asyncio
- Using D-Bus to call BlueZ. We only need to focus on BLE, not full Bluetooth functionalities.
- Using MiFlora private info to detect and retrieve data from MiFlora.
Depend on practical need, we may split the library to some smaller ones:
- Library A to work with BLE devices in general.
- Library B, based on A, to focus on MiFlora.
So, who are interested, before join us, AgriConnect, to build the library as an open source software.
Not in scope
- Because other than Linux, no platform provides a software stack for Bluetooth which can be freely used (BlueZ), we don't need to support Windows and Mac OS X.
- This library is to read sensor, we only focus to BLE, not full Bluetooth.
- No need to support Python older than 3.5 (so that we can use
async/await
syntax).
Reference:
- There is BTZen, which is similar (asyncio, BLE, D-Bus), but to read other sensors.