Package: databot-py
databot-pyA 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.ThePyDatabotclass provides the foundation for building custom classes to process the data returned from the databot, while thePyDatabotclass handles all of the setup and data retrieval.InstallIt is recommended that you use a package manager likepip-toolsorpoetryand do not rely on a existing requirements.txtThe reason is that operating system dependent libraries need to be installed to support bluetooth.Basic installation, just pip install thedatabot-pypackage from PyPI.e.g.pip install databot-pyIf using pip-tools in your project thenpip install pip-toolscreate a file calledrequirements.inadd:databot-pypip-compilepip-syncThis will install all of the OS specific versions of libraries.ClassesPyDatabotThis 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 methodprocess_databot_data.Theprocess_databot_datamethod will be called for each data record from the databot and the derived class can then process the data in a specific way.PyDatabotSaveToFileDataCollectorThis class extends thePyDatabotclass and overrides theprocess_databot_datamethod 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.PyDatabotSaveToQueueDataCollectorThis class extends thePyDatabotclass and overrides theprocess_databot_datamethod 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 InterfaceA local web service interface is available to get data values from the databot.Create an instance of thePyDatabotSaveToQueueDataCollectorclass with the desired sensors configured.Then call the functionstart_databot_webserverin the PyDatabot module passing a reference to thePyDatabotSaveToQueueDataCollectorSee the example in:examples/pydatabot_webserver_example.pyRun LocallyInstall Local RequirementsRecommended steps to install locallypip install pip-toolsorpython -m pip install pip-toolspip-compilepip-syncExamplesLocate the Databot BlueTooth addressEvery 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 valuesThis example will show you how to connect to thedatabotand display the selected data values.Custom Databot consumerThe 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.pySave databot data to fileThis example shows how to write the collected values to a file for later processingexamples/pydatabot_save_data_to_file.pyView Ambient Light Sensor ValuesThis 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.pyBreath DetectorThis 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.pyDatabot WebServer AccessThis example shows how to start a simple webserver interface to get the current values from the databot.examples/pydatabot_webserver_example.pyYou can then open a browser and navigate to:http://localhost:8321And the sensor values will be displayed as a JSON string.