RPi.GPIO python module for Pine A64/A64+
#81
(09-03-2017, 12:49 PM)psychedup Wrote: Yes, that's the one. So far I've just used it to blink LED's. This is my first attempt at trying to work with I2C. I wonder if there's some sample code that I could look at somewhere.


Your first attempts at i2c will be frustrating ( usually is ).

... first step is to place the device on your system, and then see if the i2c tools can see it;  does it show up and is its address what you expect?
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#82
Since I'm running Armbian, I'm using /dev/i2c-1 instead of /dev/twi1.
But here is some code I'm using to make some LEDs flashing on an MCP23017 :


Code:
#!/usr/bin/env python

import sys, time
from RPi import I2C as i2c

i2c.init("/dev/i2c-1")
i2c.open(0x20)
i2c.write([0x00, 0x00])
i2c.write([0x01, 0x00])
while True:
    i2c.write([0x12, 0x0F])
    i2c.write([0x13, 0x0F])
    time.sleep(0.15)
    i2c.write([0x12, 0xF0])
    i2c.write([0x13, 0xF0])
    time.sleep(0.15)
  Reply
#83
(09-03-2017, 03:43 PM)martinayotte Wrote: Since I'm running Armbian, I'm using /dev/i2c-1 instead of /dev/twi1.
But here is some code I'm using to make some LEDs flashing on an MCP23017 :


Code:
#!/usr/bin/env python

import sys, time
from RPi import I2C as i2c

i2c.init("/dev/i2c-1")
i2c.open(0x20)
i2c.write([0x00, 0x00])
i2c.write([0x01, 0x00])
while True:
    i2c.write([0x12, 0x0F])
    i2c.write([0x13, 0x0F])
    time.sleep(0.15)
    i2c.write([0x12, 0xF0])
    i2c.write([0x13, 0xF0])
    time.sleep(0.15)

Thanks, I found the problem thanks to your example. I was trying to open "/dev/twi1" which didn't exist. It's /dev/i2c-1. For some reason when I run i2cdetect or i2cdump they want me to use twi1 as an alias to /dev/i2c-1 so I got them mixed up.

Now it is reading from the device. I just have to figure out what to do with the results Smile

Thanks for your help.
  Reply
#84
Hello, I have an error when I include RPi.GPIO in my python script which includes a GUI. Error says
"cannot access to /dev/mem/" I read running as root this error is solved but if I run my script as root from the shell I get the next error "cannot connect to X server". I have read and try many options but none has work. Could you give some guidance?
  Reply
#85
you can change permission on /dev/mem by doing "sudo chmod a+rw /dev/mem", and then you application should be able to access it.
  Reply
#86
(10-13-2017, 07:02 AM)martinayotte Wrote: you can change permission on /dev/mem by doing "sudo chmod a+rw /dev/mem", and then you application should be able to access it.

It doesn't work for me, still the same error. Any other idea? ... Thanks
  Reply
#87
(04-22-2016, 12:39 AM)aquilegia Wrote: I just ported RPi.GPIO python module for Pine A64/A64+.
You can download the package from https://github.com/swkim01/RPi.GPIO-PineA64.
Thank to joey for gpio pin information.
However, the event detect function was not operated yet.
I guess the kernel's gpio driver has to be modified to enable gpio interrupts.

Will this work with the Rock64?
  Reply
#88
(10-31-2017, 09:58 AM)www139 Wrote:
(04-22-2016, 12:39 AM)aquilegia Wrote: I just ported RPi.GPIO python module for Pine A64/A64+.
You can download the package from https://github.com/swkim01/RPi.GPIO-PineA64.
Thank to joey for gpio pin information.
However, the event detect function was not operated yet.
I guess the kernel's gpio driver has to be modified to enable gpio interrupts.

Will this work with the Rock64?

@www139, I don't think it will work, would love some community expert to port this for Rock64.
  Reply
#89
I got a Nokia 5110 LCD module from Sparkfun (here), wired it up to my pineA64+ and was able to use this library to make it work over SPI (happy to share how I did it if anybody's interested).

It works just fine, but everytime I call SPI.write(), besides writing to the device it also dumps the values to the console. This was nice for debugging, but is there a way to make it quieter?

Thanks,
Chris
  Reply
#90
Are you using spidev?
Come have a chat in the Pine IRC channel >>
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  fm transmitter with gpio weasel18 2 4,830 09-10-2019, 04:28 AM
Last Post: desai_amogh
  How to use dts or other setup to declare gpio pin Interrupt (e.g. a button)? dkebler 1 3,601 06-12-2019, 10:37 AM
Last Post: dkebler
Lightbulb Sample GPIO codes highlighting RPi.GPIO-PineA64 and the PI bus MarkHaysHarris777 6 11,135 06-07-2019, 12:37 AM
Last Post: tllim
Star GPIO, SPI and I2C C++ Lib databit 7 11,218 02-04-2019, 05:45 AM
Last Post: Jeff R
Information Howto: Controlling Pine64 GPIO via the filesystem (sysfs) on linux pfeerick 4 11,857 01-24-2019, 03:36 AM
Last Post: Fifth
  GPIO and SPI SamR1 20 31,612 03-15-2018, 10:32 AM
Last Post: jomoengineer
Question GPIO shockr 7 14,778 03-11-2018, 01:52 AM
Last Post: jomoengineer
  Read GPIO problem shworker 14 21,178 08-17-2017, 01:21 PM
Last Post: martinayotte
  Cross-wired Uart Ports between two Pine Boards via Cat5 Cable MarkHaysHarris777 10 16,011 11-20-2016, 04:17 AM
Last Post: pfeerick
  GPIO fiq capability joseph 3 6,098 11-10-2016, 06:07 PM
Last Post: joseph

Forum Jump:


Users browsing this thread: 2 Guest(s)