Package: databear
DataBear V2.2General purpose data aquistion, processing, and logging platform written
in Python. DataBear is hardware independent, but is meant to be easily integrated via a custom hardware interface provided by the user.Goals:Easy to use - intuitive setup and configuration.VersatileUse on any hardware device that runs Python.Compatible with most sensor output.ExtendibleUser can integrate platform with new sensor and methods.V2.2 ChangesChanged API to better integrate with other projects. Added new environmental variables to make operation easier.V2.1 ChangesAdded support for bus type sensors (Modbus, SDI12) via a new
base class: "BusSensor" (see sensor interface below).V2.0 ChangesDatabear now uses a SQLite database for both configuration and data storage.
However, direct interaction with the database is optional and configuration
can still be completed using YAML.DataBear now runs in the background and can be managed via the commandline or
through socket communication.Some potential usage scenarios:Here are some random ideas to give a sense for DataBear capabilities (some capabilities under development).Run DataBear on a Raspberry Pi (https://www.raspberrypi.org/) to read a Modbus temperature sensor.  The sensor could be connected to a USB port on the Pi via an RS485 to USB converter and data could be read every second, averaged, and stored to CSV.Integrate DataBear into an existing Linux based measurement platform, such as the Dyacon MDL-700 (https://dyacon.com).Ideal Datalogger Features vs Data Bear 2.1FeatureData BearAdjustable sampling rates for all measurements☑Concurrent measurement of all sensors☑Adjustable rates of data storage☑Adaptive samplingData and metadata storageSQLiteSupports polled or continuously streaming sensors☑Support for sensors on a bus☑Ability to change settings on the flyPlannedInstallationpip install databearHardwareA "DataBear Driver" is needed to use DataBear on different devices.
Create a driver following the "Driver Interface" below.SensorsAll sensors must have a "sensor class" following the interface defined below.
A repository for sensor classes has been created: github.com/chrisrycx/DataBear-SensorsQuick startCheck to see if a class has been created for your sensor(s)
in github.com/chrisrycx/DataBear-Sensors. If so, clone the repository
and install it using pip. Since this project is new, it is likely you
will need to create a sensor class or modify an existing one (See "Sensor Class Interface"). If you create a class, share it with the DataBear project so others can use it.Create a driver for your platform (See Driver Interface)Create a new configuration file (YAML) following the approach used in the example folder.Set environmental variables::exportDBDRIVER=<pathtomydriver.py>
:exportDBDATABASE=<pathtofolderwheredatabasewillbelocated>*optional
:exportDBSENSORPATH=<pathtofolderwithsensorclasses>*optionalRun/Stop DataBear: databear run <myconfig>.yaml
: databear shutdownDataBear APIDataBear now features a rudimentary API for use with interprocess communication. Commands and responses are exchanged in JSON via UDP.UDP Port: 62000Command Format: {'command': <command>, 'arg': <Optional Argument>}Commandsstatus - Return a response if logger is active.getsensor <sensor name> - Get list of measurements and units for sensor.getdata <sensor name> - Return most recent measurement data for sensor.shutdown - Stop logger.Driver Interface (V0)A class that maps Databear virtual ports to hardware ports.Class initialization should create a dictionary relating virtual
ports to actual platform specific ports.A connect method returns the actual port given the virtual port.Add code as needed to provide any hardware specific configuration.classdbdriver:def__init__(self):'''Map virtual ports to hardware ports'''#A windows exampleself.ports={'port0':'','port1':'COM6','port2':'COM21'}defconnect(self,databearport,hardware_settings):'''Perform any hardware configuration and returnhardware port for use by sensor.connect method'''#A windows examplereturnself.ports[databearport]Sensor Interface (V1.2)Recommended script naming convention: manufacturerModel.pyClass name must be 'dbsensor'Inherit sensor base classclassdbsensor(sensors.Sensor):'''Overwrite base class attributes to makesensor specific. Overwriting measurementsis mandatory, others are optional.'''measurements=['measure1','measure2']def__init__(self,name,sn,address):'''Create a new simulator- Call base class init- Override base data structure'''super().__init__(name,sn,address)#Initialize a counterself.counter=0defconnect(self,port):'''Set up connection to hardwareport - port returned by driver'''defmeasure(self):'''Override base method and definehow sensor makes a measurement.Store measurement inself.data[<measurement name>].append(datetime,value)'''passBus Sensor (V0)A bus sensor should inherit from the BusSensor base class.Provide three methods:connect - initialize any communication objectsstartMeasure - process for triggering sensor to measurereadMeasure - process for reading measurement after some delay