raspiSensors 2019.3.26
A series of convenience functions for Raspbery PI sensors
License: MIT
Keywords: Raspberry PI,Sensor,Robots

# Raspberry Pi Sensors

This is a Python 3 package that enables Raspberry Pi to read various sensors .It has been tested on Python 3.5/Raspbian (stretch).
Supported devices include:

* HCSR04 ultrasonic sensor
* PCA9685 Adafruit 16-channel 12 Bit PWM Driver
* BMP280 Barometer
* Triple Axis Magnetometer QMC5883L 
* AS3935 lightning sensor MOD-1016 embedded adventures


### REQUIREMENTS


1. adafruit-circuitpython-servokit

### Installation

1. From source  (incl. examples, fritzing and ebooks)
   
 ```sh

       git clone https://github.com/hanshof/rpiSensors.git
       cd rpiSensors
       python install setup.py
 ```
       
2. PIP

 ```sh

     pip install raspiSensors
     
 ```






### HCSR04 ultrasonic sensor



> This is the HC-SR04 ultrasonic distance sensor. 
> This economical sensor provides 2cm to 400cm 
> of non-contact measurement functionality with a ranging accuracy 
> that can reach up to 3mm. 
> Each HC-SR04 module includes an ultrasonic transmitter
>, a receiver and a control circuit.

> There are only four pins that you need to worry about on the HC-SR04: 
> VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground). 
> You will find this sensor very easy to set up and use for your next range-finding project!

Example:

  ```python

    from raspiSensors import hcsr04 as HCSR04
    ultrasonic = HCSR04(trigger_pin = 21, echo_pin = 20)
    print(ultrasonic.distance())

    returns distance in cm
    
  ```
    
### PCA9685 Adafruit 16-channel 12 Bit PWM Driver


> Using only two pins, control 16 free-running PWM outputs! 
> You can even chain up 62 breakouts to control up to 992 PWM outputs (which we would really like to see since it would be glorious)
> It's an i2c-controlled PWM driver with a built in clock. That means that, unlike the TLC5940 family, you do not need to continuously send it signal tying up your microcontroller, its completely free running!
> It is 5V compliant, which means you can control it from a 3.3V microcontroller and still safely drive up to 6V outputs (this is good for when you want to control white or blue LEDs with 3.4+ forward voltages)
> 6 address select pins so you can wire up to 62 of these on a single i2c bus, a total of 992 outputs - that's a lot of servos or LEDs
> Adjustable frequency PWM up to about 1.6 KHz
> 12-bit resolution for each output - for servos, that means about 4us resolution at 60Hz update rate
> Configurable push-pull or open-drain output
> Output enable pin to quickly disable all the outputs

Example:

  ```python
  
      from raspiSensors import pca9685 as PCA9685
      servos = PCA9685(channels=16)
      
      servos.kit.servo[0].angle = 90
  ```
      
      
      
### BMP280 Barometer

  
> This is a Barometer Pressure Sensor module
> It could measure the pressure and temperature.
> This program depend on BMP280.py writted by Adafruit. 

* #### [Example](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/examples/bmp280_test.py)
* #### [Datasheet](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/datasheet/BST-BMP280-DS001-11.pdf)
* #### [Ebook](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/ebooks/BMP280.pdf)  
* #### [Fritzing](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/fritzing/Barometer_BMP280_Steckplatine.png)


### Triple Axis Magnetometer QMC5883L 


> Magnetometer QMC5883L is used for measuring the direction and magnitude of the Earth’s magnetic field. It is used for low cost compassing and magnetometry.
> It measures the Earth’s magnetic field value along the X, Y and Z axes from milli-gauss to 8 gauss.
> It can be used to find the direction of heading of the device.
> It uses I2C protocol for communication with microcontroller.

* #### [Example](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/examples/qmc5883l_test.py)


### AS3935 lightning sensor MOD-1016 embedded adventures

> The MOD1016 is a lightning sensor based on the AMS3935. It allows you to detect 
> storms up to 40km away.

* #### [Example](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/examples/as3935_test.py)
* #### [Datasheet MOD-1016](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/datasheet/MOD-1016_hw_v8_doc_v4.pdf)
* #### [Datasheet AS3935](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/datasheet/AS3935_datasheet.pdf)
* #### [Ebook](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/ebooks/MOD1016.pdf)
* #### [Fritzing](https://github.com/hanshof/raspiSensors/blob/master/raspiSensors/fritzing/MOD1016-AS3935.png)