Configuracion y use de GPIO BPI-M2 Zero

ok I think I understand what is happening look I think the problem you have is not the script but that you are not connecting your button correctly.

Here I leave you how you should connect it, being the blue cable the pin that you are going to occupy the black GND and the red 5V, you will also need a 10K resistor

circuitopulsador_1

Ok It works! thanks.

Why is resistance needed here? How to make a way to go without resistance? On raspberry pi zero no resistor is required, I connect GND to Pin37 it was change from 1 to 0.

As I remember it was because the raspberry boards have a pull down set and the banana pi only uses it on some pins.

if you don’t want to use a resistor you could pull-up the pin but it will always be high.

Direct Set PullDown on which pins would be available on banana pi board? image

For the board pin mapping change which command should I use. Important the remap UART3: pin8 bring it back to TX and pin 10 to RX as in rpi zero.

no friend, in fact the RX and TX pins are fine I have been testing them and I have not had problems with them, and the truth is that I do not remember the pull-down pins very well but I think that 15 and 16 are in pull-down and for the pin command is without parentheses.

example: sudo gpio -g read 29

or another way to change the state of the pins is with a python script, also if you want to check if the pin is pull-down you can use the following command to declare the pin as pull-down or pull-up, just one thing the pull-up is almost only for output

GPIO.setup(31, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(31, GPIO.IN, pull_up_down=GPIO.PUD_UP)

Captura%20de%20pantalla%20(412)_LI

Captura%20de%20pantalla%20(412)

Captura%20de%20pantalla%20(413)_LI

hello I started trying RPi.GPIO libraries but callback functions also don’t work:

Python Code not work:

  1. GPIO.add_event_detect(pin, GPIO.BOTH, call back=myFunction)

  2. ) GPIO.add_event_detect(pin, GPIO.FALLING, call back=myFunction)

Error Code: RuntimeError: Failed to add edge detection

No use Resistor: To avoid using resistance I have tried to set pull down on pin 31 but GPIO.input still reads random values, if I put 10k resistor it works instead.

Hello, in fact something like this I already imagined could happen but it is the fault of the RPi.GPIO library since as far as the problem goes is the identification of the board I tried to try it in many ways and the only solution I saw in one was With resistors, I’m still going to tell you that the solutions I tried and that worked for me was to take the original ROi.GPIO apo and make changes to it with respect to the sinovic version to go to version 0.6.4 where event detection already worked for me,

Another solution that I could use is to modify my own library that is based on Adafruit Blick, where it only performs copulation on /dev directories, even though I think that any of them can work for you. Also, I will tell you that this problem does not only happen on this board, but I also had it on the raspberry pi Zero w with gpiozero but I solved it by changing gpiozero to RPi.GPIO in addition to changing the gpio bms register of the raspberry pi Zero w the 3b+ although at the time of loading the library I had to make modifications when doing the installation

if I do a clean reinstall via script.sh the Rpio.GPIO library update to make callback event calls work correctly?

No Resistor 10k: To avoid the use of the 10k resistor it is possible to do something, I forced with calls python set pulldown on the pin but no solution: GPIO.setup (31, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) without resistor but GPIO.input on the pin returns to reading 0-1 random values

The truth is that I had tried it but the use of gpio was broken worse I did it with old images I never tried it with my images so it could work or I could send you the error that it is only for RPi

and it still returns you like this because it detects the pin in false as if it had nothing connected, that’s why the value is random

hey look I took a moment to check if you really couldn’t put the pins in pull-down and it turns out that if it’s okay what happened when I gave you the gpio command -g write 7 1

estaba mal era gpio -1 write 7 1 hay fue mi error pero en efecto funciona muy bien igual si quieres le di una actualizacion rapida a mi repo para que tengas mas detalles

Captura%20de%20pantalla%20(430)

Captura%20de%20pantalla%20(431)

Captura%20de%20pantalla%20(432)

Captura%20de%20pantalla%20(434)

hello, script reinstalled now.

I write type down on physical pin board = 7, but button_state_m2z.py always reads only low state in input, no change of state detected when the wires are joined : pin7 + pin39 (gnd).

No use resistance 10k.

look I took a few minutes to review it and if it worked correctly :thinking:

Screenshot_20220330-142722

do you join the physical pin 7 to a gnd (read event change of state) without using a 10k resistor? you can post a drawing whith pin GPIO use.

i don’t understand why i don’t change state , here it doesn’t work change state GPIO.input on my board

look right now I can’t post a drawing but it’s the same as before just connect one pin of your button to GND and the other to pin 7 and that’s it

also in the capture that the post does not use any 10k resistor :thinking: I find it strange that it does not work for you, could you check if your wiring is properly connected first or maybe your button was damaged :sweat_smile:

Hello I have reviewed and tightened the wiring in fact now it works, I change GPIO.input captured!:slightly_smiling_face:

sudo gpio -1 mode 7 down

Is there a permanent way of definitive setting from Rpio.GPIO library?

Still error code for GPIO.add_event_detect () calls:Failed%20to%20add%20edge%20detection

GPIO.add_event_detect (pin, GPIO.BOTH, call back = myFunction)

GPIO.add_event_detect (pin, GPIO.FALLING, call back = myFunction)

Well, as I mentioned before, remember that what I basically did was about writing the library, obviously it is not going to be perfect and it has its ups and downs, and about your other question about whether the pins can be established without forcing the start, the answer is yes, but why At the moment I don’t have the time to make modifications to the current library, I have my own as I mentioned, but I don’t release it because it still has many bugs. In fact, mine does have edge detection on the board, but I haven’t corrected the value either. of the pins that’s the reason I haven’t released it yet

ok do you expect a long time to release a first version?

Alternative libraries Python with GPIO.add_event_detect on armbian are there?

to get the first version out maybe in a few months and about other libraries I couldn’t tell you what I can tell you is that if you know the c++ language you can create a program that reads the input of the buttons with wiringpi