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.
  • jirmJ jirm

    @hausinger

    Of course you dont need any SPI bus.
    And so sorry but before I checked so badly the error you posted.

    Not seems any related working error for mysgw. I think you have mysgw working fine, seems only they can not connect/work with sensor node.

    You seems only need check node communication and adjust node configuration to have your mysgw working.

    I don't see you found so much trouble to make working from usb-rs485 adapter if you can do it with usb/serial node, it's only matter that the driver of adapter can work with mysgw without so much issues.

    Regards

    H Offline
    H Offline
    hausinger
    wrote on last edited by
    #31

    @jirm said:

    @hausinger

    Of course you dont need any SPI bus.
    And so sorry but before I checked so badly the error you posted.

    Not seems any related working error for mysgw. I think you have mysgw working fine, seems only they can not connect/work with sensor node.

    You seems only need check node communication and adjust node configuration to have your mysgw working.

    I don't see you found so much trouble to make working from usb-rs485 adapter if you can do it with usb/serial node, it's only matter that the driver of adapter can work with mysgw without so much issues.

    Regards

    Thank you for your fast answer.
    I try to answer it as best as I can.

    I tried it once again:
    connected the arduino to the USB port on my OPI
    DMESG says it is port ttyUSB0

    If i start the Gateway with:
    sudo ./bin/mysgw -d

    I got the same result as posted before. My CPU Usage is at 100% on one core.

    if I kill the process of mysgw and start openhab2 (my used controller) it can connect direct to the Arduino (connected as USB as before) and it worked fine.

    So my configuration of my nodes (currently only 1 for testing) is working fine through rs485.

    Summary:
    Connection node -> Arduino Gateway = OK
    Connetion from openhab2 to Arduino Gateway = OK (openhab2 on same OPI as Arduino)
    OPI as a Ethernet - Serial Gateway = NOT OK, Problem is shown on my screenshot.

    USB-RS485:
    I also tried this, but after my configuration:
    ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 --my-rs485-baudrate=57600
    I can do the "make" command.
    After that I start it with:
    sudo ./bin/mysgw -d
    I only get this:
    0_1483635312443_GatewayRS485.JPG
    I can now type a new command in the console (Gateway quit itself)

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

      Hi All,
      Collected some info on the OPI zero CPU:

      root@orangepizero:/proc# more cpuinfo
      Processor : ARMv7 Processor rev 5 (v7l)
      processor : 0
      BogoMIPS : 2400.00

      processor : 1
      BogoMIPS : 2400.00

      processor : 2
      BogoMIPS : 2400.00

      processor : 3
      BogoMIPS : 2400.00

      Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt
      CPU implementer : 0x41
      CPU architecture: 7
      CPU variant : 0x0
      CPU part : 0xc07
      CPU revision : 5

      Hardware : sun8i
      Revision : 0000
      Serial : 2467783d034e20000098
      root@orangepizero:/proc#

      Dmesg Output:
      [ 0.000000] Initializing cgroup subsys cpu
      [ 0.000000] Linux version 3.4.113-sun8i (root@xenial) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.1) ) #50 SMP PREEMPT Mon Nov
      14 08:41:55 CET 2016
      [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
      [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
      [ 0.000000] Machine: sun8i

      It should be a H2+, but I have seen H3 (think that was with an FTDI interface on the debug port....

      1 Reply Last reply
      0
      • H hausinger

        @jirm said:

        @hausinger

        Of course you dont need any SPI bus.
        And so sorry but before I checked so badly the error you posted.

        Not seems any related working error for mysgw. I think you have mysgw working fine, seems only they can not connect/work with sensor node.

        You seems only need check node communication and adjust node configuration to have your mysgw working.

        I don't see you found so much trouble to make working from usb-rs485 adapter if you can do it with usb/serial node, it's only matter that the driver of adapter can work with mysgw without so much issues.

        Regards

        Thank you for your fast answer.
        I try to answer it as best as I can.

        I tried it once again:
        connected the arduino to the USB port on my OPI
        DMESG says it is port ttyUSB0

        If i start the Gateway with:
        sudo ./bin/mysgw -d

        I got the same result as posted before. My CPU Usage is at 100% on one core.

        if I kill the process of mysgw and start openhab2 (my used controller) it can connect direct to the Arduino (connected as USB as before) and it worked fine.

        So my configuration of my nodes (currently only 1 for testing) is working fine through rs485.

        Summary:
        Connection node -> Arduino Gateway = OK
        Connetion from openhab2 to Arduino Gateway = OK (openhab2 on same OPI as Arduino)
        OPI as a Ethernet - Serial Gateway = NOT OK, Problem is shown on my screenshot.

        USB-RS485:
        I also tried this, but after my configuration:
        ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 --my-rs485-baudrate=57600
        I can do the "make" command.
        After that I start it with:
        sudo ./bin/mysgw -d
        I only get this:
        0_1483635312443_GatewayRS485.JPG
        I can now type a new command in the console (Gateway quit itself)

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

        @hausinger That shouldn't happen (gateway quitting itself). Could you submit the debug log with MY_DEBUG_VERBOSE_RF24 enabled?

        H 1 Reply Last reply
        0
        • M marceloaqno

          @hausinger That shouldn't happen (gateway quitting itself). Could you submit the debug log with MY_DEBUG_VERBOSE_RF24 enabled?

          H Offline
          H Offline
          hausinger
          wrote on last edited by
          #34

          @marceloaqno said:

          @hausinger That shouldn't happen (gateway quitting itself). Could you submit the debug log with MY_DEBUG_VERBOSE_RF24 enabled?

          Yes i can check that, but how?
          I tried it to enable it in "example_linux" => mysgw.cpp (added the line "#define MY_DEBUG_VERBOSE_RF24")
          I also tried it in the file: "MyConfig.h" (also added the line "#define MY_DEBUG_VERBOSE_RF24")

          But my output is still the same in the console.

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

            @Tag Just to make it clear, do you want to connect the RF24 radio directly on the OPi's GPIO pins? Or do you want to connect it first to an Arduino and then to the OPi?
            I haven't used the mysgw because so far I only played with EasyIoT (directly attached RF24 to RPi GPIO - doesn't work on OPi) and MyController (using an Arduino connected to the OPi's serial port).
            Since MySensors is open source you can definitely change the pin numbers to match the OPI's Sunxi pin numbering. I don't have a setup in place right now to point you in the exact direction but will cook one tomorrow and get back with the details.
            Meanwhile you can burn the GatewaySerial sketch on your Arduino and either use /bin/mysgw or:

            apt-get -y update
            apt-get -y install minicom
            minicom -D /dev/ttyUSB0
            

            It's likely that the minicom will scramble the text on your screen but you can:

            Ctrl+Z
            O
            Screen and Keyboard
            T
            Esc
            Save setup as df1
            

            Close the minicom window then open it again and all should be fine.

            T 1 Reply Last reply
            0
            • M mihai.aldea

              @Tag Just to make it clear, do you want to connect the RF24 radio directly on the OPi's GPIO pins? Or do you want to connect it first to an Arduino and then to the OPi?
              I haven't used the mysgw because so far I only played with EasyIoT (directly attached RF24 to RPi GPIO - doesn't work on OPi) and MyController (using an Arduino connected to the OPi's serial port).
              Since MySensors is open source you can definitely change the pin numbers to match the OPI's Sunxi pin numbering. I don't have a setup in place right now to point you in the exact direction but will cook one tomorrow and get back with the details.
              Meanwhile you can burn the GatewaySerial sketch on your Arduino and either use /bin/mysgw or:

              apt-get -y update
              apt-get -y install minicom
              minicom -D /dev/ttyUSB0
              

              It's likely that the minicom will scramble the text on your screen but you can:

              Ctrl+Z
              O
              Screen and Keyboard
              T
              Esc
              Save setup as df1
              

              Close the minicom window then open it again and all should be fine.

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

              @mihai.aldea

              Hi!, my idea is to have the NRF24 radio directly attached to the GPIO header on the OPI, (got this already working on my RPI system). So the idea is to run mysgw on the OPI system.
              (already got an extensive sensor network running with multiple arduinos and Mycontroller on thae RPI) On the RPI i had the arduino GW attached to USB and the NRF24 directly attached at the GPIO header at the same time, MyController saw 2 gateways :) )

              The other option like you already mentioned is to attach the arduino using USB read from /dev/ttyUSB0. I see this as a last resort only if mysgw will never run on the OPI zero.

              I read on the OPI website that the 26 pin header from the OPI is directly compatible with the RPI, however other sources of information tell me differently. So if you want to help out with the pin numbering this is greatly appreciated!

              but again mysgw on the OPI with the radio on the GPIO header would be great!!

              At this moment we try to build/compile mysgw on the OPI board, however that fails at the SPI part.

              Thanks!

              1 Reply Last reply
              0
              • H hausinger

                I'm using a orangepi one and with your help I can compile it.
                I tried it with a serial gateway. I connected a arduino nano with the gateway serial scath on it through USB to my orangepi one. DMESG say to me, that it is attached to ttyUSB0
                So i tried to build the gateway with:
                ./configure --my-gateway=serial --my-serial-port=/dev/ttyUSB0 --my-serial-baudrate=115200

                make has no errors

                after that, i tried to start it with:
                sudo ./bin/mysgw -d

                Is started but i get this problem:
                (0_1483630831348_Gateway_problem.JPG

                Do you know whats wrong with it?

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

                @hausinger The problem you are having with your serial gateway (./configure --my-gateway=serial --my-serial-port=/dev/ttyUSB0 --my-serial-baudrate=115200) may be related to this bug:
                https://github.com/mysensors/MySensors/issues/720#issuecomment-270712256

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

                  @Tag I made the test setup and retraced my steps from the previous experiment. While the TMRh20 is working, the problem indeed lies with the ** mysgw** compilation. I'm getting the same error.
                  After spending quite some time trying to mitigate the errors I hit a wall and I concluded that the problem is not the different pin numbering but the mysgw source code. I believe the problem is the lack of support for this architecture and with MySensors being so complex and my C++ skills so average, I'm afraid I can't help.
                  However, if someone can mitigate the source code to successfully compile, the radio should be initialized with:
                  RF24 radio(7, 0);
                  7 - CE pin
                  0 - CS pin
                  More details here: https://github.com/TMRh20/RF24/issues/257

                  T 1 Reply Last reply
                  0
                  • M mihai.aldea

                    @Tag I made the test setup and retraced my steps from the previous experiment. While the TMRh20 is working, the problem indeed lies with the ** mysgw** compilation. I'm getting the same error.
                    After spending quite some time trying to mitigate the errors I hit a wall and I concluded that the problem is not the different pin numbering but the mysgw source code. I believe the problem is the lack of support for this architecture and with MySensors being so complex and my C++ skills so average, I'm afraid I can't help.
                    However, if someone can mitigate the source code to successfully compile, the radio should be initialized with:
                    RF24 radio(7, 0);
                    7 - CE pin
                    0 - CS pin
                    More details here: https://github.com/TMRh20/RF24/issues/257

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

                    @mihai.aldea said:

                    us experiment. While the TMRh20 is working, the problem indeed lies with the ** mysgw** compilation. I'm getting the same error.

                    Thanks for the confirmation!!, now lets hope that mysgw, will be fixed/ported to the OPI boards soon!
                    would be great to expand the number of systems it will run on..

                    R 1 Reply Last reply
                    0
                    • T Tag

                      @mihai.aldea said:

                      us experiment. While the TMRh20 is working, the problem indeed lies with the ** mysgw** compilation. I'm getting the same error.

                      Thanks for the confirmation!!, now lets hope that mysgw, will be fixed/ported to the OPI boards soon!
                      would be great to expand the number of systems it will run on..

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

                      @Tag
                      Could you setup my sensors gateway on orange pi one? if you can please help me to build this . thank you

                      T 1 Reply Last reply
                      0
                      • R Reza

                        @Tag
                        Could you setup my sensors gateway on orange pi one? if you can please help me to build this . thank you

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

                        @Reza

                        Unfortunately the mysgw software does not run native on the OPI systems at this moment.The only option today is to add an arduino to the USB port running i.e the serial gateway sketch (if you do not want to use the USB port, an other option would be using an UART trough the GPIO header, you data will show up on i.e. /dev/ttyS1 if UART 1 is used)

                        step 2 will be to install controller software.
                        (i tested MyController on the OPI and that works like a charm, and looks pretty cool!)

                        See this link on how to build a serial gateway on the arduino. Using this setup you can follow the RaspberryPI tutorials.

                        Hopefully mysgw will run soon on the OrangePI systems! think this is work in progress......

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          marceloaqno
                          Code Contributor
                          wrote on last edited by marceloaqno
                          #42

                          I'm trying to add support for Orange Pi to MySensors, this is the work-in-progress repository:
                          https://github.com/marceloaqno/MySensors/tree/spidev

                          It would be great if someone could test and submit results from the configure and make commands:

                          git clone https://github.com/marceloaqno/MySensors marceloaqno-spidev
                          cd marceloaqno-spidev
                          git checkout spidev
                          ./configure
                          make
                          
                          T 2 Replies Last reply
                          1
                          • M marceloaqno

                            I'm trying to add support for Orange Pi to MySensors, this is the work-in-progress repository:
                            https://github.com/marceloaqno/MySensors/tree/spidev

                            It would be great if someone could test and submit results from the configure and make commands:

                            git clone https://github.com/marceloaqno/MySensors marceloaqno-spidev
                            cd marceloaqno-spidev
                            git checkout spidev
                            ./configure
                            make
                            
                            T Offline
                            T Offline
                            Tag
                            wrote on last edited by
                            #43

                            @marceloaqno

                            Hi!, really appreciate your hard work on this!!, below are the results,
                            (I was not able to execute the 1st command :( but... tried something else..

                            root@orangepizero:~# git clone https://github.com/marceloaqno/MySensors.git marceloaqno-spidev
                            Cloning into 'marceloaqno-spidev'...
                            remote: Counting objects: 13834, done.
                            remote: Compressing objects: 100% (26/26), done.
                            remote: Total 13834 (delta 2), reused 0 (delta 0), pack-reused 13808
                            Receiving objects: 100% (13834/13834), 9.67 MiB | 3.16 MiB/s, done.
                            Resolving deltas: 100% (8289/8289), done.
                            Checking connectivity... done.
                            root@orangepizero:~# cd marceloaqno-spidev
                            root@orangepizero:~/marceloaqno-spidev# git checkout spidev
                            Branch spidev set up to track remote branch spidev from origin.
                            Switched to a new branch 'spidev'

                            root@orangepizero:~/marceloaqno-spidev# ./configure
                            [SECTION] Detecting target machine.
                            [OK] machine detected: SoC=H3, Type=unknown, CPU=armv7l.
                            [SECTION] Detecting SPI driver.
                            [OK] SPI driver detected:SPIDEV.
                            [SECTION] Detecting init system.
                            [OK] init system detected: systemd.
                            [SECTION] Saving configuration.
                            [SECTION] Cleaning previous builds.
                            [OK] Finished.
                            root@orangepizero:~/marceloaqno-spidev# make
                            gcc -MT build/drivers/Linux/log.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/log.c -o build/drivers/Linux/log.o
                            g++ -MT build/drivers/Linux/noniso.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/noniso.cpp -o build/drivers/Linux/noniso.o
                            g++ -MT build/drivers/Linux/GPIO.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/GPIO.cpp -o build/drivers/Linux/GPIO.o
                            g++ -MT build/drivers/Linux/Print.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/Print.cpp -o build/drivers/Linux/Print.o
                            g++ -MT build/drivers/Linux/EthernetClient.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/EthernetClient.cpp -o build/drivers/Linux/EthernetClient.o
                            g++ -MT build/drivers/Linux/SerialPort.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/SerialPort.cpp -o build/drivers/Linux/SerialPort.o
                            g++ -MT build/drivers/Linux/Stream.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/Stream.cpp -o build/drivers/Linux/Stream.o
                            g++ -MT build/drivers/Linux/IPAddress.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/IPAddress.cpp -o build/drivers/Linux/IPAddress.o
                            g++ -MT build/drivers/Linux/compatibility.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/compatibility.cpp -o build/drivers/Linux/compatibility.o
                            g++ -MT build/drivers/Linux/interrupt.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/interrupt.cpp -o build/drivers/Linux/interrupt.o
                            g++ -MT build/drivers/Linux/SoftEeprom.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/SoftEeprom.cpp -o build/drivers/Linux/SoftEeprom.o
                            g++ -MT build/drivers/Linux/EthernetServer.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/EthernetServer.cpp -o build/drivers/Linux/EthernetServer.o
                            g++ -MT build/examples_linux/mysgw.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c examples_linux/mysgw.cpp -o build/examples_linux/mysgw.o
                            /tmp/ccVhf8xP.s: Assembler messages:
                            /tmp/ccVhf8xP.s:14808: Warning: IT blocks containing 32-bit Thumb instructions are deprecated in ARMv8
                            g++ -MT build/drivers/SPIDEV/SPI.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_GPIO_CAPABLE -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/SPIDEV/SPI.cpp -o build/drivers/SPIDEV/SPI.o
                            g++ -pthread -o bin/mysgw build/drivers/Linux/log.o build/drivers/Linux/noniso.o build/drivers/Linux/GPIO.o build/drivers/Linux/Print.o build/drivers/Linux/EthernetClient.o build/drivers/Linux/SerialPort.o build/drivers/Linux/Stream.o build/drivers/Linux/IPAddress.o build/drivers/Linux/compatibility.o build/drivers/Linux/interrupt.o build/drivers/Linux/SoftEeprom.o build/drivers/Linux/EthernetServer.o build/examples_linux/mysgw.o build/drivers/SPIDEV/SPI.o

                            root@orangepizero:~/marceloaqno-spidev# ll bin
                            total 640
                            -rwxr-xr-x 1 root root 654544 Jan 7 22:48 mysgw

                            Seems we have a binary!!
                            :D

                            1 Reply Last reply
                            0
                            • M marceloaqno

                              I'm trying to add support for Orange Pi to MySensors, this is the work-in-progress repository:
                              https://github.com/marceloaqno/MySensors/tree/spidev

                              It would be great if someone could test and submit results from the configure and make commands:

                              git clone https://github.com/marceloaqno/MySensors marceloaqno-spidev
                              cd marceloaqno-spidev
                              git checkout spidev
                              ./configure
                              make
                              
                              T Offline
                              T Offline
                              Tag
                              wrote on last edited by Tag
                              #44

                              @marceloaqno

                              Just hooked up a radio to the GPIO header. (used this link for the model 1 RPI https://www.mysensors.org/build/raspberry and attached the interrupt pin also to pin 15)

                              This is the result i get
                              root@orangepizero:~/marceloaqno-spidev/bin# mysgw
                              mysgw: Starting gateway...
                              mysgw: Protocol version - 2.2.0-beta
                              mysgw: Could not open /sys/class/gpio/gpio10/direction
                              Illegal instruction
                              root@orangepizero:~/marceloaqno-spidev/bin#

                              M 2 Replies Last reply
                              0
                              • T Tag

                                @marceloaqno

                                Just hooked up a radio to the GPIO header. (used this link for the model 1 RPI https://www.mysensors.org/build/raspberry and attached the interrupt pin also to pin 15)

                                This is the result i get
                                root@orangepizero:~/marceloaqno-spidev/bin# mysgw
                                mysgw: Starting gateway...
                                mysgw: Protocol version - 2.2.0-beta
                                mysgw: Could not open /sys/class/gpio/gpio10/direction
                                Illegal instruction
                                root@orangepizero:~/marceloaqno-spidev/bin#

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

                                @Tag Great! The mapping of the physical GPIO number in OrangePi is not ready yet, so you need to figure out the correct value for the CE and CSN pins by adding this to the examples_linux/mysgw.cpp or MyConfig.h

                                #define MY_RF24_CE_PIN X
                                #define MY_RF24_CS_PIN Y
                                

                                This is the best pinout image I've found that could help:
                                https://oshlab.com/orange-pi-zero-pinout/

                                This may also give you some hint:

                                cat /sys/kernel/debug/gpio
                                
                                M 1 Reply Last reply
                                0
                                • M marceloaqno

                                  @Tag Great! The mapping of the physical GPIO number in OrangePi is not ready yet, so you need to figure out the correct value for the CE and CSN pins by adding this to the examples_linux/mysgw.cpp or MyConfig.h

                                  #define MY_RF24_CE_PIN X
                                  #define MY_RF24_CS_PIN Y
                                  

                                  This is the best pinout image I've found that could help:
                                  https://oshlab.com/orange-pi-zero-pinout/

                                  This may also give you some hint:

                                  cat /sys/kernel/debug/gpio
                                  
                                  M Offline
                                  M Offline
                                  marceloaqno
                                  Code Contributor
                                  wrote on last edited by marceloaqno
                                  #46

                                  @Tag Maybe this one can help too:
                                  http://orange314.com/WiringOP

                                  M 1 Reply Last reply
                                  0
                                  • M marceloaqno

                                    @Tag Maybe this one can help too:
                                    http://orange314.com/WiringOP

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

                                    @Tag also, please don't set the interrupt pin for now.

                                    1 Reply Last reply
                                    0
                                    • T Tag

                                      @marceloaqno

                                      Just hooked up a radio to the GPIO header. (used this link for the model 1 RPI https://www.mysensors.org/build/raspberry and attached the interrupt pin also to pin 15)

                                      This is the result i get
                                      root@orangepizero:~/marceloaqno-spidev/bin# mysgw
                                      mysgw: Starting gateway...
                                      mysgw: Protocol version - 2.2.0-beta
                                      mysgw: Could not open /sys/class/gpio/gpio10/direction
                                      Illegal instruction
                                      root@orangepizero:~/marceloaqno-spidev/bin#

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

                                      @Tag I found more information on the wiki page about the gpio pins:
                                      http://linux-sunxi.org/GPIO

                                      It seems that there is a calculation to be made to know which number to use :scream:

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

                                        @marceloaqno

                                        Hi!!, many thanks for the info!! really helpful!
                                        Made some progress. first I created this table based on this page: http://linux-sunxi.org/GPIO

                                        Pin - Num - Name - Calculated value A=1 ((1-1)*32 + Pin)
                                        CE / 22 / PA02 / 2
                                        SCK / 23 / PA14 / 14
                                        MISO / 21 / PA16 / 16
                                        CSN / 24 / PA13 / 13
                                        MOSI / 19 / PA15 / 15

                                        Now it is important that you know which kernel is used on your systems the 4.x architecture is different compared to the 3.x arch...

                                        If the 4.x kernel is used you need to use the calculated value for the GPIO pin numbering, i could not test that since I am using the 3.x kernel, so this is what i did:

                                        1. load the GPIO kernel module:
                                        modprobe gpio-sunxi
                                        
                                        1. Create the GPIO device files since these were not available on my system by default.
                                        for A in 1 2 3 4 5 6 7 8 9 10 11 12; do echo "$A" > /sys/class/gpio/export ; done
                                        

                                        This created the following entries in /sys/class/gpio

                                        root@orangepizero:~/marceloaqno-spidev/bin# ls -l /sys/class/gpio
                                        total 0
                                        --w------- 1 root root 4096 Jan  8 07:39 export
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio1 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio1
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio11 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio11
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio12 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio12
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:32 gpio13 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio13
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio2 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio2
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio3 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio3
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio4 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio4
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio5 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio5
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio6 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio6
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio7 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio7
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio8 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio8
                                        lrwxrwxrwx 1 root root    0 Jan  8 07:16 gpio9 -> ../../devices/platform/sunxi-pinctrl/gpio/gpio9
                                        lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip0 -> ../../devices/platform/sunxi-pinctrl/gpio/gpiochip0
                                        --w------- 1 root root 4096 Jan  1  1970 unexport
                                        

                                        Modified mysgw.cpp to use:

                                        #define MY_RF24_CE_PIN 2
                                        #define MY_RF24_CS_PIN 13
                                        

                                        And did a clean build:

                                        make clean
                                        ./configure
                                        make
                                        

                                        Now some thing has changed! :)

                                        root@orangepizero:~/marceloaqno-spidev/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
                                        

                                        Will do some more testing with an LED today see if the GPIO pin numbering that was created is okay,

                                        will keep you posted!:

                                        M 1 Reply Last reply
                                        1
                                        • T Offline
                                          T Offline
                                          Tag
                                          wrote on last edited by Tag
                                          #50

                                          @marceloaqno
                                          Did some testing,

                                          Setup the GPIO pins:

                                          modprobe gpio-sunxi
                                          
                                          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
                                          

                                          (The device files that are created by the commands above do not survive a reboot, so remember to execute the above commands after each reboot!)

                                          Hooked up an led between ground and i.e. pin 22, this pin is linked to GPIO2

                                          Then:

                                          echo out > /sys/class/gpio/gpio2/direction
                                          echo 1 > /sys/class/gpio/gpio2/value
                                          echo 0 > /sys/class/gpio/gpio2/value
                                          
                                          

                                          And eureka!! Led went on and off :D

                                          Did this for all GPIO ports used by mysgw, below is the verified pin / GPIO table

                                          Pin#  -  GPIO / NRF24 
                                          22 - GPIO2   / CE
                                          23 - GPIO14  / SCK
                                          21 - GPIO16  / MISO
                                          24 - GPIO13  / CSN
                                          19 - GPIO15  / MOSI
                                          

                                          Tested all pins and led went on and off on all

                                          How i connected the radio: https://www.mysensors.org/build/raspberry (see the Pi1 part)
                                          How to setup GPIO: http://linux-sunxi.org/GPIO (3.x kernel part, and added pin 13/14/15/16)
                                          Pinout for the OPI Zero: https://i1.wp.com/oshlab.com/wp-content/uploads/2016/11/Orange-Pi-Zero-Pinout-banner2.jpg?fit=1200%2C628&ssl=1 (carefully look at the pin numbering!)

                                          Maybe it is usefull, I rebuild mysgw with NRF24 radio debugging enabled, this is the output I get:

                                          root@orangepizero:~/marceloaqno-spidev/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=0
                                          mysgw: RF24:read register, reg=5, value=0
                                          mysgw: !RF24:INIT:SANCHK FAIL
                                          mysgw: !TSM:INIT:TSP FAIL
                                          mysgw: TSM:FAIL:CNT=1
                                          mysgw: TSM:FAIL:PDT
                                          mysgw: RF24:write register, reg=0, value=12
                                          mysgw: RF24:PD
                                          ^Cmysgw: Received SIGINT
                                          

                                          keeps looping, until ctrl-c is given.

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


                                          18

                                          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