Skip to main content

Aranet4 Python client

Project description

Aranet4 Python client

Installation

  1. Install bluepy:
sudo apt-get install python-pip
sudo apt-get install libglib2.0-dev
sudo pip install bluepy
sudo pip install requests
  1. Pair device:
    1. Open bluetoothctl: sudo bluetoothctl
    2. Scan devices: scan on
    3. When found your device, stop scan: scan off
    4. Pair device: pair <DEVICE_ADDRESS>
    5. Exit from bluetooth ctl: exit

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:

  1. Edit crontab: crontab -e
  2. 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
  1. 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


Download files

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

Source Distribution

aranet4-1.1.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

aranet4-1.1.1-py2-none-any.whl (4.9 kB view hashes)

Uploaded Python 2

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