Aranet4 Python client
Project description
Aranet4 Python client
Installation
- Install bluepy:
sudo apt-get install python-pip
sudo apt-get install libglib2.0-dev
sudo pip install bluepy
sudo pip install requests
- Pair device:
- Open bluetoothctl:
sudo bluetoothctl
- Scan devices:
scan on
- When found your device, stop scan:
scan off
- Pair device:
pair <DEVICE_ADDRESS>
- Exit from bluetooth ctl:
exit
- Open bluetoothctl:
Usage
Run script: python aranet.py <DEVCE_ADDRESS> [OPTIONS]
Options:
-n Print current info only
-o <file> Save history to file
-l <count> Get <count> last records
-u <url> Remote url for current value push
Usage as library
You can use this in your own project by adding aranet4 folder to your project and in main code just import it:
import aranet4
device_mac = "00:00:00:00:00:00"
ar4 = aranet4.Aranet4(device_mac)
current = ar4.currentReadings()
print "Temperature:", current["temperature"]
print "Humidity:", current["humidity"]
print "Pressure:", current["pressure"]
print "CO2:", current["co2"]
Examples
Current readings
Input: python aranet.py AA:BB:CC:DD:EE:FF -n
Output:
--------------------------------------
Connected: Aranet4 00000 | v0.3.1
Updated 51 s ago. Intervals: 60 s
5040 total readings
--------------------------------------
CO2: 904 ppm
Temperature: 19.9 C
Humidity: 51 %
Pressure: 997.0 hPa
Battery: 96 %
--------------------------------------
History
History file format: Id;Date;Temperature;Humidity;Pressure,CO2
History file example:
0;2019-09-09 15:11;25.00;43;1015.2;504
1;2019-09-09 15:12;25.00;43;1015.2;504
...
Usage with InfluxDB
If you wish to store data on server, using InfuxDB, check influx.py
Automatic data collection To automate data collection, using crontab will be easiest way:
- Edit crontab:
crontab -e
- Add job. If running Aranet4 with 1 minute intervals, run script veery minute:
* * * * * python /PATH_TO_THIS_REPO/influx.py XX:XX:XX:XX:XX:XX anrijsAR4
- Save and close crontab.
History upload
It is also possible to upload history to InfluxDB. In this case run command:
python influx.py XX:XX:XX:XX:XX:XX anrijsAR4 -h
To limit record count, add -l <count>
parameter.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aranet4-1.1.1.tar.gz
.
File metadata
- Download URL: aranet4-1.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fe82f7f4853b5035f37d67dedba8e783b97d2bedf681bbd33da25bf56996d78 |
|
MD5 | a2688229342daa4f622c397521b0ba40 |
|
BLAKE2b-256 | 87e9e98e81617a778328c302ec4609a42942f970dcc4f9132ad26a4e678aaa6d |
File details
Details for the file aranet4-1.1.1-py2-none-any.whl
.
File metadata
- Download URL: aranet4-1.1.1-py2-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b193759fb79cf5ab5f5b57f6e2585f3a7b0cd399810160cfd21fc05468424c1 |
|
MD5 | ded9eb59eb936593165353ba8f5fa966 |
|
BLAKE2b-256 | dfe18204efccfc98e487c6fe7a4ab87635df09746730ef6c78944250b3a14acd |