GreenPonik WaterPump Driver
README

Quality Gate Status Maintainability Rating

Lines of Code Duplicated Lines (%)

Reliability Rating Security Rating Vulnerabilities

Upload Python Package

## GreenPonik_WaterPump_Driver.py Library for Raspberry pi

This is the python side driver to manage GreenPonik WaterPump devices

Table of Contents

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
from GreenPonik_WaterPump_Driver import i2c_scanner, read_byte_data

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
"""
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
"""
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