kmchord9 / grove.py

Python library for Seeedstudio Grove devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

grove.py

Build Status

Python library for Seeedstudio Grove Devices on embeded Linux platform, especially good on below platforms:



Architecture

To operate grove sensors, the grove.py depends on the smbus2 hardware interface library.




Installation

For beginner or library user only, please install with online method.
For developer or advanced user, please install dependencies and then install grove.py with source code.

Caution

Here is the compatibility of grove.py with Python2 and Python3 on each releases of Raspbian/Raspberry Pi OS.

Raspberry Pi OS Releases grove.py for Python2 grove.py for Python3
9 (Stretch)
10 (Buster) until 2020-08-20
10 (Buster) after 2020-08-20 ×
11 (Bullseye) ×
12 (bookworm) ×

Because Python2 is obsolete and APT repository does not provide python-pip, so the Raspberry Pi OS releases which after 10 (Buster) 2020-08-20 cannot use Online install command. We also recommend using Python3 to all the users and developers.

Install grove.py

git clone https://github.com/kmchord9/grove.py.git
cd grove.py
python -m venv vgrove
source vgrove/bin/activate
pip install .



Usage

Grove Base Hat for Raspberry Piのピン配置は上記の画像のようになっており、
センサーの仕様によってDigital,Analog,I2C,PWM,UARTの接続先が異なるので注意する。

温度センサー(DHT22)

接続先 Digital
image
Gravity- DHT22 温湿度センサ — スイッチサイエンス

依存ライブラリのインストール

sudo apt-get install libgpiod2
pip install adafruit-circuitpython-dht

実行方法

cd grove.py/code
python grove_temperature_dht22.py 18

D18に接続した場合には引数に18を入れる

距離センサ

接続先 Digital
image
GROVE - 超音波距離センサモジュール — スイッチサイエンス

依存ライブラリのインストール


実行方法

cd grove.py/code
python grove_ultrasonic_ranger.py 18

D18に接続した場合には引数に18を入れる

振動センサ

接続先 Digital
image
GROVE - 振動センサ(SW-420) — スイッチサイエンス

依存ライブラリのインストール

pip install pigpio
pip install gpiozero

実行方法

cd grove.py/code
python grove_vibration_sw420.py 18

D18に接続した場合には引数に18を入れる

6軸加速度・ジャイロセンサ(BMI088)

接続先 I2C
image
GROVE - 6軸加速度・ジャイロセンサ(BMI088) — スイッチサイエンス

依存ライブラリのインストール

sudo apt-get install debhelper dh-make debmake devscripts fakeroot
cd ~
git clone https://github.com/turmary/bmi088-python.git
cd bmi088-python
git submodule init
git submodule update
./tools/packaging_deb.sh
cd ~/bmi088-python/deobj
sudo dpkg -i libbmi088_0.0.2-1_arm64.deb

bmi088-python/ at master · turmary/bmi088-python

実行方法

cd grove.py/code
python grove_6_axis_accel_gyro_bmi088.py

音センサ

接続先 Analog
image

Gravity- DHT22 温湿度センサ — スイッチサイエンス

依存ライブラリのインストール


実行方法

cd grove.py/code
python grove_sound_sensor.py 0

A0に接続した場合には引数に0を入れる



API Documentation

click here

how to update me



Contribution

Check list for adding a new grove device, for simple, take grove_led as a example.

  • Add a Class in the python source file, and export with __all__ =
  • Code sytle PEP8 is recommanded
  • The python source could run directly with python <file> and python3 <file>
  • Add demo code at the near top of source file
  • The demo code could run directly with someone python/python3 IDE.
  • Add document to class and it's member and show the result by refering to API document
  • Add a command item in setup.py console_scripts list, take effect by install again
  • Add a item to command table in Usage Doc
  • If the command need argument but not specified, please list available arguments.
  • If specified invalid argument, also output usage document then exit.

About

Python library for Seeedstudio Grove devices

License:MIT License


Languages

Language:Python 96.7%Language:Makefile 1.7%Language:Shell 1.6%