gwaag
Posts: 52
Joined: Tue Apr 08, 2014 5:06 pm

piface read pin pull up

Sun Mar 05, 2017 9:02 pm

Hello
just tested below scrip. I want to see if input 0 is hight or low.
Unfurtunatly this is not showing a result when I run the script from comand line.

Code: Select all

#!/usr/bin/python
import pifacedigitalio
pfd = pifacedigitalio.PiFaceDigital()

pfd.input_pins[0].value[/code

I also would like to know the python code to set the pull up for input  0 high or low.
best regards
gwaag

User avatar
DougieLawson
Posts: 30139
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: piface read pin pull up

Sun Mar 05, 2017 9:31 pm

Try running it with python3 rather than python2.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

gwaag
Posts: 52
Joined: Tue Apr 08, 2014 5:06 pm

Re: piface read pin pull up

Sun Mar 05, 2017 9:53 pm

#!/usr/bin/env python3

pi@raspberrypi:/bin $ /bin/test.py
pi@raspberrypi:/bin $


same, not returning a value 0 or 1, justs jumps back to comand line.
gwaag

ghp
Posts: 1150
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: piface read pin pull up

Sun Mar 05, 2017 10:40 pm

Hello,
tried these commands with a piface board and reading inputs work.

There is a blink program "python3 /usr/share/doc/python3-pifacedigitalio/examples/blink.py", does this work ?
There are a few jumpers on the board, also for the address selection. Perhaps one of these is misplaced?

Regards,
Gerhard

gwaag
Posts: 52
Joined: Tue Apr 08, 2014 5:06 pm

Re: piface read pin pull up

Mon Mar 06, 2017 8:35 am

Yes, blink.py works ok.
but, below is not.

Code: Select all

#!/usr/bin/env python3

import pifacedigitalio

pifacedigital = pifacedigitalio.PiFaceDigital()

pifacedigital.input_pins[0].value
(jessie) (4.4.50+)

gwaag

ghp
Posts: 1150
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: piface read pin pull up

Mon Mar 06, 2017 1:45 pm

Hello,
in a script, use print ( pifacedigital.input_pins[0].value )
Regards,
Gerhard

gwaag
Posts: 52
Joined: Tue Apr 08, 2014 5:06 pm

Re: piface read pin pull up

Mon Mar 06, 2017 4:37 pm

Thanks Gerhard, this is working now.
where do you have the docu from ??

What is the code to see if pull up is high or low? or to set it to high or low??

Code: Select all

#!/usr/bin/python

import pifacedigitalio

pfio = pifacedigitalio.PiFaceDigital()

# print ( pfio.input_pins[0].value )

digital_write_pullup( 0, 1 )
get this error:
NameError: name 'digital_write_pullup' is not defined



regards
gwaag

ghp
Posts: 1150
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: piface read pin pull up

Mon Mar 06, 2017 5:24 pm

Hello,
some doku is in https://github.com/piface/pifacedigitalio and the source ( the truth lies in the code ).
Think the pullup are read by
digital_read_pullup(pin_num, hardware_addr=0)
digital_write_pullup(pin_num, value, hardware_addr=0)

remember to apply these methods on the instance 'pfio ' of PiFaceDigital()
Regards,
Gerhard

ronrose7
Posts: 1
Joined: Sat May 13, 2017 8:18 pm

Re: piface read pin pull up

Tue May 16, 2017 4:37 pm

I have my old security system door sensors hooked up to the PiFace inputs and a Python program monitoring them. It sends REST commands to my ISY Controller turning a flag on or off when the door opens or closes. In the ISY controller I have logic to send texts, email turn lights on etc. if I am away.
It has been working well for the past year but the last time I was away someone came to my door and rang the door bell. That made it look like one of the doors were opened and I got a text message saying someone was in my house.
In this case I was able to see on the camera who it was and called them to insure it was a false alarm.

I found this thread and though maybe the pull up is what I needed. Playing around with my program it looks like the pull up was already defaulted to on but now I have a write_pullup in the code to make sure it is.
That did not fix my problem though.

Any suggestions what I should try next? Am I doing something wrong?
I guess I could modify my logic to not send the REST command until the door shows open for a full 2 seconds but was hopping not to go that direction.
My last ditch option would be to disconnect the door bell. :)

Here are the pifaceditialio calls I am using in my program.

import pifacedigitalio
pifacedigitalio.init()
pifacedigitalio.digital_write_pullup(0,1)
front_door = pifacedigitalio.digital_read(0)

Thanks for the help, Ron

Return to “Python”

Who is online

Users browsing this forum: No registered users and 22 guests