Jump to content

processor

Members
  • Posts

    3
  • Joined

  • Last visited

  1. thanks your answer i changed gpio like # initialize GPIO temPin = port.PA13 trigPin = port.PA14 when run program , say error root@orangepizero:-/orangepi_PC_gpio_py113/MiT22-Python-library-Orange-PI# sudo python dht3 .py File ''dht3 . py a , line 32 print ( ' error ! ) Synt axError : EOL while scanning string literal edit line 32 ('error!') and then root@orangepizero:-/DHT22-master# sudo python dht3.py Last valid input: 2018-10-28 20:52:24.470819 Celsius: 26.5 C Fahrenheit: 79.7 F Humidity: 45.2 %% Traceback (most recent call last): File 'dht3.py', line 38, in <module> if celToFar < 75: NameError: name 'celToFar' is not defined i have question what's trigPin and what to do this pin?
  2. i dont have any error the output is nothing and "time.sleep(1)" is runs. the code is here https://github.com/ionutpi/DHT22-Python-library-Orange-PI defined in >>dht22.py in class DHT22 import time from pyA20.gpio import gpio from pyA20.gpio import port #import RPi class DHT22Result: 'DHT22 sensor result returned by DHT22.read() method' ERR_NO_ERROR = 0 ERR_MISSING_DATA = 1 ERR_CRC = 2 error_code = ERR_NO_ERROR temperature = -1 humidity = -1 def __init__(self, error_code, temperature, humidity): self.error_code = error_code self.temperature = temperature self.humidity = humidity def is_valid(self): return self.error_code == DHT22Result.ERR_NO_ERROR class DHT22: 'DHT22 sensor reader class for Raspberry' __pin = 0 def __init__(self, pin): self.__pin = pin def read(self): gpio.setcfg(self.__pin, gpio.OUTPUT) # send initial high self.__send_and_sleep(gpio.HIGH, 0.05) # pull down to low self.__send_and_sleep(gpio.LOW, 0.02) # change to input using pull up #gpio.setcfg(self.__pin, gpio.INPUT, gpio.PULLUP) gpio.setcfg(self.__pin, gpio.INPUT) gpio.pullup(self.__pin, gpio.PULLUP) # collect data into an array data = self.__collect_input() # parse lengths of all data pull up periods pull_up_lengths = self.__parse_data_pull_up_lengths(data) # if bit count mismatch, return error (4 byte data + 1 byte checksum) if len(pull_up_lengths) != 40: return DHT22Result(DHT22Result.ERR_MISSING_DATA, 0, 0) & ....
  3. hi freinds i'm trying to use a dht22 to read temperature and humidity , with Armbian 5.65 (stretch) 4.14.78-sunxi and orenge pi zero orange pi state like this /etc/modules-load.d/modules.conf #gpio sunxi #gc2035 wire wl-sunxi wl-gpio wl-therm #sunxi-cir #xradio_wlan g_serial #xradio_wlan i2c -dev /etc/default/cpufrequtils ENABLE=true MIN SPEED=6000000 MAX_SPEED=1200000 GOVERNOR=interactive /boot/armbianEnv.txt verbosity=1 logo=disabled console=both disp_mode=1920x1080p60 overlay prefix=sun8i-h3 overlays=usbhost2 usbhost3 12c0 wl-gpio rootdev=WID=55cee3e8-79d6-4dd3-ab14-99274fo626cb rootfstype=ext4 param wl_pin=PA10 param wl_pin int_pullup=1 usbstorageguirks=0x2537:0x1066:u,0x2537:0x1068:u and im trying with this code https://www.piprojects.xyz/temperature-sensor-orange-pi-python-code/ and https://community.home-assistant.io/t/extend-dht-sensor-for-orange-pi/39838 from pyA20.gpio import gpio from pyA20.gpio import port #import RPi.GPIO as GPIO import dht22 import time import datetime # initialize GPIO #gpio.setwarnings(False) #gpio.setmode(GPIO.BCM) PIN2 = port.PA6 gpio.init() #gpio.cleanup() # read data using pin 14 instance = dht22.DHT22(pin=PIN2) while True: result = instance.read() if result.is_valid(): print("Last valid input: " + str(datetime.datetime.now())) print("Temperature: %.2f C" % result.temperature) print("Humidity: %.2f %%" % result.humidity) time.sleep(1) dht22 work correct with raspberry and rasbian also test ds18b20 with orange pi and work good but i need humidity sensor i dont know what's the problem??!! Thanks for any help
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines