Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

OrangePi Zero - GPIO question

Featured Replies

Hi,

 

I have probably trivial question related to GPIO on Orange Pi Zero.

 

So - I have a switch there connected ot 3.3V and then to GPIO (pin 12 on Zero).

What I want to do is just to read GPIO state. When button pressed it goes to high state - normally.

 

On RaspberryPi and Odroid C1 that works fine just using basic code with wiringpi2 or eventually wiringpi.

So I tried the same on Zero compiling wiring for H3/H2. 

My code is basic in Python:

import time
import wiringpi
import pyA20 as GPIO

cykl = 1
wiringpi.wiringPiSetupGpio #or wiringPiSetup()
wiringpi.pinMode(1,0)
while cykl == 1 :
 do_call = wiringpi.digitalRead(1)
 if do_call:
   print 'pressed'
 time.sleep(0.05)

On other arm machines it works.

 

Did I missed something with ZERO? 

I do not have any error - but so far I never got change of the state to 1. I assume in mapping PIN 12 is GPIO1 or eventually GPIO7.

Is this correct?

 

I think I have missed something there - probably very basic.....

 

Thanks in advance for help....

 

Michal

  • Author

Thanks Martin,

 

That is true... I should go with easy way. I think I was just too much focus and used to Wiringpi.... 

Actually I even compiled that library before... but never used.

 

Looks like this works... 

 

There is only one small issue which I see I have with that button. My button is piezoelectric - unfortunately on this type you have small leakage of voltage (very low) from time to time.

And unfortunately it is read as signal.

 

Maybe somebody has idea if in digital mode I can set up at which level it should react? Or do I have to set up physical electronic filter  before sending this to GPIO input?

 

For now I have like 90% state 0 but 10% randomly jumps to 1. If there is no good way then I would need to jump to physical button and give up with piezoelectric one.

 

I know it is more electronic question... but if somebody is using GPIO - then there is electronic behind....

 

pyA20 solution works perfectly fine.... but my button not... 

 

Thanks again for assistance

 

Michal

You can not do anything for the digital pin rules, the difference between low and high is hardcoded. From what I understand there is no single value for the threshold but it works on higher than some targed value...

Some logic coverter might work but I think you need analog device which basic socs do not support

 

Maybe somebody has idea if in digital mode I can set up at which level it should react? Or do I have to set up physical electronic filter before sending this to GPIO input?

  • Author

Yeap... values float a little. I was just thinking if method like pullup or puldown would not help....

 

But to be honest I'm not sure if I can use that and how in easy way.

For now it looks like I have to revert to analogue push button :(

 

Mike

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.