Closed vitasam closed 8 years ago
It means that either there's another program running that uses the same GPIO pin, or that the GPIO pin has not been properly closed by a program that used the pin in the past (with GPIO.cleanup()
).
Searching for "this channel is already in use" should yield more results: https://duckduckgo.com/?q=%22This+channel+is+already+in+use%22&ia=web
Please comment again if this issue is not resolved for you :)
Hi, I did reboot the Raspberry - there should not be any program that used the same GPIO, isn't it? I've rebooted the PC and did try to use GPIO.cleanup() in the following code:
from RPLCD import CharLCD
import RPi.GPIO as GPIO
GPIO.cleanup()
lcd = CharLCD()
lcd.write_string(u'Raspberry Pi HD44780')
GPIO.cleanup()
Apparently it did not help:
pi@raspberrypi:~/PythonStuff/LCD16x2 $ sudo python rplcd.py
rplcd.py:4: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead!
GPIO.cleanup()
/usr/local/lib/python2.7/dist-packages/RPLCD/lcd.py:191: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(pin, GPIO.OUT)
I'm not sure. Is the Raspbian installation fresh? Are there other processes running that might access GPIO?
Hi, Raspbian installation was pretty much fresh. And it works Ok e.g. with this script: http://www.raspberrypi-spy.co.uk/2012/08/16x2-lcd-module-control-with-backlight-switch/#comment-192164
Does it only happen the second time you run the script? Do you call lcd.close()
afterwards?
Actually I did not call lcd.close() WIll try. Thanks!
Let me know if it helps!
Yes, sure!
Hi,
Thanks! lcd.close() did help with warnings, following code was running Ok (including one API pin assignment):
pi@raspberrypi:~ $ cat PythonStuff/LCD16x2/rplcd_test.py
from RPLCD import CharLCD
import RPi.GPIO as GPIO
lcd = CharLCD(pin_rs=13)
lcd.write_string(u'Raspberry Pi HD44780')
lcd.close()
pi@raspberrypi:~ $ sudo python PythonStuff/LCD16x2/rplcd_test.py
pi@raspberrypi:~ $
There is some problem with Backlight. I did try this Init, Setup, Teardown example, but got an error:
pi@raspberrypi:~ $ sudo python PythonStuff/LCD16x2/rplcd_test.py
Traceback (most recent call last):
File "PythonStuff/LCD16x2/rplcd_test.py", line 2, in <module>
from RPLCD import CharLCD, BacklightMode
ImportError: cannot import name BacklightMode
Looks like that version wasn't deployed yet.
I just pushed version 0.4.0 to PyPI, can you try with that?
Also, if your project is public, it would be cool if you could send me a link :) Then I could start a list of hardware projects using RPLCD.
Hi, it works now, after I did an update:
pi@raspberrypi:~ $ cat PythonStuff/LCD16x2/rplcd_test.py
from RPLCD import CharLCD, BacklightMode
import time
lcd = CharLCD(pin_rs=13, pin_backlight=10, backlight_enabled=True, backlight_mode=BacklightMode.active_high)
lcd.write_string(u'Raspberry Pi HD44780')
lcd.backlight = True
time.sleep(2)
lcd.backlight = False
lcd.close()
I just started an open project but it was without your library. I will update the project to RPLCD and will send you a link :)
Is it Ok if my project under GPL v 3 license and your code is under MIT?
Yes, MIT licensed code may be included in GPL licensed projects :)
Great that it works now.
Ok, good! By the way what is a best way to map that LCD in to RaspPi? From the GPIO utilization point of view (e.g. to not to occupy SPI bus etc.)?
Do you mean the pin usage? Simply make sure that you don't use the SPI pins. You can give any pin mapping to the constructor of the CharLCD class.
Hi, this is my PreAlpha project, where I've migrated to RPLCD library: https://sourceforge.net/projects/home-controller/
Now display works much more stable :)
Hello,
I have got this code working, why such warning appeared?