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. Announcements
  3. 💬 Building a Raspberry Pi Gateway

💬 Building a Raspberry Pi Gateway

Scheduled Pinned Locked Moved Announcements
1.1k Posts 173 Posters 422.7k Views 131 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.
  • ben999B ben999

    I feel a bit sorry to come back here for my own little troubles...

    1- So i installed openhab2 on RPi3 with a fresh SDCard
    2- I followed tobof 's excellent step-by-step howto
    3- I installed mysGateway
    4- With pi@raspberrypi:~/MySensors $ sudo ./examples_linux/mysGateway -d i can see that my motion sensor and my RPi gateway get on well... they do speak to each other, right ?

    mysGateway: Starting gateway...
    mysGateway: Protocol version - 2.0.1-beta
    mysGateway: MCO:BGN:INIT GW,CP=RNNG---,VER=2.0.1-beta
    mysGateway: TSF:LRT:OK
    mysGateway: TSM:INIT
    mysGateway: TSM:INIT:TSP OK
    mysGateway: TSM:INIT:GW MODE
    mysGateway: TSM:READY
    mysGateway: MCO:REG:NOT NEEDED
    mysGateway: MCO:BGN:STP
    mysGateway: MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
    

    5-in things/demo.things" I put this.

    Bridge mysensors:bridge-ser:gateway [ serialPort="/dev/pts/2", sendDelay=200 ] {  }
    

    Right away, it worked (king of the world!) and i could see that bridge in paperUI !!!
    But i got that after a reboot of RPi

    openhab> Failed to connect on port: /dev/pts/2 exception: 
    gnu.io.NoSuchPortException
            at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273)
            at gnu.io.NRSerialPort.connect(NRSerialPort.java:48)
            at org.openhab.binding.mysensors.protocol.serial.MySensorsSerialConnection.<init>(MySensorsSerialConnection.java:52)
            at org.openhab.binding.mysensors.handler.MySensorsBridgeHandler.initialize(MySensorsBridgeHandler.java:63)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:764)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:1)
            at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:177)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
    

    Wrong serial port ?

    Juste to make it clear : mysGateway bit of software is the magic that makes RPi believe that there's an arduino acting as a gateway on USB and collects the NRF24 info through GPio ?

    YveauxY Offline
    YveauxY Offline
    Yveaux
    Mod
    wrote on last edited by
    #114

    @ben999 said:

    Wrong serial port ?

    Likely ;-)
    /dev/pts/x are pseudo-terminals , not serial ports.

    On my (old) Pi running Raspbian the serial port is /dev/ttyAMA0
    You could run something like

    dmesg |grep -i tty
    

    to get an idea of serial ports on your Pi.

    http://yveaux.blogspot.nl

    ben999B 1 Reply Last reply
    1
    • YveauxY Yveaux

      @ben999 said:

      Wrong serial port ?

      Likely ;-)
      /dev/pts/x are pseudo-terminals , not serial ports.

      On my (old) Pi running Raspbian the serial port is /dev/ttyAMA0
      You could run something like

      dmesg |grep -i tty
      

      to get an idea of serial ports on your Pi.

      ben999B Offline
      ben999B Offline
      ben999
      wrote on last edited by
      #115

      @Yveaux thanks a lot for your answer. Understanding linux is a slow and painful process :laughing:

      Here is the output from your command : dmesg |grep -i tty

      pi@raspberrypi:~ $ dmesg |grep -i tty
      [    0.000000] Kernel command line: 8250.nr_uarts=0 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa02082 bcm2709.serial=0xcc3e67e3 smsc95xx.macaddr=B8:27:EB:3E:67:E3 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
      [    0.001337] console [tty1] enabled
      [    1.772114] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
      

      What a mess...
      ttyAMA0 is the one !!!
      Thanks @Yveaux you got me on the right path !!! Goto next step! :smile:

      1 Reply Last reply
      1
      • JahFyahhJ Offline
        JahFyahhJ Offline
        JahFyahh
        wrote on last edited by
        #116

        I just did a fresh install of pimatic and MsGateway on the pi. But pimatic does not seem to get de messages. i started the gateway via the daemon method, is there a way to see if the sensor is reaching the gateway?

        M 1 Reply Last reply
        0
        • H Offline
          H Offline
          hausinger
          wrote on last edited by
          #117

          @b0rmann
          Do you still using the rs485 usb "dongle" to connect the rs485 nodes to the rpi? Do you attached some more nodes to your rs485 rpi Gateway?
          Is it stable?
          How do you do the configuration for it?

          1 Reply Last reply
          0
          • JahFyahhJ JahFyahh

            I just did a fresh install of pimatic and MsGateway on the pi. But pimatic does not seem to get de messages. i started the gateway via the daemon method, is there a way to see if the sensor is reaching the gateway?

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

            @JahFyahh To view messages being exchanged with the sensors, run the gateway in debug mode:

            mysGateway -d
            
            1 Reply Last reply
            0
            • JahFyahhJ Offline
              JahFyahhJ Offline
              JahFyahh
              wrote on last edited by
              #119

              @marceloaqno thank you for the reply, I tried that and I receive "mysGateway: acce[t: Bad file descriptor" Any idea what this means?

              M 1 Reply Last reply
              0
              • JahFyahhJ JahFyahh

                @marceloaqno thank you for the reply, I tried that and I receive "mysGateway: acce[t: Bad file descriptor" Any idea what this means?

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

                @JahFyahh Could you provide the full debug log?

                1 Reply Last reply
                0
                • manulM Offline
                  manulM Offline
                  manul
                  wrote on last edited by
                  #121

                  Hi team,

                  First of all, thanks for this amazing project and this doc.
                  I'm trying to use arduino nanos with Raspberry Pi 2 as a gateway: I can get it working when I configure the Raspberry Pi using serial gateway, however, it does not work using MQTT with latest version from git.
                  The error message is:
                  "mysGateway: accept: Bad file descriptor"

                  I followed all explanations given on this page.
                  Any idea?
                  Thanks again

                  M 1 Reply Last reply
                  0
                  • manulM manul

                    Hi team,

                    First of all, thanks for this amazing project and this doc.
                    I'm trying to use arduino nanos with Raspberry Pi 2 as a gateway: I can get it working when I configure the Raspberry Pi using serial gateway, however, it does not work using MQTT with latest version from git.
                    The error message is:
                    "mysGateway: accept: Bad file descriptor"

                    I followed all explanations given on this page.
                    Any idea?
                    Thanks again

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

                    @manul Which MQTT broker are you using? Did you try to update it?

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hausinger
                      wrote on last edited by
                      #123

                      I wanted to use the mysGateway with a USB/RS485 converter.

                      Here is my config: ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 my-rs485-baudrate=57600

                      make does it's job, but after i start the gateway it says:
                      mysGateway: Starting gateway....
                      mysGateway: Protocol version - 2.0.1-beta
                      mysGateway: MCO:BGN:INIT GW,CP=RSNG---,VER=2.0.1-beta
                      mysGateway: TSM:INIT
                      mysGateway: TSM:INIT:TSP OK
                      mysGateway: TSM:INIT: GW Mode
                      mysGateway: TSM:READY

                      after that it stopped to work.

                      Whats wrong in my configuration?

                      M 1 Reply Last reply
                      0
                      • H hausinger

                        I wanted to use the mysGateway with a USB/RS485 converter.

                        Here is my config: ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 my-rs485-baudrate=57600

                        make does it's job, but after i start the gateway it says:
                        mysGateway: Starting gateway....
                        mysGateway: Protocol version - 2.0.1-beta
                        mysGateway: MCO:BGN:INIT GW,CP=RSNG---,VER=2.0.1-beta
                        mysGateway: TSM:INIT
                        mysGateway: TSM:INIT:TSP OK
                        mysGateway: TSM:INIT: GW Mode
                        mysGateway: TSM:READY

                        after that it stopped to work.

                        Whats wrong in my configuration?

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

                        @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?

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

                          The RPi port has just received a new update that changes some important things related to the location and name of the gateway binary and services:

                          mysGateway was renamed to mysgw
                          mysgateway service was renamed to mysgw

                          Now, after successfully running the make command, you will find the gateway file under ./bin/mygw

                          Also, before installing the new version you need to manually remove the old one:

                          If you are using systemd

                          sudo systemctl disable mysgateway.service
                          sudo rm /etc/systemd/system/mysgateway.service
                          sudo rm /usr/local/bin/mysGateway
                          

                          If you are using sysvinit

                          sudo update-rc.d -f mysgateway remove
                          sudo rm /etc/init.d/mysgateway
                          sudo rm /usr/local/bin/mysGateway
                          
                          1 Reply Last reply
                          2
                          • M marceloaqno

                            @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?

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

                            @marceloaqno said:

                            @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?

                            Thank you for your answer. I don't know, how to check that? The wiring to my nodes is correct, the serial port is correct (dmesg says that).
                            Could you confirm, that my configuration from my last post is correct?

                            M 2 Replies Last reply
                            0
                            • H hausinger

                              @marceloaqno said:

                              @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?

                              Thank you for your answer. I don't know, how to check that? The wiring to my nodes is correct, the serial port is correct (dmesg says that).
                              Could you confirm, that my configuration from my last post is correct?

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

                              @hausinger Your configuration is correct. To check the serial, install the screen package (if you haven't already done so) and run:

                              screen /dev/ttyUSB0 57600
                              

                              You should see some strange characters being printed.

                              I did a quick test here with your setup and found out that there is a bug with the gateway when the rs485 baud rate is set to 57600. With 9600 it works fine. I'll try to fix this.

                              1 Reply Last reply
                              0
                              • H hausinger

                                @marceloaqno said:

                                @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?

                                Thank you for your answer. I don't know, how to check that? The wiring to my nodes is correct, the serial port is correct (dmesg says that).
                                Could you confirm, that my configuration from my last post is correct?

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

                                @hausinger You forgot "--" for my-rs485-baudrate=57600 in your configuration.
                                It should be:

                                ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 --my-rs485-baudrate=57600
                                
                                H 1 Reply Last reply
                                0
                                • M marceloaqno

                                  @hausinger You forgot "--" for my-rs485-baudrate=57600 in your configuration.
                                  It should be:

                                  ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 --my-rs485-baudrate=57600
                                  
                                  H Offline
                                  H Offline
                                  hausinger
                                  wrote on last edited by
                                  #129

                                  @marceloaqno said:

                                  @hausinger You forgot "--" for my-rs485-baudrate=57600 in your configuration.
                                  It should be:

                                  ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 --my-rs485-baudrate=57600
                                  

                                  Hi @marceloaqno
                                  Thank you for your answers. Yes, i saw this, but I did the "--", i forgot it in the last post, because I can't use copy & paste on my raspberry (remote Desktop).

                                  Did this configuration work on your System?
                                  Are you sure, that my configuration is ok? (with the "--")
                                  Whats the normal behavior when i start the mysGateway with debug (mysGateway -d)? If i type the starting command in the terminal, the Gateway gives me the Messages (from my last post) and thats it (not more). I can now type a new command

                                  I'm now not at home (Business trip), if I get home, i will try your "Screen" command

                                  H 1 Reply Last reply
                                  0
                                  • jmmorgan83J Offline
                                    jmmorgan83J Offline
                                    jmmorgan83
                                    wrote on last edited by
                                    #130

                                    I followed the instruction above to make a mysgw file, but no file was generated.

                                    mfalkviddM 1 Reply Last reply
                                    0
                                    • jmmorgan83J jmmorgan83

                                      I followed the instruction above to make a mysgw file, but no file was generated.

                                      mfalkviddM Offline
                                      mfalkviddM Offline
                                      mfalkvidd
                                      Mod
                                      wrote on last edited by mfalkvidd
                                      #131

                                      @jmmorgan83 do you think there is any information you can share might help us help you?

                                      1 Reply Last reply
                                      0
                                      • jmmorgan83J Offline
                                        jmmorgan83J Offline
                                        jmmorgan83
                                        wrote on last edited by
                                        #132

                                        I reset everything and ran it again. It did generate the file this time. Thanks, - Now to test it.

                                        1 Reply Last reply
                                        0
                                        • jmmorgan83J Offline
                                          jmmorgan83J Offline
                                          jmmorgan83
                                          wrote on last edited by
                                          #133

                                          Has anyone gotten the raspberry pi gateway to work with Openhab on the same raspberry pi? I have both the virtual and mqtt gateways working, but I can get either one to communicate with Openhab.

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


                                          9

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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