5

I was trying to run a motor using the Pi. It was working fine before when I was executing using a Python script.

Later I installed WiringPi and tried to execute the GPIO using shell script and it worked once.

After that nothing was working, neither the python scripts nor the shell scripts.

In the Python scripts I had added GPIO.cleanup() but still no use. But when I am executing the python script, I am getting the following warning message:

RuntimeWarning: This channel already in use, continuing anyway

Is there any way to reset the GPIO to its normal state again?

Also I had tried adding try and final statements in my Python script but still no use.

3

It is a warning only and may safely be ignored.

The warning is telling you that another program told Linux it wanted to use that gpio. It's all to do with Linux "exporting" the gpio to be visible to a user, so an ordinary user can read and write the gpio. The external program should have "unexported" the gpio when it was finished.

The warning should not prevent you from reading and writing to gpios.

1

I found the completed solution for your issue: RPi.GPIO basics 3 – How to Exit GPIO programs cleanly, avoid warnings and protect your Pi

I see this is the best way to other answers.

Basically you have to call cleanup.

import RPi.GPIO as GPIO 
# do stuff …
# … left blank for the reader to fill in …
# … then perform a clean exit:
GPIO.cleanup()
  • 1
    Welcome! Please take the tour and visit the helpcenter. Whilst this may theoretically answer the question, it is preferable to include the essential parts of the answer here, and provide the link for reference. In fact we're enforcing this policy: please edit so that the answer stands on its own should the link break in the future. If it is not edited within 48 hours it will be converted to Community Wiki. – Jacobm001 Aug 1 '17 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.