Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

IOPi Pin Write, Keep Pin State

3989 Views - Created 05/10/2015

10/07/2015

Posted by:
D_Az35

D_Az35 Avatar

Hey everyone,
I was wandering what would be the correct approach, in Python, to keep an IOPi Output Pin, with the value 1 (high), even after the script dies, only returning to its original 0 (low) state, if the RPi is rebooted or if you change it back. Can this be done without extra hardware?
Thks to all
D.az

10/07/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Once you set the state of an output pin on an IO Pi using either the write_pin() or write_port() function it should keep that state until you send a new write_pin command, so once you set the pin to 1 it should stay at 1 until either the power is removed or a new command is sent.

I have just tried running the following python script which sets pin 1 on bus 1 to high and it remained at the high state after the script finished and also stayed high when I rebooted the raspberry pi.


#!/usr/bin/python

from ABE_helpers import ABEHelpers
from ABE_IoPi import IoPi

i2c_helper = ABEHelpers()
newbus = i2c_helper.get_smbus()

bus1 = IoPi(newbus, 0x20)

bus1.set_port_direction(0, 0x00)
bus1.write_pin(1, 1)

19/11/2015

Posted by:
wieserdk

wieserdk Avatar

Hi Andrew,

I used script you put above, but I have a problem.
I tried to read pin states using demo-iopiread2.py and it returns only:

Pin 1: 0
Pin 2: 0
Pin 3: 0
Pin 4: 0
Pin 5: 0
Pin 6: 0
Pin 7: 0

Pin 8: 0
Any sugestions?

20/11/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Do you have the inputs on the IO Pi connected to anything or are there any other devices connected to the Raspberry Pi on the I2C bus? The demo-iopiread2.py script should show the inputs as 1 unless the pin is connected to ground so I am not sure why all of the inputs would be showing as 0.

20/11/2015

Posted by:
wieserdk

wieserdk Avatar

I have 2 IO Pi connected only. Nothing else, even nothing connected to GPIO pins. I'm lost..

21/11/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Does the demo-iopiread.py script work on your IO Pi? I have just tried running the demo-iopiread2.py script on an IO Pi and it failed to run as it was looking at the wrong I2C address. demo-iopiread.py and demo-iopiread2.py appear to be the same script but with different I2C addresses, I am not sure why demo-iopiread2.py was in the GitHub folder but I have removed it.

28/11/2015

Posted by:
wieserdk

wieserdk Avatar

demo-iopiread.py returns eactly the same: only 0

28/11/2015

Posted by:
wieserdk

wieserdk Avatar

Than can be quite important, and strange:
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f

70: 70 71 72 73 74 75 76 77

Any ideas?

29/11/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

The i2cdetect response is strange, all of the rows and columns should be 00 except 20 and 21.

Can you try disconnecting the IO Pi and see if you get the same response? If it all goes to 00 then it may be a fault with the IO Pi, in which case I will send you a new one to try.

If it still shows all of the addresses then it is probably a problem with the i2c configuration in Linux. Try going through our i2c tutorial and checking that everything is set up correctly. Otherwise, you may need to try a fresh install of Raspbian Linux and see if that solves the problem.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.