Hamburger Hamburger

Heating and Ventilation Control

/HvcSendI2C

Keine Erläuterungen gefunden.

"""
PWM to control Ebmpapst ventilators in Paul Thermos 200
Dr. Arne Jachens
2020-06-20
"""

#import  smbus
from smbus2 import  SMBus

class HvcSendI2C:
    def  __init__(self):
        self.bus = SMBus(1)              # 0 = /dev/i2c-0 , 1 = /dev/i2c-1
        self.ADDRESS  = 96 #0x60         # address on bus, check: i2cdetect -y 1
        self.REG_MODE = 17 #0x11         # auto increment flag, output logics with pull up resistors


    
    def  setPWM(self,level):
        """
        Set the ventilation level [0:1], where 1 is maximal,
        here both ventilation levels are set equal.
        """

        #level percent to integer
        levelInt = []
        for  i,lev in enumerate(level):
            levelInt.append(int( 255*(1.0-lev) ))

        #compose message bytes
        values=[]
        values.append( 00 )     # frequency of PWM0
        values.append(levelInt[0]) # PWM0
        values.append( 00 )     # frequency of PWM1
        values.append(levelInt[1]) # PWM1
        values.append( 14 )     # xxxx1110 set output0 to PWM0 and output1 to PWM1

        #send message
        self.bus.write_i2c_block_data(self.ADDRESS, self.REG_MODE, values)


"""
for  testing
"""
if __name__ == "__main__":
    I2C = HvcSendI2C()
    level = [0.5, 0.5]
    I2C.setPWM(level)

python

1/HvcLightControl.py
2/HvcHCSR04ultrasonic.py
3/HvcPV.py
4/HvcMotorDriver.py
5/HvcRollerShutter.py
6/manGenMqttMap.py
7/HvcReadSPI.py
8/HvcMqtt.py
9/HvcTables.py
10/HvcMain.py
11/HvcSetGPIO.py
12/HvcWifiRelay.py
13/HvcOperationMode.py
14/HvcControl.py
15/HvcRaw2phys.py
16/HvcWeather.py
17/HvcOneWire.py
18/makeDoc.py
19/HvcFronius.py
20/EnergyManager.py
21/HvcSendI2C.py

php

1/HV_colorMap.php
2/HV_Admin_Login.php
3/HV_readOperationState.php
4/HV_setParameters.php
5/HV_config.php
6/EM_handleJSON.php
7/index.php
8/readFilenames.php
9/HV_restart.php
10/HV_moveGate.php
11/HV_showLog.php
12/HV_RollerShutter.php
13/EM_editParameter.php
14/HV_serviceLog.php
15/HV_H2Olevel.php
16/HV_TempCal.php
17/HV_Fronius.php
18/EM_plot.php
19/readNamedData.php
20/HV_composeH2Oplot.php
21/HVdoc.php
22/HV_showWeatherForecast.php
23/HV_showHouse.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.