|
Edited by antares at 2019-5-3 07:17
Hello !
I'm sorry for my bad English, i'm French and i speak very bad in English.
I have an Orange Pi Zero and i would like to turn it into a connected object (IOT). I am therfore looking to drive a relays, read DHT22 probes, as well as communicate on the I2C bus and communicate with an MQTT broker.
To date, i manage to fly the map relays, communicate in mqtt with paho.mqtt, i realized a program that retrieves messages and runs different threads for my relays (tempo, etc...)
i'm having a problem with the GPIO port, i'm using OPi.GPIO for Python
- import OPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BOARD)
- GPIO.setwarnings(False)
- pin = 10
- GPIO.setup (pin, GPIO.OUT, initial=GPIO.HIGH)
- try:
- While True:
- print("High")
- GPIO.output(pin, GPIO.HIGH)
- time.sleep(1)
- print("Low")
- GPIO.output(pin, GPIO.LOW)
- time.sleep(1)
- Except KeyboardInterrupt:
- print("Exit")
- exit()
Copy code the program working and i press CTRL + C for exit and i watch in /sys/class/gpio
- ls /sys/class/gpio
- export gpio199 gpiochip0 gpiochip352 unexport
Copy code the pin number 10 is PG07 in setmode BOARd (7-1)*32+7= 199 so gpio199 is my export.
If i comment the line #GPIO.setup (pin, GPIO.OUT, initial=GPIO.HIGH) in my program and i run it
i have a run time error Channel 10 is not configured.
Whereas the export has alreday been done, if i export my gpio into the /etc/rc.local for exportation on starting the pi.
My result is the same
Also, the parameter initial=GPIO.HIGH or GPIO.LOW not working. My gpio is always with a lower level = 3.3V and higher level = 0V
My relay card is higer level trigger so i'm contrain to used a GPIO.LOW for working relay and used GPIO.HIGH for shutdown.
- sudo nano /sys/class/gpio/gpio199/active_low
Copy code always contains 0 regardless of the initial setting (GPIO.LOW or GPIO.HIGH).
if i make
- echo 1 > /sys/class/gpio/gpio199/active_low
- echo 0 > /sys/class/gpio/gpio199/value (relay off)
- echo 1 > /sys/class/gpio/gpio199/value (relay on)
Copy code it's work outside the program.
i don't understand.
thanks for help.
I'm sorry for my english
|
|