Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

Keine Erläuterungen gefunden.

import  RPi.GPIO as  GPIO


class HvcSetGPIO:
    
    def  __init__(self):
        """
        Connect your actuators to specific GPIO pins.
        """
        #Relays  links nach rechts: 27, 22, 23, 24, 25
        self.ActPins={}
        self.ActPins['solar'] = 25 #22
        self.ActPins['oven']  = 24 #23
        self.ActPins['pump']  = 23
        #self.ActPins['serv']  = 24
        #self.ActPins['door']  = 25

        
    def  setMode(self):
        """
        At startup, you need to set the mode once.
        """
        #Setup GPIO
        GPIO.setmode(GPIO.BCM)
        message = "HvcSetGPIO.setMode: \n"
        actuators={}
        for  pin in self.ActPins:
            GPIO.setup(self.ActPins[pin], GPIO.OUT)
            message = message + "GPIO "+pin+":\t"+str(self.ActPins[pin])+"\t=> OUT \n"
            actuators[pin] = 0

        return actuators,message

    
    def  set(self,actuators):
        """
        Set the GPIO according to the actuator settings,
        The actuators are expected to be in the range [0:1],
        where values > 0.5 are assumed to be ON.
        """
        for  pin in self.ActPins:
            if actuators[pin]>0.0:
                GPIO.output(self.ActPins[pin], GPIO.HIGH)
            else:
                GPIO.output(self.ActPins[pin], GPIO.LOW)
        return

"""
For testing, toggle some relays and hear the click.
Secondly, the status of all actuator pins is reported.
"""
if __name__ == "__main__":
    import  time
    myIO = HvcSetGPIO()
    actuators,message = myIO.setMode()
    print(message)
    actuators['oven']=1
    #myIO.set(actuators)
    time.sleep(1)
    actuators['oven']=0
    #myIO.set(actuators)
    #check status of GPIOS
    for  pin in myIO.ActPins:
        GPIO.output(myIO.ActPins[pin], GPIO.HIGH)
        foo = GPIO.input(myIO.ActPins[pin])
        print(pin,foo)

python

1HvcControl.py
2HvcHCSR04ultrasonic.py
3HvcMain.py
4HvcMotorDriver.py
5HvcOneWire.py
6HvcOperationMode.py
7HvcRaw2phys.py
8HvcReadSPI.py
9HvcSendI2C.py
10HvcSetGPIO.py
11HvcTables.py
12HvcWeather.py
13makeDoc.py

php

1HV_Admin_Login.php
2HV_colorMap.php
3HV_composeH2Oplot.php
4HV_config.php
5HV_H2Olevel.php
6HV_readOperationState.php
7HV_restart.php
8HV_serviceLog.php
9HV_setParameters.php
10HV_showHouse.php
11HV_showLog.php
12HV_showWeatherForecast.php
13HV_TempCal.php
14index.php
15readFilenames.php
16readNamedData.php

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