Git Product home page Git Product logo

pozyx-python-library's Introduction

Pozyx-Python-library

A Python library to work with the pozyx indoor positioning system over USB.

This library works with both Python 2 and 3.

Prerequisites

  • Download and install Python. On Windows, make your life easier and make sure Python is in your PATH. A recommended install is therefore the Anaconda Suite by Continuum. If you're going to follow the tutorials, you'll need to install Python 3 for the python-osc support.
  • Install the PySerial package. If you have pip installed, you can do this by writing pip install pyserial in your command line interface (cmd on Windows).
  • Windows only install ST's virtual COM driver. After running this installer, please run the correct driver package for your system, located in C:\Program Files (x86)\STMicroelectronics\Software\Virtual comport driver. Choose Win7 if you run Windows 7 or older. Choose Win8 for Windows 8 or newer. Run dpinst_amd64.exe on a 64-bit system, dpinst_x86.exe on a 32-bit system.

Installing this package

Just run pip install pypozyx

PyPozyx is now installed. To check whether it is: if you followed all the steps correctly, and know which port your Pozyx is on, the following code should work:

from pypozyx import PozyxSerial
port = 'COMX' # on UNIX systems this will be '/dev/ttyACMX'
p = PozyxSerial(port)

If your port is correct and the serial connection to the Pozyx isn't used by other software, this will run without any errors.

But! How do I know what port my Pozyx is on?

  • You can see the COM ports on your system easily using Python with: python -c "from pypozyx import *;list_serial_ports()"

  • NEW You can quickly find whether there's a recognized Pozyx device using: python -c "from pypozyx import *;print(get_first_pozyx_serial_port())"

Documentation and examples

You can find the Python tutorials on our site: https://docs.pozyx.io/creator/latest/python.

Documentation for the Python library can be found here: https://pypozyx.readthedocs.io.

  • This was originally a port of the Pozyx's Arduino library, so most of the Arduino Library Documentation is transformable to this. The major difference is that you don't ever again need to pass along the length of the data you're reading/writing. This is taken care of by the library through the Data and SingleRegister classes like so:
whoami = SingleRegister()
pozyx.regRead(POZYX_WHO_AM_I, whoami) # which is pozyx.getWhoAmI(whoami)
  • SingleRegister(value=0, size=1, signed=1) is basically an instance Data([0], 'B'), which functions as a single uint8_t. If you want to make your custom data, for a single register you can adapt the size and signed parameters, and for larger data structures you can use your own data formats. Data([0]*3, 'BHI'), for example, creates a structure of 1 uint8_t, uint16_t and uint32_t. Writing and reading data using this example as a parameter will automatically read/write 7 bytes worth of data. To specify your own data formats, check the struct package documentation for Python 3 or Python 2.

  • A more pythonic library would be nice, but isn't in the works.

More usage examples can be found in the useful and tutorials folders of the repository.

pozyx-python-library's People

Contributors

jspaletavert avatar laurentva avatar michieldwitte avatar muldec avatar samuelvdv avatar sapphire-arches avatar sven-bock avatar willowblade avatar

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.