Skip to content

GreenPonik/GreenPonik_EC_Python_industrial_probes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GreenPonik_EC.py Library for Raspberry pi


This is the sample code for 1/2 EC industrial probes

Table of Contents

Installation

Dependencies:

DFRobot_ADS1115

Call modules:

from DFRobot_ADS1115 import ADS1115
from GreenPonik_EC import GreenPonik_EC

or run example directly

$> python3 example/EC_Read.py

Methods

"""
@brief Init The Analog EC Sensor
"""
def begin(self):

"""
@brief Convert voltage to EC with temperature compensation
"""
def readEC(self,voltage,temperature):

"""
@brief Calibrate the calibration data
"""
def calibration(self,voltage,temperature):

"""
@brief Reset the calibration data to default value
"""
def reset(self):

Examples

EC read => EC_Read.py in libs folder

git clone https://github.com/DFRobot/DFRobot_ADS1115.git

import time
import sys
sys.path.insert(0,'../libs/DFRobot_ADS1115/RaspberryPi/Python/')
sys.path.insert(0,'../src/')


from GreenPonik_EC import GreenPonik_EC
from DFRobot_ADS1115 import ADS1115

ADS1115_REG_CONFIG_PGA_6_144V = 0x00  # 6.144V range = Gain 2/3
ADS1115_REG_CONFIG_PGA_4_096V = 0x02  # 4.096V range = Gain 1
ADS1115_REG_CONFIG_PGA_2_048V = 0x04  # 2.048V range = Gain 2 (default)
ADS1115_REG_CONFIG_PGA_1_024V = 0x06  # 1.024V range = Gain 4
ADS1115_REG_CONFIG_PGA_0_512V = 0x08  # 0.512V range = Gain 8
ADS1115_REG_CONFIG_PGA_0_256V = 0x0A  # 0.256V range = Gain 16

ads1115 = ADS1115()
ec = GreenPonik_EC()
ec.begin()

def read_ec():
    global ads1115
    global ec
    temperature = 25 # or make your own temperature read method
    # Set the IIC address
    ads1115.setAddr_ADS1115(0x48)
    # Sets the gain and input voltage range.
    ads1115.setGain(ADS1115_REG_CONFIG_PGA_6_144V)
    # Get the Digital Value of Analog of selected channel
    adc0 = ads1115.readVoltage(0)
    # Convert voltage to EC with temperature compensation
    EC = ec.readEC(adc0['r'], temperature)
    print("Temperature:%.1f ^C EC:%.3f ms/cm " % (temperature, EC))
    return EC


if __name__ == "__main__":
    while True:
        read_ec()
        time.sleep(1)

EC calibration => EC_Calibration.py

in libs folder

git clone https://github.com/DFRobot/DFRobot_ADS1115.git

import time
import sys
sys.path.insert(0,'../libs/DFRobot_ADS1115/RaspberryPi/Python/')
sys.path.insert(0,'../src/')

from DFRobot_ADS1115 import ADS1115
from GreenPonik_EC import GreenPonik_EC

ADS1115_REG_CONFIG_PGA_6_144V = 0x00  # 6.144V range = Gain 2/3
ADS1115_REG_CONFIG_PGA_4_096V = 0x02  # 4.096V range = Gain 1
ADS1115_REG_CONFIG_PGA_2_048V = 0x04  # 2.048V range = Gain 2 (default)
ADS1115_REG_CONFIG_PGA_1_024V = 0x06  # 1.024V range = Gain 4
ADS1115_REG_CONFIG_PGA_0_512V = 0x08  # 0.512V range = Gain 8
ADS1115_REG_CONFIG_PGA_0_256V = 0x0A  # 0.256V range = Gain 16

ads1115 = ADS1115()
ec = GreenPonik_EC()
ec.begin()


def calibration():
    global ads1115
    global ec
    temperature = 25 # or make your own temperature read method
    # Set the IIC address
    ads1115.setAddr_ADS1115(0x48)
    # Sets the gain and input voltage range.
    ads1115.setGain(ADS1115_REG_CONFIG_PGA_6_144V)
    # Get the Digital Value of Analog of selected channel
    adc0 = ads1115.readVoltage(0)
    return ec.calibration(adc0['r'], temperature)


if __name__ == "__main__":
    while True:
        calibration()
        time.sleep(1)

read both pH and EC => PH_EC.py

in libs folder

git clone https://github.com/GreenPonik/GreenPonik_EC_Python_industrial_probres.git

git clone https://github.com/DFRobot/DFRobot_ADS1115.git

import time
import sys
sys.path.insert(0,'../libs/DFRobot_ADS1115/RaspberryPi/Python/')
sys.path.insert(0,'../libs/GreenPonik_PH_Python_industrial_probes/src/')
sys.path.insert(0,'../src/')


ADS1115_REG_CONFIG_PGA_6_144V        = 0x00 # 6.144V range = Gain 2/3
ADS1115_REG_CONFIG_PGA_4_096V        = 0x02 # 4.096V range = Gain 1
ADS1115_REG_CONFIG_PGA_2_048V        = 0x04 # 2.048V range = Gain 2 (default)
ADS1115_REG_CONFIG_PGA_1_024V        = 0x06 # 1.024V range = Gain 4
ADS1115_REG_CONFIG_PGA_0_512V        = 0x08 # 0.512V range = Gain 8
ADS1115_REG_CONFIG_PGA_0_256V        = 0x0A # 0.256V range = Gain 16

from DFRobot_ADS1115 import ADS1115
from GreenPonik_EC import GreenPonik_EC
from GreenPonik_PH import GreenPonik_PH

ads1115 = ADS1115()
ec      = GreenPonik_EC()
ph      = GreenPonik_PH()

ec.begin()
ph.begin()


def read_ph_ec():
	global ads1115
	global ec
	global ph
	temperature = 25 # or make your own temperature read process
	#Set the IIC address
	ads1115.setAddr_ADS1115(0x48)
	#Sets the gain and input voltage range.
	ads1115.setGain(ADS1115_REG_CONFIG_PGA_6_144V)
	#Get the Digital Value of Analog of selected channel
	adc0 = ads1115.readVoltage(0)
	adc1 = ads1115.readVoltage(1)
	#Convert voltage to EC with temperature compensation
	EC = ec.readEC(adc0['r'],temperature)
	PH = ph.readPH(adc1['r'])
	print("Temperature:%.1f ^C EC:%.2f ms/cm PH:%.2f " %(temperature,EC,PH))
	return temperature, EC, PH


if __name__ == "__main__":
    while True:
        read_ph_ec()
        time.sleep(1)

Credits

Writter by Mickael Lehoux, from GreenPonik, 2019

based on GreenPonik_EC_Python

support us

become a patreon

About

Read EC with industrial probes 1/2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages