kgbplus
Posts: 11
Joined: Mon Dec 05, 2016 1:59 pm
Location: Saint-Petersburg, RU

Gpio pins monitoring and test

Tue Dec 06, 2016 3:11 pm

I've written a little python program to do gpio pins monitor and testing. It is small and doesn't need any external dependencies (additional libraries or other programs). All what you need is Python interpreter (installed in all Linux distros) and my program itself.
Program runs under Linux console and may be started directly with or without GUI or via SSH. Reading of gpio pins state made with gpio events and callback functions, that's why program will detect all of changes within debounce time. The small log window can help you to see when and which pin's state was changed. Also you can set output values and debug your DYI projects this way.

Program can automatically detect Raspberry Pi model (to determine number of gpio pins). List of model's id has been taken from http://elinux.org/RPi_HardwareHistory. If you have rare model - please let me know (and use --gpio_num command line option).

Program is free, so you can modify anything your want. My github repo https://github.com/kgbplus/gpiotest. Look at tiny manual here or start program with --help argument.
Attachments
gpiotest.png
gpiotest.png (7.44 KiB) Viewed 23245 times
Last edited by kgbplus on Tue Dec 06, 2016 4:33 pm, edited 1 time in total.

User avatar
joan
Posts: 15970
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Gpio pins monitoring and test

Tue Dec 06, 2016 4:02 pm

The code is using the RPi.GPIO library. That is both a library and a dependency.

kgbplus
Posts: 11
Joined: Mon Dec 05, 2016 1:59 pm
Location: Saint-Petersburg, RU

Re: Gpio pins monitoring and test

Tue Dec 06, 2016 4:32 pm

joan wrote:The code is using the RPi.GPIO library. That is both a library and a dependency.
Of course, you are right. I mean that you don't need type 'pip install' or something like this to install additional modules before you can start program. All modules used are common and installed in Raspbian by default. I will fix my first message.

willance85
Posts: 1
Joined: Mon Dec 18, 2017 12:53 pm

Re: Gpio pins monitoring and test

Mon Dec 18, 2017 1:46 pm

Hi, my RaspiModel is a32082, it's production from Japan, when running the script, there's an error occur "hardware not supported"
so i added

def getRaspiModel(argument):
"a32082": "3 Model B 1Gb"

def getGpioNum(argument):
"a32082": 26

but still occur the error in the shell:

setupterm: could not find terminal
Traceback (most recent call last):
File "/home/pi/Desktop/gpiotest-master/gpiotest.py", line 391, in <module>
termOn()
File "/home/pi/Desktop/gpiotest-master/gpiotest.py", line 39, in termOn
curses.nocbreak()
_curses.error: must call initscr() first

what can i do now?

User avatar
DougieLawson
Posts: 42176
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Gpio pins monitoring and test

Thu Dec 21, 2017 6:05 am

Two options:
1. Rewrite the script or library function to recognise your Japanese machine.
2. Report the error to the library author so they can fix the library for everyone.

Option 1 is fun (and part of learning to your use Raspberry). Option 2 is essential.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

kgbplus
Posts: 11
Joined: Mon Dec 05, 2016 1:59 pm
Location: Saint-Petersburg, RU

Re: Gpio pins monitoring and test

Thu Dec 21, 2017 12:58 pm

My apologies for taking so long to reply. I've updated hardware detection in my project, please try to use it.
I will try to catch this exception soon.

tyrion_lannister
Posts: 1
Joined: Tue May 15, 2018 6:10 pm

Re: Gpio pins monitoring and test

Tue May 15, 2018 6:18 pm

Hi, I am trying to use this but I get a "Failed to add edge detection" when I run sudo python3 gpiotest.py. Any help is appreciated.

kgbplus
Posts: 11
Joined: Mon Dec 05, 2016 1:59 pm
Location: Saint-Petersburg, RU

Re: Gpio pins monitoring and test

Wed May 16, 2018 7:25 am

Could you please tell me your python version and rpi.gpio library version (use this guide)

vaarasp
Posts: 6
Joined: Sun Mar 06, 2016 6:06 pm

Re: Gpio pins monitoring and test

Mon Feb 10, 2020 10:00 pm

Hello
I suspect I roasted one or more Gpoi-pins. Anyway SPI doesn't do its job like it used to, since I tried to measure battery voltage via Mcp3008 ADconverter
Gpio load spi gives gpio:unable to load/unload modules etc
Ls /dev/*spi* gives the two devices /dev/spidev0.0 and 0.1
Did raspi-config, dtparam=spi=on
Lsmod gives no spidev anymore! But bcm2835_gpiomem is there.
Controled the settings several times, updated etc, no clue. So tried to test with Gpiotest.py.
sudo pigpiod but when I run the program in CL, i get no message and a new commandline after 1-2 seconds.
No message. What can be the background of this?
Is my SPI "broken"? If just Gpiotest would work!
I have a Rasberry 2B v.14 2014
Linux raspberry 4.1.19-v7+

Thanks

kgbplus
Posts: 11
Joined: Mon Dec 05, 2016 1:59 pm
Location: Saint-Petersburg, RU

Re: Gpio pins monitoring and test

Tue Feb 11, 2020 2:15 pm

vaarasp wrote:
Mon Feb 10, 2020 10:00 pm
Is my SPI "broken"? If just Gpiotest would work!
I have a Rasberry 2B v.14 2014
Linux raspberry 4.1.19-v7+
Hello!

Seems the only way to know is to find another Raspberry Pi and try it with your sd card in it.
I haven't seen anything like that but I haven't seen enough.

Roman

vaarasp
Posts: 6
Joined: Sun Mar 06, 2016 6:06 pm

Re: Gpio pins monitoring and test

Tue Feb 11, 2020 11:09 pm

Yes, I'm busy doing exactly that.....but still, that won't answer the question why the otther one is having this problem.

Spawnreaper
Posts: 25
Joined: Mon Oct 10, 2016 1:13 pm

Re: Gpio pins monitoring and test

Fri Jan 01, 2021 8:24 pm

I am getting some irregular responses from this script that make no sense to me.
I am trying to test out a relay I want to switch. 5v and grond from pin 4 and 6. signal wire is set on pin 11 (gpio17)

When I run an "input" command to gpio17 the relay turns off.
If I run a "output" commend and ether set gpio17 to true or false the relay turns on.
If I switch the status from high to low or the other way around the relay remains on.

I makes no sense. should I use another pin?

kgbplus
Posts: 11
Joined: Mon Dec 05, 2016 1:59 pm
Location: Saint-Petersburg, RU

Re: Gpio pins monitoring and test

Fri Jan 01, 2021 8:29 pm

Seems some relay issue (incorrect relay voltage)

Return to “Automation, sensing and robotics”