background image

 

Published: 27.08.2018  

Copyright by Joy-IT 

Combi Sensor 

 

#!/usr/bin/python

 

# coding=utf

-

8

 

  

# Required modules are imported and set up

 

import

 RPi.

GPIO

 

as

 GPIO

 

import

 Adafruit_DHT

 

import

 

time

 

  

# The pause of two seconds between measurements is set here

 

sleeptime 

=

 

2

 

  

# Sensor should be set to Adafruit_DHT.DHT11,

 

# Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302.

 

DHTSensor 

=

 Adafruit_DHT.

DHT11

 

  

# The pin to which the sensor module is connected can be declared here

 

GPIO_Pin 

=

 

23

 

  

print

(

'KY

-

015 Sensortest 

-

 Temperatur und Luftfeuchtigkeit'

)

 

  

try

:

 

    

while

(

1

)

:

 

        

# Measurement is started and the result is written to the corresponding vari-

ables

 

 

        Luftfeuchte

,

 Temperatur 

=

 Adafruit_DHT.

read_retry(

DHTSensor

,

 GPIO_Pin

)

 

  

        

print

(

"

-----------------------------------------------------------------

"

)

 

        

if

 Luftfeuchte 

is

 

not

 

None

 

and

 Temperatur 

is

 

not

 

None

:

 

  

            

# Das gemessene Ergebnis wird in der Konsole ausgegeben

 

            

print

(

'Temperatur = {0:0.1f}°C  | rel. Luftfeuchtigkeit = 

{1:0.1f}%'

.

format(

Temperatur

,

 Luftfeuchte

))

 

  

        

# Because the Raspberry Pi is disadvantaged for real

-

time applications due to 

the Linux operating system,

 

        

# communication may fail due to timing problems.

 

        

# In this case an error message is displayed 

-

 a result should be available 

at the next attempt

 

        

else

:

 

            

print

(

'Fehler beim Auslesen 

-

 Bitte warten auf nächsten Versuch!'

)

 

        

print

(

"

-----------------------------------------------------------------

"

)

 

        

print

(

""

)

 

        

time

.

sleep(

sleeptime

)

 

  

# Cleanup after the program is finished

 

except

 

KeyboardInterrupt

:

 

    GPIO.

cleanup()

 

Содержание Combi Sensor

Страница 1: ...3 Combi Sensor KY 015...

Страница 2: ...ublished 27 08 2018 Copyright by Joy IT 2 Combi Sensor 1 Overview 2 Pin Assignment 3 Code Example Arduino 4 Code Example Raspberry Pi 5 Information and take back obligations 6 Support TABLE OF CONTENT...

Страница 3: ...lease do not hesitate to contact us Please note that the sensor only provides a new measurement result every 2 seconds It is designed for long term recordings 1 OVERVIEW Chipset DHT11 Communication pr...

Страница 4: ...ernatively this is also included in the download package You can download the code example here or copy and paste the following sections 3 CODE EXAMPLE ARDUINO Adafruit_DHT Library is inserted include...

Страница 5: ...tected an error message is displayed here if isnan h isnan t Serial println Fehler beim Auslesen des Sensors return Output to the serial console Serial println Serial print Luftfeuchtigkeit Serial pri...

Страница 6: ...er the following commands Use the following command to download the latest version of the Adafruit_DHT Library Now install the library You can download the code example here Alternatively you can copy...

Страница 7: ...and the result is written to the corresponding vari ables Luftfeuchte Temperatur Adafruit_DHT read_retry DHTSensor GPIO_Pin print if Luftfeuchte is not None and Temperatur is not None Das gemessene Er...

Страница 8: ...free of charge when purchasing a new device Small appliances where no external dimensions are larger than 25 cm can be delivered in normal household quantities irrespective of the purchase of a new ap...

Страница 9: ...any questions left or if you encounter any problems please feel free to contact us by mail phone or by our ticket system on our website E Mail service joy it net Ticket System http support joy it net...

Отзывы: