Skip to content

Python module to interface with the Qwiic Proximity board

License

Notifications You must be signed in to change notification settings

sparkfun/Qwiic_Proximity_Py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qwiic_Proximity_Py

follow on Twitter

Python module to interface with the Qwiic Proximity board.

This package is a port of the SparkFun VCNL4040 Proximity Sensor Arduino Library

This package can be used in conjunction with the overall SparkFun qwiic Python Package

New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Contents

Supported Platforms

The qwiic Proximity Python package current supports the following platforms:

Dependencies

This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py

Documentation

The SparkFun qwiic Proximity module documentation is hosted at ReadTheDocs

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-proximity package. On systems that support PyPi installation via pip, this library is installed using the following commands

For all users (note: the user must have sudo privileges):

sudo pip install sparkfun-qwiic-proximity

For the current user:

pip install sparkfun-qwiic-proximity

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line:

python setup.py install

To build a package for use with pip:

python setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.

cd dist
pip install sparkfun_qwiic_proximity-<version>.tar.gz

Example Use

See the examples directory for more detailed use examples.

import qwiic_proximity
import time
import sys

def runExample():

	print("\nSparkFun Proximity Sensor VCN4040 Example 1\n")
	oProx = qwiic_proximity.QwiicProximity()

	if oProx.isConnected() == False:
		print("The Qwiic Proximity device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	oProx.begin()

	while True:
		proxValue = oProx.getProximity()
		print("Proximity Value: %d" % proxValue)
		time.sleep(.4)
    
runExample()

SparkFun - Start Something