Skip to main content

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.

Release files for databot-py 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for databot-py 0.0.8
File Size Uploaded
databot-py-0.0.8.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for databot-py 0.0.8
File Interpreter ABI Platform
databot_py-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 22.1 kB

Release files / databot-py-0.0.8.tar.gz

Download URL databot-py-0.0.8.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b811cc9dedeffa7c514e34addc1ad212e7e1d2a21436e671aa3c00cd0c14f397
BLAKE2b-256 checksum
How to use checksums
5f484817cc766d0b9ac2e223dd1e5a6c9e81ac8be25b5f9f633fc2664ad84d68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4

Release files / databot_py-0.0.8-py3-none-any.whl

Download URL databot_py-0.0.8-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
876af355aef57e86e36ca7209456ccad45ea6a0a85a7f2759710d9fa4189f21c
BLAKE2b-256 checksum
How to use checksums
29185e609d8d12865ce4eedcdda553db3f0458a01d0e2514f1b13e822d52d89e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page