Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Mysensors Gateway on OrangePi (Zero) (opi)

Mysensors Gateway on OrangePi (Zero) (opi)

Scheduled Pinned Locked Moved Development
117 Posts 11 Posters 43.2k Views 11 Watching
  • 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.
  • T Tag

    @Reza

    You need to create the files after each boot.

    After the modprobe, Issue this command:

    sudo for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done
    

    This will get you the files.

    R Offline
    R Offline
    Reza
    wrote on last edited by
    #86

    @Tag said:

    sudo for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done

    orangepi one have 40 pins

    M 1 Reply Last reply
    0
    • R Reza

      @Tag said:

      sudo for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done

      orangepi one have 40 pins

      M Offline
      M Offline
      marceloaqno
      Code Contributor
      wrote on last edited by
      #87

      @Reza Is there /sys/class/gpio/export file on your OPi?

      R 2 Replies Last reply
      0
      • M marceloaqno

        @Reza Is there /sys/class/gpio/export file on your OPi?

        R Offline
        R Offline
        Reza
        wrote on last edited by
        #88

        @marceloaqno
        no i have not folder "gpio" in my orangepi

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mihai.aldea
          wrote on last edited by
          #89

          @marceloaqno It still doesn't work on my OPi Zero :confused:

          root@opi-zero-1:~/orangepi# bin/mysgw -d
          mysgw: Starting gateway...
          mysgw: Protocol version - 2.2.0-beta
          mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
          mysgw: TSM:INIT
          mysgw: TSF:WUR:MS=0
          mysgw: !TSM:INIT:TSP FAIL
          mysgw: TSM:FAIL:CNT=1
          mysgw: TSM:FAIL:PDT
          mysgw: Received SIGINT

          I do have the /sys/class/gpio/export and I ran for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done

          For the record, here's my OS:

          BOARD=orangepizero
          BOARD_NAME="Orange Pi Zero"
          VERSION=5.24
          LINUXFAMILY=sun8i
          BRANCH=default
          ARCH=arm
          PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
          NAME="Debian GNU/Linux"
          VERSION_ID="8"
          VERSION="8 (jessie)"
          ID=debian
          HOME_URL="http://www.debian.org/"
          SUPPORT_URL="http://www.debian.org/support"
          BUG_REPORT_URL="https://bugs.debian.org/"
          
          M 1 Reply Last reply
          0
          • M mihai.aldea

            @marceloaqno It still doesn't work on my OPi Zero :confused:

            root@opi-zero-1:~/orangepi# bin/mysgw -d
            mysgw: Starting gateway...
            mysgw: Protocol version - 2.2.0-beta
            mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
            mysgw: TSM:INIT
            mysgw: TSF:WUR:MS=0
            mysgw: !TSM:INIT:TSP FAIL
            mysgw: TSM:FAIL:CNT=1
            mysgw: TSM:FAIL:PDT
            mysgw: Received SIGINT

            I do have the /sys/class/gpio/export and I ran for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done

            For the record, here's my OS:

            BOARD=orangepizero
            BOARD_NAME="Orange Pi Zero"
            VERSION=5.24
            LINUXFAMILY=sun8i
            BRANCH=default
            ARCH=arm
            PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
            NAME="Debian GNU/Linux"
            VERSION_ID="8"
            VERSION="8 (jessie)"
            ID=debian
            HOME_URL="http://www.debian.org/"
            SUPPORT_URL="http://www.debian.org/support"
            BUG_REPORT_URL="https://bugs.debian.org/"
            
            M Offline
            M Offline
            marceloaqno
            Code Contributor
            wrote on last edited by
            #90

            @mihai.aldea The gateway does the exporting when needed, you don't need to run:
            for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done

            Could you send the output of this command?

            ls -lah /dev/spidev*
            
            T 1 Reply Last reply
            0
            • M marceloaqno

              @mihai.aldea The gateway does the exporting when needed, you don't need to run:
              for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done

              Could you send the output of this command?

              ls -lah /dev/spidev*
              
              T Offline
              T Offline
              Tag
              wrote on last edited by Tag
              #91

              @marceloaqno

              Still issues here:

              root@orangepizero:~/orangepi/bin# ll /dev/spi*
              crw------- 1 root root 153, 0 Jan  9 22:51 /dev/spidev0.0
              crw------- 1 root root 153, 1 Jan  9 22:51 /dev/spidev1.0
              

              Then:

              ./configure --spi-spidev-device=/dev/spidev1.0
              

              added to examples_linux/mysgw.cpp

              #define MY_RF24_CE_PIN 2
              #define MY_RF24_CS_PIN 13
              

              end enabled radio debugging:

              output:

              root@orangepizero:~/orangepi/bin# ./mysgw -d
              mysgw: Starting gateway...
              mysgw: Protocol version - 2.2.0-beta
              mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
              mysgw: TSM:INIT
              mysgw: TSF:WUR:MS=0
              mysgw: RF24:write register, reg=0, value=14
              mysgw: RF24:write register, reg=3, value=3
              mysgw: RF24:write register, reg=4, value=95
              mysgw: RF24:write register, reg=5, value=76
              mysgw: RF24:write register, reg=6, value=39
              mysgw: RF24:write register, reg=16, value=115
              mysgw: RF24:write register, reg=29, value=6
              mysgw: RF24:read register, reg=6, value=39
              mysgw: RF24:read register, reg=5, value=76
              mysgw: RF24:write register, reg=2, value=2
              mysgw: RF24:write register, reg=1, value=0
              mysgw: RF24:write register, reg=28, value=3
              mysgw: RF24:flushRX
              mysgw: RF24:flushTX
              mysgw: RF24:write register, reg=7, value=112
              mysgw: TSM:INIT:TSP OK
              mysgw: TSM:INIT:GW MODE
              mysgw: RF24:write register, reg=2, value=3
              mysgw: RF24:write register, reg=1, value=1
              mysgw: RF24:STRT LIS
              mysgw: RF24:write register, reg=0, value=15
              mysgw: RF24:write register, reg=10, value=0
              mysgw: TSM:READY:ID=0,PAR=0,DIS=0
              mysgw: MCO:REG:NOT NEEDED
              mysgw: RF24:read register, reg=23, value=17
              Illegal instruction
              root@orangepizero:~/orangepi/bin# 
              

              Almost there?

              1 Reply Last reply
              0
              • M marceloaqno

                @Reza Is there /sys/class/gpio/export file on your OPi?

                R Offline
                R Offline
                Reza
                wrote on last edited by Reza
                #92

                @marceloaqno
                in "orangepi one"(ubuntu os) there is not gpio folder in sys/class. but i think after run "modprobe gpio-sunxi" built a folder that name is "gpio_sw" and in this folder there are this files: normal_led,pa3,pa6,pa8 and 9,10,13,14,15,21 ,...

                M T 2 Replies Last reply
                0
                • R Reza

                  @marceloaqno
                  in "orangepi one"(ubuntu os) there is not gpio folder in sys/class. but i think after run "modprobe gpio-sunxi" built a folder that name is "gpio_sw" and in this folder there are this files: normal_led,pa3,pa6,pa8 and 9,10,13,14,15,21 ,...

                  M Offline
                  M Offline
                  mihai.aldea
                  wrote on last edited by
                  #93

                  @Reza Is it too complicated to switch to Debian?

                  R 1 Reply Last reply
                  0
                  • M mihai.aldea

                    @Reza Is it too complicated to switch to Debian?

                    R Offline
                    R Offline
                    Reza
                    wrote on last edited by
                    #94

                    @mihai.aldea said:

                    Is it too complicated to switch to Debian?

                    you told me i change my os ? to armbian ?

                    1 Reply Last reply
                    0
                    • R Reza

                      @marceloaqno
                      in "orangepi one"(ubuntu os) there is not gpio folder in sys/class. but i think after run "modprobe gpio-sunxi" built a folder that name is "gpio_sw" and in this folder there are this files: normal_led,pa3,pa6,pa8 and 9,10,13,14,15,21 ,...

                      T Offline
                      T Offline
                      Tag
                      wrote on last edited by Tag
                      #95

                      @Reza
                      More info on armbian.com

                      I use the debian jessie, works like a charm!

                      R 2 Replies Last reply
                      0
                      • M Offline
                        M Offline
                        mihai.aldea
                        wrote on last edited by
                        #96

                        @Reza I wouldn't even dream of not using Armbian on OrangePi and NanoPi. Compared to Raspbian it's years ahead in terms of optimization and tidyness. Armbian is the reason I'm avoiding RPi when possible. So go ahead and install a proper OS for your OPi. Not sure if Xenial or Debian, maybe we should wait for @marceloaqno to respond to my comment with the running OS.

                        1 Reply Last reply
                        0
                        • T Tag

                          @Reza
                          More info on armbian.com

                          I use the debian jessie, works like a charm!

                          R Offline
                          R Offline
                          Reza
                          wrote on last edited by
                          #97

                          @Tag
                          i worked with armbiam before. but my question is with armbian my problem is resolve ?

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mihai.aldea
                            wrote on last edited by
                            #98

                            That I can not say.

                            1 Reply Last reply
                            0
                            • T Tag

                              @Reza
                              More info on armbian.com

                              I use the debian jessie, works like a charm!

                              R Offline
                              R Offline
                              Reza
                              wrote on last edited by
                              #99

                              @Tag said:

                              I use the debian jessie, works like a charm!

                              ok i change my os and test again. thank you

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mihai.aldea
                                wrote on last edited by
                                #100

                                I confirm it's not working on the OPi PC where TMRh20 works.

                                S 1 Reply Last reply
                                0
                                • M marceloaqno

                                  @Tag Oops, did I get it right this time (I reuploaded the image)?

                                  T Offline
                                  T Offline
                                  Tag
                                  wrote on last edited by
                                  #101

                                  @marceloaqno said:

                                  @Tag Oops, did I get it right this time (I reuploaded the image)?

                                  Got it spot on!! looks great!

                                  1 Reply Last reply
                                  0
                                  • R Offline
                                    R Offline
                                    Reza
                                    wrote on last edited by
                                    #102

                                    i have problem with compile source domoticz(i must use source domoticz for my changes) in armbian, so i have to use ubuntu.
                                    @marceloaqno can you help me to run mysensors gateway in orangepi one (ubuntu os).thank you

                                    1 Reply Last reply
                                    0
                                    • T Offline
                                      T Offline
                                      Tag
                                      wrote on last edited by Tag
                                      #103

                                      Hi All,

                                      I put together the steps to get MySensors running on the OrangePi Zero:
                                      Take note of the SPI part, 1 typo and you will not see /dev/spidev1.0

                                      • Download and Install the ARMbian(debian) OS image
                                        https://www.armbian.com/orange-pi-zero/

                                      • Install sunxi-tools:
                                        These tools are required to make changes in the boot area of the system

                                      sudo apt-get update
                                      sudo apt-get install sunxi-tools
                                      
                                      • How to add /dev/spidev1.0 (which is required since /dev/spidev0.0 is used for the onboard NAND flash)
                                      cd /boot
                                      bin2fex /boot/script.bin /root/myscript.txt
                                      

                                      Now edit /root/myscript.bin and add/change the following so it looks exactly like the part below:

                                      [spi0]
                                      spi_used = 1
                                      spi_cs_bitmap = 1
                                      spi_mosi = port:PC00<3><default><default><default>
                                      spi_miso = port:PC01<3><default><default><default>
                                      spi_sclk = port:PC02<3><default><default><default>
                                      spi_cs0 = port:PC03<3><1><default><default>
                                      	
                                      [spi1]
                                      spi_used = 1
                                      spi_cs_bitmap = 1
                                      spi_cs0 = port:PA13<2><1><default><default>
                                      spi_sclk = port:PA14<2><default><default><default>
                                      spi_mosi = port:PA15<2><default><default><default>
                                      spi_miso = port:PA16<2><default><default><default>
                                      	
                                      [spi_devices]
                                      spi_dev_num = 2
                                      	
                                      [spi_board0]
                                      modalias = "spidev"
                                      max_speed_hz = 33000000
                                      bus_num = 0
                                      chip_select = 0
                                      mode = 0
                                      full_duplex = 1
                                      manual_cs = 0
                                      	
                                      [spi_board1]
                                      modalias = "spidev"
                                      max_speed_hz = 33000000
                                      bus_num = 1
                                      chip_select = 0
                                      mode = 0
                                      full_duplex = 1
                                      manual_cs = 0
                                      
                                      • Then recompile the script file:
                                      fex2bin /root/myscript.txt /boot/script.bin
                                      

                                      Reboot the system

                                      reboot
                                      

                                      2 device files should exist now:

                                      root@orangepizero:~# ls -l /dev/spi*
                                      crw------- 1 root root 153, 0 Jan 11 16:31 /dev/spidev0.0
                                      crw------- 1 root root 153, 1 Jan 11 16:31 /dev/spidev1.0
                                      

                                      Load the gpio module

                                      modprobe gpio-sunxi
                                      

                                      To load the module gpio-sunxi automagically load at boot time, add gpio-sunxi to /etc/modules

                                      echo gpio-sunxi >> /etc/modules
                                      
                                      • Now it is time to install the GW.
                                      cd /root
                                      git clone https://github.com/marceloaqno/MySensors.git orangepi 
                                      cd orangepi/ 
                                      git pull origin spidev
                                      ./configure --spi-spidev-device=/dev/spidev1.0
                                      make
                                      

                                      Working like a charm!

                                      If you tested "/bin/mysgw -d" and all works as expected, make the installation permanent:

                                      make install
                                      

                                      Additional
                                      If you want to read data into a controller using a device file (i.e Mycontroller) use the build string below

                                       ./configure --spi-spidev-device=/dev/spidev1.0  --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
                                      

                                      Hope this helps!! have fun!!

                                      M 1 Reply Last reply
                                      1
                                      • T Tag

                                        Hi All,

                                        I put together the steps to get MySensors running on the OrangePi Zero:
                                        Take note of the SPI part, 1 typo and you will not see /dev/spidev1.0

                                        • Download and Install the ARMbian(debian) OS image
                                          https://www.armbian.com/orange-pi-zero/

                                        • Install sunxi-tools:
                                          These tools are required to make changes in the boot area of the system

                                        sudo apt-get update
                                        sudo apt-get install sunxi-tools
                                        
                                        • How to add /dev/spidev1.0 (which is required since /dev/spidev0.0 is used for the onboard NAND flash)
                                        cd /boot
                                        bin2fex /boot/script.bin /root/myscript.txt
                                        

                                        Now edit /root/myscript.bin and add/change the following so it looks exactly like the part below:

                                        [spi0]
                                        spi_used = 1
                                        spi_cs_bitmap = 1
                                        spi_mosi = port:PC00<3><default><default><default>
                                        spi_miso = port:PC01<3><default><default><default>
                                        spi_sclk = port:PC02<3><default><default><default>
                                        spi_cs0 = port:PC03<3><1><default><default>
                                        	
                                        [spi1]
                                        spi_used = 1
                                        spi_cs_bitmap = 1
                                        spi_cs0 = port:PA13<2><1><default><default>
                                        spi_sclk = port:PA14<2><default><default><default>
                                        spi_mosi = port:PA15<2><default><default><default>
                                        spi_miso = port:PA16<2><default><default><default>
                                        	
                                        [spi_devices]
                                        spi_dev_num = 2
                                        	
                                        [spi_board0]
                                        modalias = "spidev"
                                        max_speed_hz = 33000000
                                        bus_num = 0
                                        chip_select = 0
                                        mode = 0
                                        full_duplex = 1
                                        manual_cs = 0
                                        	
                                        [spi_board1]
                                        modalias = "spidev"
                                        max_speed_hz = 33000000
                                        bus_num = 1
                                        chip_select = 0
                                        mode = 0
                                        full_duplex = 1
                                        manual_cs = 0
                                        
                                        • Then recompile the script file:
                                        fex2bin /root/myscript.txt /boot/script.bin
                                        

                                        Reboot the system

                                        reboot
                                        

                                        2 device files should exist now:

                                        root@orangepizero:~# ls -l /dev/spi*
                                        crw------- 1 root root 153, 0 Jan 11 16:31 /dev/spidev0.0
                                        crw------- 1 root root 153, 1 Jan 11 16:31 /dev/spidev1.0
                                        

                                        Load the gpio module

                                        modprobe gpio-sunxi
                                        

                                        To load the module gpio-sunxi automagically load at boot time, add gpio-sunxi to /etc/modules

                                        echo gpio-sunxi >> /etc/modules
                                        
                                        • Now it is time to install the GW.
                                        cd /root
                                        git clone https://github.com/marceloaqno/MySensors.git orangepi 
                                        cd orangepi/ 
                                        git pull origin spidev
                                        ./configure --spi-spidev-device=/dev/spidev1.0
                                        make
                                        

                                        Working like a charm!

                                        If you tested "/bin/mysgw -d" and all works as expected, make the installation permanent:

                                        make install
                                        

                                        Additional
                                        If you want to read data into a controller using a device file (i.e Mycontroller) use the build string below

                                         ./configure --spi-spidev-device=/dev/spidev1.0  --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
                                        

                                        Hope this helps!! have fun!!

                                        M Offline
                                        M Offline
                                        marceloaqno
                                        Code Contributor
                                        wrote on last edited by
                                        #104

                                        @Tag great! Thanks for the detailed explanation :clap:
                                        I will add to the instructions page

                                        1 Reply Last reply
                                        0
                                        • pansenP Offline
                                          pansenP Offline
                                          pansen
                                          wrote on last edited by
                                          #105

                                          out of curiousity: this all relates to 3.x kernel in armbian right? which has proprietary stuff in there?

                                          i read somewhere that mainline 4.10 SPI is "work in progress"

                                          Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

                                          T 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          21

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular