Giter Club home page Giter Club logo

bluetooth-python-sample's Introduction

Bluetooth-Python-Sample

Different sample to manage bluetooth for raspberry in Python.

Build

Here you will find the procedure to manage the sample files and run it directly in your environnement. The target environnement tested and available are:

Raspberry-Pi 3B+

To execute the different python sample provide by ELA Bluetooth for the bluetooth, you need to install the different environnement or package :

  • Python 3.7
  • bluepy

First of all be sure that your raspberry is up to date by executing the following commands:

   sudo apt-get update

Then install python 3.7; you may need to use pip3:

   sudo apt-get install python3-pip libglib2.0-dev
   sudo pip3 install bluepy

Samples

This repository contains different sample. Accordings to your needs, you can try each files with python to perform the following functions:

elaScanSample.py

This sample use the scanner during a fix period (10 seconds) and display results as raw payload from Bluetooth Advertising.

Run the command :

   sudo python3 elaScanSample.py

elaScanInterpretedDataSample.py

This sample use the scanner during a fix period (10 seconds) and display results as interpreted sensor data from Bluetooth Advertising.

Run the command :

   sudo python3 elaScanInterpretedDataSample.py

elaConnectSample.py

This sample use bluetooth and bluepy to connect to an ELA Innovation tag and send command.

Run the command :

   sudo python3 elaConnectSample.py <mac_address> <ela_tag_command>

Input parameters description:

  1st parameter is mac address: enter a string to specify the tag's mag address. This information is available by scanning and in the Bluetooth Advertisement

  2nd parameter is command  : enter a string to specify the command / functionnlaity available for an ELA Innovation Bluetooth Tag

bluetooth_scanner_sample.py

To use the scanner and record data into a csv file, you can use the script bluetooth_scanner_sample.py. This program allows you to record for a defined period and filter to flush the result into a csv file.

Run the command :

   sudo python3 bluetooth_scanner_sample.py <timescan> <file>.csv <"filters">

Input parameters description:

  1st parameter is timescan(s): enter a float number to determine the time requiered to scan

  2nd parameter is file.csv   : enter a string; that will be your created file's name. Don't forget the '.csv' extension

  3rd parameter are filters   : enter a string; that will determinate each word use to filter our 'file.csv' data writed.
                                You must write your differente filters like this: "filter1;filter2;filter3;..."
                                This is a contain filter. You will get only data contain your filter word.
                                **The filter algorithm match only if the filter is contained in Bluetooth Local Name**
                                
 You must to enter the both first parameters. For the 3rd parameter (filters) you have to enter "" if you don't want filter.

elaDownloadDataLogger.py

This sample use bluetooth and bluepy to connect to an ELA Innovation tag and send command for Data Logger EN 12830. You can Start, Read Data logger EN 12830 (and flush into a text file), and Stop.

Run the command :

   sudo python3 elaDownloadDataLogger.py <mac_address> <password> [OPTION]

Input parameters description:

  1st parameter is mac address: enter a string to specify the tag's mag address. This information is available by scanning and in the Bluetooth Advertisement

  2nd parameter is password  : enter the Bluetooth password configured for you tag to allow EN12830 operations 

  3rd parameter are option  : for the options associated to the fonction
           -a, --start => Start the data logger. Start recording all the data according to the loggin period configured in the tag
           -r <file>, --read <file> => Read the content of data logger and export it on a output file
           -o, --stop => Stop the data logger. Stop recording data into the tag

bluetooth-python-sample's People

Contributors

kberdague avatar matbuster avatar elainnovation avatar kaplacat avatar

Stargazers

CxuLo avatar Jonathan Hassall avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bluetooth-python-sample's Issues

20 byte limit on receiving and sending on RPI

Hello,

My company asked me to test the ELA Blue PUCK T EN12830 for a project. I am using a raspberry pi 4 to try and connect to the device and read its data.

I used your python examples and they seem to work, except when command or response is more then 20 bytes.
When I need to receive a notification that is longer then 20 bytes, the message is just cut off. When I need to send more then 20 bytes, the message is never aknowleged.

I tried to manually install the bluetooth driver (BlueZ) and bluePY, but this did not change anything.

Is this something you also came across?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.