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.
  • 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
                      • pansenP pansen

                        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"

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

                        @pansen
                        Yes correct, for OPI Zero only ARMbian 3.x is available as a download image.
                        I used the debian jessie one

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

                          Instructions page updated, let me know if there is any mistake.

                          T 1 Reply Last reply
                          0
                          • M marceloaqno

                            Instructions page updated, let me know if there is any mistake.

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

                            @marceloaqno

                            looks great!! thx!!:thumbsup:

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

                              Excellent work !!! It finally works, I believe the slight mistake was with the damn SPI device ID. Now that I've enabled /dev/spidev1.0 everything works perfect. Really nice job and awesome commitment to showing people that it's time for them to pull their heads out of their a.... and spend less for way more awesome boards because let's face it, RPi has the greatest community support but it's a nothing more than an expensive closed source crappy board.

                              T 1 Reply Last reply
                              0
                              • M mihai.aldea

                                Excellent work !!! It finally works, I believe the slight mistake was with the damn SPI device ID. Now that I've enabled /dev/spidev1.0 everything works perfect. Really nice job and awesome commitment to showing people that it's time for them to pull their heads out of their a.... and spend less for way more awesome boards because let's face it, RPi has the greatest community support but it's a nothing more than an expensive closed source crappy board.

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

                                @mihai.aldea
                                Great!!, found out the SPI0 is used for the NAND flash, once you add SPI1 to the script.bin, also the need board paragraph with bus 1 needs to be added otherwise it will not work.... anyway great you got mysensors up and running!!
                                About the RPI, i like both boards, and in my opinion the enormous success of the RPI is responsible, for the large collection of OPI boards that is available these days ;)

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

                                  There are few who know that lots of asian compaines were producing SBC's long before RPi ever existed. RPi has to take credit for the SBC boom, but the connaisseurs will always prefer a top notch SBC that costs less than half of an RPi and is piled with features. Take the OPi Zero for instance, it's way smaller than RPi 3, has half the RAM and doesn't have Bluetooth. But you can buy 4 OPi Zeros with the money you'd spend on an RPi 3.
                                  Anyway it's an endless debate here, I'm just glad I could help a bit bringing this to life, even though you and @marceloaqno did the heavy lifting.

                                  1 Reply Last reply
                                  0
                                  • Nca78N Offline
                                    Nca78N Offline
                                    Nca78
                                    Hardware Contributor
                                    wrote on last edited by
                                    #112

                                    Thank you for the hard work guys, I have a fresh orange pi zero and I will install armbian and try this hack as soon as possible. Looks like a great way to have an ultra compact&cheap controller + gateway system !

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

                                      Support for OrangePi is now part of the official MySensors development repository.
                                      In the official version, it is necessary to define the CE and CS pins, as the default ones will not work. This will change in the future, but more work needs to be done to better detect the different types of Orange Pi and other H3 soc boards.
                                      For now, if you have set your system in the same way as the wiring instructions, use:

                                      ./configure --spi-spidev-device=/dev/spidev1.0 --my-transport=nrf24 --my-rf24-ce-pin=2 --my-rf24-cs-pin=13
                                      
                                      T 1 Reply Last reply
                                      2
                                      • M marceloaqno

                                        Support for OrangePi is now part of the official MySensors development repository.
                                        In the official version, it is necessary to define the CE and CS pins, as the default ones will not work. This will change in the future, but more work needs to be done to better detect the different types of Orange Pi and other H3 soc boards.
                                        For now, if you have set your system in the same way as the wiring instructions, use:

                                        ./configure --spi-spidev-device=/dev/spidev1.0 --my-transport=nrf24 --my-rf24-ce-pin=2 --my-rf24-cs-pin=13
                                        
                                        T Offline
                                        T Offline
                                        Tag
                                        wrote on last edited by
                                        #114

                                        @marceloaqno

                                        Thank you for your hard work and continued support on this!!

                                        1 Reply Last reply
                                        0
                                        • M mihai.aldea

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

                                          S Offline
                                          S Offline
                                          sergey-sychev
                                          wrote on last edited by
                                          #115

                                          @mihai.aldea
                                          It's working on my OPi One with Armbian. MySensors and TMRh20 works!

                                          Only in ./MySensors: bin
                                          Only in ./MySensors: build
                                          diff -ruBdX ex ./_MySensors/drivers/RF24/RF24.cpp ./MySensors/drivers/RF24/RF24.cpp
                                          --- ./_MySensors/drivers/RF24/RF24.cpp<>2017-01-28 10:24:03.557215399 +0200
                                          +++ ./MySensors/drivers/RF24/RF24.cpp<->2017-01-28 10:58:51.757543157 +0200
                                          @@ -29,7 +29,7 @@
                                           LOCAL RF24_receiveCallbackType RF24_receiveCallback = NULL;
                                           #endif
                                          .
                                          -#ifdef LINUX_SPI_BCM
                                          +#if defined (LINUX_SPI_BCM) || (LINUX_SPI_SPIDEV)
                                           uint8_t spi_rxbuff[32+1] ; //SPI receive buffer (payload max 32 bytes)
                                           uint8_t spi_txbuff[32+1] ; //SPI transmit buffer (payload max 32 bytes + 1 byte for the command)
                                           #endif
                                          @@ -56,7 +56,7 @@
                                           <----->RF24_csn(LOW);
                                           <----->// timing
                                           <----->delayMicroseconds(10);
                                          -#ifdef LINUX_SPI_BCM
                                          +#if defined (LINUX_SPI_BCM) || (LINUX_SPI_SPIDEV)
                                           <----->uint8_t * prx = spi_rxbuff;
                                           <----->uint8_t * ptx = spi_txbuff;
                                           <----->uint8_t size = len + 1; // Add register value to transmit buffer
                                          diff -ruBdX ex ./_MySensors/Makefile.inc ./MySensors/Makefile.inc
                                          --- ./_MySensors/Makefile.inc<->2017-01-28 10:49:53.990638008 +0200
                                          +++ ./MySensors/Makefile.inc<-->2017-01-28 11:12:57.601198157 +0200
                                          @@ -1,5 +1,5 @@
                                           SOC=H3
                                          -CPPFLAGS=-march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV.
                                          +CPPFLAGS=-march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DLINUX_SPI_SPIDEV -DMY_RF24_CE_PIN=7 -DSPI_S
                                           LDFLAGS=-pthread.
                                           PREFIX=/usr/local
                                           CC=gcc
                                          
                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          26

                                          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