Skip to main content

databot Python Library

Project description

databot-py

A bluetooth Python interface for interacting with the databot sensor device.

The classes in this package provide a Pythonic interface for interfacing with the databot sensor device. These classes allow the user to select different sensors of interest and retrieve the sensor values on a user selected periodic polling frequency. The sensor values can be returned to the host Python script by either a file, a queue interface, a web service interface, etc.

The PyDatabot class provides the foundation for building custom classes to process the data returned from the databot, while the PyDatabot class handles all of the setup and data retrieval.

Install

It is recommended that you use a package manager like pip-tools or poetry and do not rely on a existing requirements.txt

The reason is that operating system dependent libraries need to be installed to support bluetooth.

Basic installation, just pip install the databot-py package from PyPI.

e.g. pip install databot-py

If using pip-tools in your project then

  • pip install pip-tools
  • create a file called requirements.in
  • add: databot-py
  • pip-compile
  • pip-sync

This will install all of the OS specific versions of libraries.

Classes

classes

PyDatabot

This class is the base class implementation for interacting with the databot over bluetooth.

This class can be used directly and will print the data read from the databot.

However, this class is really meant to be inherited from and the derived class should override the method process_databot_data.

The process_databot_data method will be called for each data record from the databot and the derived class can then process the data in a specific way.

PyDatabotSaveToFileDataCollector

This class extends the PyDatabot class and overrides the process_databot_data method to save values to a file.

This class is used primarily to easily read values from the databot and save them to a file for future processing.

PyDatabotSaveToQueueDataCollector

This class extends the PyDatabot class and overrides the process_databot_data method to save values to an internal queue.

This class is used primarily with the databot webserver to provide the latest readings from the databot.

Local WebServer Interface

A local web service interface is available to get data values from the databot.

webarch

Create an instance of the PyDatabotSaveToQueueDataCollector class with the desired sensors configured.

Then call the function start_databot_webserver in the PyDatabot module passing a reference to the PyDatabotSaveToQueueDataCollector

See the example in:

examples/pydatabot_webserver_example.py

Run Locally

Install Local Requirements

Recommended steps to install locally

  • pip install pip-tools or python -m pip install pip-tools
  • pip-compile
  • pip-sync

Examples

Locate the Databot BlueTooth address

Every databot has a bluetooth address. The find the address use the static method:

PyDatabot.get_databot_address()

and it is used in the configration like:

    c = DatabotConfig()
    c.address = PyDatabot.get_databot_address()

Simple Databot interfacing to print data values

This example will show you how to connect to the databot and display the selected data values.

Custom Databot consumer

The PyDatabot class performs all of the necessary steps to interface with the databot and collect data from the databot. However, the PyDatabot class does not do anything with the collected data excepti to print it.

For any custom processing of the databot data, a custom databot consumer is needed.

For an example and test of how to do this see:

examples/pydatabot_custom_consumer.py

Save databot data to file

This example shows how to write the collected values to a file for later processing

examples/pydatabot_save_data_to_file.py

View Ambient Light Sensor Values

This example shows how to read ambient light sensor values. Start the example and then cover the sensor with your hand.

Notice the light level values goes down.

examples/pydatabot_light_level_example.py

Breath Detector

This example shows how to read co2 level. Start the example and then breath on the databot. Watch the co2 values go up.

examples/pydatabot_light_level_example.py

Databot WebServer Access

This example shows how to start a simple webserver interface to get the current values from the databot.

examples/pydatabot_webserver_example.py

You can then open a browser and navigate to: http://localhost:8321

And the sensor values will be displayed as a JSON string.

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

databot-py-0.0.8.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

databot_py-0.0.8-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file databot-py-0.0.8.tar.gz.

File metadata

  • Download URL: databot-py-0.0.8.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for databot-py-0.0.8.tar.gz
Algorithm Hash digest
SHA256 b811cc9dedeffa7c514e34addc1ad212e7e1d2a21436e671aa3c00cd0c14f397
MD5 96782bcb60f5c8e88e9487ba91aab6e0
BLAKE2b-256 5f484817cc766d0b9ac2e223dd1e5a6c9e81ac8be25b5f9f633fc2664ad84d68

See more details on using hashes here.

File details

Details for the file databot_py-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: databot_py-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for databot_py-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 876af355aef57e86e36ca7209456ccad45ea6a0a85a7f2759710d9fa4189f21c
MD5 b756c5e30d5f46e2f52f85a29d1ea768
BLAKE2b-256 29185e609d8d12865ce4eedcdda553db3f0458a01d0e2514f1b13e822d52d89e

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