• Recent
  • Wiki
  • Github
  • 百度网盘
  • Onedrive
  • Official
  • Shop
  • Register
  • Login
  • Register
  • Login
  • Search
  • Recent
  • Wiki
  • Github
  • 百度网盘
  • Onedrive
  • Official
  • Shop

coolpi 4b python3 gpio operation compatable with raspberry pi

Pi 4B
11
30
3.5k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 大法师
    大法师 last edited by jack_admin Apr 25, 2023, 1:41 AM Dec 19, 2022, 5:55 AM

    download and install with root user.

    sudo pip3 install CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whl
    

    for ubuntu 20.04
    CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whl

    for ubuntu 22.04
    CPi.GPIO-1.0.0-cp310-cp310-linux_aarch64.whl

    other
    CPi.GPIO-1.0.0-cp39-cp39-linux_aarch64.whl

    default gpio cfg with system image:
    33e8f15f-4873-40b9-b72d-565a7939aa34-110d40fc1c675dc16529c2212427a4e.png
    gpio_coolpi


    test.py

    running test:

    sudo python3 test.py
    
    #!/usr/bin/env python3
    
    import CPi.GPIO as GPIO
    import time
    
    PIN = 40
    
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(PIN, GPIO.OUT)
    
    while True:
       GPIO.output(PIN, 0) 
       time.sleep(1)
       GPIO.output(PIN, 1) 
       time.sleep(1)
    
    

    其中GPIO.setmode(GPIO.BOARD)表示使用coolpi 4b板子自然编号Pin number。如果要使用Rockchip gpio编号,需要引用GPIO.setmode(GPIO.RK)。

    4b679a9d-aff9-43a9-8e4c-777b17da89a4-1671431575404.png

    if you want to remove this module, exec command:

    sudo pip3 uninstall CPi.GPIO
    

    jack@cool-pi.com

    A W 2 Replies Last reply Mar 8, 2023, 9:29 AM Reply Quote 0
    • 花
      花月 last edited by Dec 21, 2022, 12:19 PM

      也适用于debain等其他系统嘛

      G 1 Reply Last reply Dec 21, 2022, 1:52 PM Reply Quote 0
      • G
        george @花月 last edited by Dec 21, 2022, 1:52 PM

        @花月 注意python版本,其它都是一样的。ubuntu22.04 默认python3.10,要注意切换一下。

        花 D 2 Replies Last reply Jan 15, 2023, 5:36 AM Reply Quote 0
        • topic:timeago_later,8 days
        • 花
          花月 @george last edited by Dec 29, 2022, 10:42 AM

          @george SPI 怎么开,在debain下安装完输入gpio_coolpi显示命令找不到
          是否有比较全的示例介绍SPI

          J 1 Reply Last reply Dec 29, 2022, 1:27 PM Reply Quote 0
          • J
            jack_admin @花月 last edited by Dec 29, 2022, 1:27 PM

            @花月
            系统中若无该命令,请将附件文件拷贝到/usr/sbin/,再执行chmod a+x /usr/sbin/gpio_coolpi

            gpio_coolpi

            SPI与I2C操作使用标准python或标准C调用API

            花 1 Reply Last reply Dec 29, 2022, 1:56 PM Reply Quote 0
            • 花
              花月 @jack_admin last edited by Dec 29, 2022, 1:56 PM

              @jack_admin 这个附件名称是什么,下载是数字的名称,有后缀嘛?

              J 1 Reply Last reply Dec 30, 2022, 3:52 AM Reply Quote 0
              • J
                jack_admin @花月 last edited by Dec 30, 2022, 3:52 AM

                @花月 可以拷贝重命名/usr/sbin/gpio_coolpi

                1 Reply Last reply Reply Quote 0
                • topic:timeago_later,16 days
                • D
                  dreamer @george last edited by Jan 15, 2023, 5:36 AM

                  @george Is there any way to use GPIOs without sudo priviledge, such as in a ros package?

                  大法师 1 Reply Last reply Jan 16, 2023, 5:05 AM Reply Quote 0
                  • 大法师
                    大法师 @dreamer last edited by 大法师 Jan 16, 2023, 5:14 AM Jan 16, 2023, 5:05 AM

                    @dreamer
                    hi, please add extra operation for coolpi user.

                    Add rules for normal user:

                    sudo echo "SUBSYSTEM==\"gpio*\", ACTION==\"add\", PROGRAM=\"/bin/bash -c 'chown root:coolpi /sys/class/gpio/export /sys/class/gpio/unexport;chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'\"" > /lib/udev/rules.d/99-gpio.rules
                    sudo echo "SUBSYSTEM==\"gpio*\", ACTION==\"add\", PROGRAM=\"/bin/bash -c 'chown root:coolpi /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low; chmod 0660 /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low'\"" >> /lib/udev/rules.d/99-gpio.rules
                    sudo reboot
                    

                    Check rules:

                    coolpi@coolpi:~/Desktop$ cat /lib/udev/rules.d/99-gpio.rules 
                    SUBSYSTEM=="gpio*", ACTION=="add", PROGRAM="/bin/bash -c 'chown root:coolpi /sys/class/gpio/export /sys/class/gpio/unexport;chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
                    SUBSYSTEM=="gpio*", ACTION=="add", PROGRAM="/bin/bash -c 'chown root:coolpi /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low; chmod 0660 /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low'"
                    

                    Test case:

                    coolpi@coolpi:~/Desktop$ echo 115 > /sys/class/gpio/export 
                    coolpi@coolpi:~/Desktop$ ls /sys/class/gpio/gpio115
                    active_low  device  direction  edge  power  subsystem  uevent  value
                    coolpi@coolpi:~/Desktop$ echo out > /sys/class/gpio/gpio115/direction 
                    coolpi@coolpi:~/Desktop$ echo 1 > /sys/class/gpio/gpio115/value 
                    coolpi@coolpi:~/Desktop$ echo 0 > /sys/class/gpio/gpio115/value 
                    coolpi@coolpi:~/Desktop$
                    

                    Screenshot from 2023-01-16 13-14-27.png

                    jack@cool-pi.com

                    1 Reply Last reply Reply Quote 0
                    • topic:timeago_later,18 days
                    • A
                      AugustRobot_Zou last edited by AugustRobot_Zou Feb 3, 2023, 9:35 AM Feb 3, 2023, 9:34 AM

                      请问跟RPi.GPIO的函数完全兼容吗?
                      GPIO.setwarnings(False) 之类的函数都有吗
                      @大法师

                      大法师 1 Reply Last reply Feb 6, 2023, 4:16 AM Reply Quote 0
                      • 大法师
                        大法师 @AugustRobot_Zou last edited by Feb 6, 2023, 4:16 AM

                        @AugustRobot_Zou
                        还未完整测试所有接口。

                        jack@cool-pi.com

                        1 Reply Last reply Reply Quote 0
                        • Referenced by  大法师 大法师 Feb 17, 2023, 3:33 AM
                        • A
                          AugustRobot_Zou @大法师 last edited by AugustRobot_Zou Mar 9, 2023, 9:27 AM Mar 8, 2023, 9:29 AM

                          @大法师
                          请问有支持python3.6的 .whl安装包吗?
                          我的docker环境是unbuntu18.04+py2.7+py3.6.9的,CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whl安装不了。
                          或者有没有其他方式,驱动gpio

                          大法师 1 Reply Last reply Mar 8, 2023, 10:13 AM Reply Quote 0
                          • 大法师
                            大法师 @AugustRobot_Zou last edited by 大法师 Mar 8, 2023, 10:13 AM Mar 8, 2023, 10:13 AM

                            @AugustRobot_Zou
                            所有的底层封装操作都是基于访问/sys/class/gpio/

                            https://www.cool-pi.com/topic/72/coolpi-4b硬件扩展四-gpio

                            jack@cool-pi.com

                            A 1 Reply Last reply Mar 9, 2023, 9:26 AM Reply Quote 0
                            • A
                              AugustRobot_Zou @大法师 last edited by AugustRobot_Zou Mar 9, 2023, 9:41 AM Mar 9, 2023, 9:26 AM

                              @大法师
                              请问能麻烦编译一个python3.6.9的安装包吗?
                              使用CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whl,必须装上python3.8。
                              我的docker环境是ubuntu18.04+python3.6.9+ROS。

                              装了python3.8后,同时存在python3.8和python3.6,导致原本的代码程序很多python版本适配问题,这几天为这个问题搞得头大,很难兼顾 CPi.GPIO库和原来的程序,模块脚本的#!/usr/bin/python3 只能配置2选1(3.8 or 3.6 )。

                              80fa368b-5533-4b1d-b029-60c55cbe2106-图片.png

                              大法师 J 2 Replies Last reply Mar 9, 2023, 10:24 AM Reply Quote 0
                              • 大法师
                                大法师 @AugustRobot_Zou last edited by Mar 9, 2023, 10:10 AM

                                @AugustRobot_Zou okay!

                                jack@cool-pi.com

                                1 Reply Last reply Reply Quote 0
                                • J
                                  jack_admin @AugustRobot_Zou last edited by Mar 9, 2023, 10:24 AM

                                  @AugustRobot_Zou CPi.GPIO-1.0.0-cp36-cp36m-linux_aarch64.whl

                                  A 1 Reply Last reply Mar 9, 2023, 11:52 AM Reply Quote 0
                                  • A
                                    AugustRobot_Zou @jack_admin last edited by Mar 9, 2023, 11:52 AM

                                    @jack_admin @大法师
                                    Really appreciate your help!
                                    Now our system is basically compatible with coolp4B,which used to running on raspberry-pi4B.

                                    1 Reply Last reply Reply Quote 0
                                    • Referenced by  A AugustRobot_Zou Mar 10, 2023, 2:39 AM
                                    • Referenced by  J jack_admin Mar 11, 2023, 3:46 PM
                                    • X
                                      xingzhan2012 last edited by xingzhan2012 Mar 14, 2023, 12:41 AM Mar 14, 2023, 12:41 AM

                                      有python3.9版本的吗

                                      J 1 Reply Last reply Mar 14, 2023, 1:17 PM Reply Quote 0
                                      • J
                                        jack_admin @xingzhan2012 last edited by Mar 14, 2023, 1:17 PM

                                        @xingzhan2012 有。在帖子最顶楼

                                        X 1 Reply Last reply Mar 14, 2023, 2:14 PM Reply Quote 0
                                        • X
                                          xingzhan2012 @jack_admin last edited by Mar 14, 2023, 2:14 PM

                                          @jack_admin 谢谢

                                          1 Reply Last reply Reply Quote 0
                                          • M
                                            Macs last edited by Macs Mar 19, 2023, 6:03 AM Mar 19, 2023, 6:02 AM

                                            Does the coolpi have a DPI mode for the gpio like the RPI4?

                                            J 1 Reply Last reply Mar 19, 2023, 7:30 AM Reply Quote 0
                                            • J
                                              jack_admin @Macs last edited by Mar 19, 2023, 7:30 AM

                                              @Macs said in coolpi 4b python3 gpio operation compatable with raspberry pi:

                                              Does the coolpi have a DPI mode for the gpio like the RPI4?

                                              WiringPi ?

                                              M 1 Reply Last reply Mar 19, 2023, 6:57 PM Reply Quote 0
                                              • M
                                                Macs @jack_admin last edited by Mar 19, 2023, 6:57 PM

                                                @jack_admin I mean can output video signal on the gpio using with custom timings, like you can on the RPI4?

                                                1 Reply Last reply Reply Quote 0
                                                • topic:timeago_later,2 months
                                                • O
                                                  Orion last edited by May 26, 2023, 1:54 PM

                                                  请问支持C++语言吗

                                                  J 1 Reply Last reply May 27, 2023, 9:27 AM Reply Quote 0
                                                  • J
                                                    jack_admin @Orion last edited by May 27, 2023, 9:27 AM

                                                    @Orion C++可以代码文件操作gpio,不需要调用python库

                                                    O 1 Reply Last reply May 29, 2023, 1:52 PM Reply Quote 0
                                                    • O
                                                      Orion @jack_admin last edited by May 29, 2023, 1:52 PM

                                                      @jack_admin 请问C++需要包含哪个库呢,是writtingPi吗

                                                      J 1 Reply Last reply May 29, 2023, 2:00 PM Reply Quote 0
                                                      • J
                                                        jack_admin @Orion last edited by May 29, 2023, 2:00 PM

                                                        @Orion 直接裸操作/sys/class/gpio,不做二次包装

                                                        1 Reply Last reply Reply Quote 0
                                                        • topic:timeago_later,16 days
                                                        • Z
                                                          zensation last edited by Jun 14, 2023, 8:30 PM

                                                          it says in the GPIO page that all gpio are configurable with pullup or pulldown mode. How can we access the pull down resistor on a input pin say pin 32 GPIO105 that is default set to pullup? I tried the same convention as raspberry pi python access which is

                                                          GPIO.setup([pin#], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

                                                          and i get the error no PUD_DOWN in the module. Can you post the entire documentation with included commands in this module?

                                                          大法师 1 Reply Last reply Jun 15, 2023, 7:00 AM Reply Quote 0
                                                          • 大法师
                                                            大法师 @zensation last edited by Jun 15, 2023, 7:00 AM

                                                            @zensation not support setting pullup/down in user space now.

                                                            jack@cool-pi.com

                                                            1 Reply Last reply Reply Quote 0
                                                            • topic:timeago_later,about a year
                                                            • W
                                                              weiweiwei @大法师 last edited by Jul 31, 2024, 2:03 AM

                                                              This post is deleted!
                                                              1 Reply Last reply Reply Quote 0
                                                              • 1 / 1
                                                              1 out of 30
                                                              • First post
                                                                1/30
                                                                Last post