GreenPonik WaterPump i2c driver
Reason this release was yanked:
bugs
Project description
GreenPonik_WaterPump_Driver.py Library for Raspberry pi
This is the python side driver to manage GreenPonik WaterPump devices
! Only tested on Raspberry Pi 3 A+ !
Table of Contents
- GreenPonik_WaterPump_Driver.py Library for Raspberry pi
- Table of Contents
- Installation
- Methods
- Examples
- Credits
Installation
> git clone https://github.com/GreenPonik/GreenPonik_WaterPump_Driver.git
cd GreenPonik_WaterPump_Driver
pip3 install -r requirements.txt
or
> pip3 install greenponik-waterpump-driver
import GreenPonik_WaterPump_Driver
Methods
def i2c_scanner():
"""
@brief i2c Scanner use to return the list of all addresses find on the i2c bus
@return list of addresses
"""
def read_byte_data(addr, register):
"""
@brief read byte data from the device
@param addr > byte i2c address of the device
@param register > byte i2c register to read
@return byte
"""
def write_byte_data(addr, register, value):
"""
@brief write byte data on the device
@param addr > byte i2c address of the device
@param register > byte i2c register to write
"""
def read_block_data(addr, register, size = 8):
"""
@brief read block byte data from the device
@param addr > byte i2c address of the device
@param register > byte i2c register to read
@param size > byte size of block read from i2c bus
@return list
"""
def write_block_data(addr, register, data):
"""
@brief write block byte data on the device
@param addr > byte i2c address of the device
@param register > byte i2c register to write
@param data > array of bytes to be send through i2c bus
"""
def pump_run(addr, register, command):
"""
@brief command pump
@param addr > byte i2c address of the pump
@param register > byte i2c register of the pump
@param command > byte order 0x00 = OFF / 0x01 = ON
"""
Example
from time import sleep
from GreenPonik_WaterPump_Driver import i2c_scanner, read_byte_data, read_block_data
if __name__ == "__main__":
try:
while True:
i2c_devices = i2c_scanner()
for device in i2c_devices:
if I2C_DEVICES_TYPE['WATERPUMP'] != read_byte_data(device, I2C_REGISTERS['TYPE']:
raise Exception("Current device is not a WaterPump")
else:
UUID = read_block_data(device, I2C_REGISTERS['UUID'])
print("Device UUID: %s" % UUID)
sleep(0.5)
sleep(2)
except Exception as e:
print("Exception occured", e)
Credits
Write by Mickael Lehoux, from GreenPonik, 2019
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for greenponik-waterpump-driver-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6dab5df30b2f9596c7b25add25429d25e3e070b452b69fb52f68bcb88342867 |
|
MD5 | bf298dc818cd4eca892b7cc2adcacc2f |
|
BLAKE2b-256 | d7409682f0d5d82de80defa44818a5ae43ddd4f3aec85a82eed1e6bdb2b32a4a |
Close
Hashes for greenponik_waterpump_driver-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a7c762a468c6eab2a9fb61f31cf98f9f93e2b3c065f98a8cc6d85090a1d718b |
|
MD5 | 09d7ffeea9b77386fcd03765df9b559f |
|
BLAKE2b-256 | 90803f97fcf2ce87ac827f17a0c26f24acf6a7f432b93200d60c877e6e146b60 |