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 428.3k 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.
  • M marceloaqno

    @Reza You could connect the rs485 to the RPi UART and use the option --my-rs485-serial-port=/dev/ttyAMA0, but you need to turning off the UART functioning as a serial console.

    Or, to make things easier:
    rs485 <==> TTL/USB <==> RPi

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

    @marceloaqno
    i am beginner and i can not turning off the UART functioning. . . also on some board usb port after power off/on lost and i should disconnect/connect cable... i test your steps serial gateway with raspberry and GPIO with virtual usb serial . and i see this problem solve and after power off/on gateway is connect .
    i suggest that you add this commands to page of rs485 gateway step by step and update this .
    (https://www.mysensors.org/build/rs485)

    I thank you for hard working and trying

    b0rmannB 1 Reply Last reply
    0
    • R Reza

      @marceloaqno
      i am beginner and i can not turning off the UART functioning. . . also on some board usb port after power off/on lost and i should disconnect/connect cable... i test your steps serial gateway with raspberry and GPIO with virtual usb serial . and i see this problem solve and after power off/on gateway is connect .
      i suggest that you add this commands to page of rs485 gateway step by step and update this .
      (https://www.mysensors.org/build/rs485)

      I thank you for hard working and trying

      b0rmannB Offline
      b0rmannB Offline
      b0rmann
      wrote on last edited by b0rmann
      #301

      @Reza

      if you want use rpi /dev/ttyAMA0 for rs485 gateway -

      1. remove string "console=serial0,115200" from /boot/cmdline.txt
      2. add strings "enable_uart=1" and "dtoverlay=pi3-disable-bt" to /boot/config.txt (only on rpi3)
      3. reboot raspi
      R 1 Reply Last reply
      1
      • M marceloaqno

        @marceltrapman

        If you use the --my-controller-ip-address= option, the gateway will act as a client and attempt to conect to the supplied ip and port. If you want the gateway to open port 5003, omit this option.

        marceltrapmanM Offline
        marceltrapmanM Offline
        marceltrapman
        Mod
        wrote on last edited by marceltrapman
        #302

        @marceloaqno nice, working now :+1:

        Thank you...

        Fulltime Servoy Developer
        Parttime Moderator MySensors board

        I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
        I have a FABtotum to print cases.

        1 Reply Last reply
        0
        • b0rmannB b0rmann

          @Reza

          if you want use rpi /dev/ttyAMA0 for rs485 gateway -

          1. remove string "console=serial0,115200" from /boot/cmdline.txt
          2. add strings "enable_uart=1" and "dtoverlay=pi3-disable-bt" to /boot/config.txt (only on rpi3)
          3. reboot raspi
          R Offline
          R Offline
          Reza
          wrote on last edited by
          #303

          @b0rmann
          thank you friend , but i am sorry i am very beginner in raspberry pi . because i use vera before and with raspberry and orange pi i use recently. so i need a full steps for a rs485 gateway(wiring and commands . . .) i dont know what is ttyAMA0 ! i use a serial gateway with usb port with raspberrypi 3 but i have some problem , but with a raspberrypi gateway and use a virtual serial port (ttyUSB020) all of my problem resolve. but i have problem with wireless. so i want have a wiring network. i want a full steps for setup a rs485 module with raspberrypi 3(wiring and steps for install...) thank you for help

          M 1 Reply Last reply
          0
          • AndurilA Offline
            AndurilA Offline
            Anduril
            wrote on last edited by
            #304

            Do I read that correctly, does this gateway also gives a ethernet link to a serial-only controller? How do I have to configure ip and port? In the build section I see no option to set them.

            T 1 Reply Last reply
            0
            • E ericvdb

              use sudo ;)

              LaMB95L Offline
              LaMB95L Offline
              LaMB95
              wrote on last edited by
              #305

              @LaMB95 said:

              @ericvdb

              0_1484579303843_Screen Shot 2017-01-16 at 7.08.05 PM.png

              Okay what could be the problem? :3

              1 Reply Last reply
              0
              • R Reza

                @b0rmann
                thank you friend , but i am sorry i am very beginner in raspberry pi . because i use vera before and with raspberry and orange pi i use recently. so i need a full steps for a rs485 gateway(wiring and commands . . .) i dont know what is ttyAMA0 ! i use a serial gateway with usb port with raspberrypi 3 but i have some problem , but with a raspberrypi gateway and use a virtual serial port (ttyUSB020) all of my problem resolve. but i have problem with wireless. so i want have a wiring network. i want a full steps for setup a rs485 module with raspberrypi 3(wiring and steps for install...) thank you for help

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

                @Reza There are many guides on the web teaching how to connect and use rs485 with the RPi. I recommend you start with them and when you are sure it is working, you add MySensors to the equation.

                R 1 Reply Last reply
                0
                • M marceloaqno

                  @Reza There are many guides on the web teaching how to connect and use rs485 with the RPi. I recommend you start with them and when you are sure it is working, you add MySensors to the equation.

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

                  @marceloaqno said:

                  There are many guides on the web teaching how to connect and use rs485 with the RPi. I recommend you start with them and when you are sure it is working, you add MySensors to the equation.

                  ok thank you :(

                  1 Reply Last reply
                  0
                  • AndurilA Anduril

                    Do I read that correctly, does this gateway also gives a ethernet link to a serial-only controller? How do I have to configure ip and port? In the build section I see no option to set them.

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

                    @Anduril
                    you will get all the build options for the mysgw with the command

                    ./configure -help
                    

                    Here you can configure all options like serial and ethernet

                    1 Reply Last reply
                    0
                    • AndurilA Offline
                      AndurilA Offline
                      Anduril
                      wrote on last edited by
                      #309

                      just cloned and read the --help, but still I don't know how to use.
                      To make it a litte less abstract: I have a ethernet gateway (ESP8266) running at 192.168.38.19 with port 5003 to connect to. I want to have this accessible by a serial-only controller on the raspberry.

                      I tried to do this config and make afterwards, but starting gave only FAILs...

                      ./configure --my-gateway=ethernet --my-controller-ip-address=192.168.38.19 --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
                      
                      ~/MySensors$ sudo ./bin/mysgw -d
                      mysgw: Starting gateway...
                      mysgw: Protocol version - 2.1.0
                      mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0
                      mysgw: TSF:LRT:OK
                      mysgw: TSM:INIT
                      mysgw: TSF:WUR:MS=0
                      mysgw: !TSM:INIT:TSP FAIL
                      mysgw: TSM:FAIL:CNT=1
                      mysgw: TSM:FAIL:PDT
                      mysgw: TSM:FAIL:RE-INIT
                      mysgw: TSM:INIT
                      mysgw: !TSM:INIT:TSP FAIL
                      mysgw: TSM:FAIL:CNT=2
                      mysgw: TSM:FAIL:PDT
                      mysgw: TSM:FAIL:RE-INIT
                      mysgw: TSM:INIT
                      mysgw: !TSM:INIT:TSP FAIL
                      mysgw: TSM:FAIL:CNT=3
                      mysgw: TSM:FAIL:PDT
                      mysgw: TSM:FAIL:RE-INIT
                      mysgw: TSM:INIT
                      mysgw: !TSM:INIT:TSP FAIL
                      mysgw: TSM:FAIL:CNT=4
                      mysgw: TSM:FAIL:PDT
                      

                      I think my config is wrong and it tries to connect to a nrf24 at the rpi. So what's the correct config for my case?

                      Thanks in advance.

                      gohanG 1 Reply Last reply
                      0
                      • AndurilA Anduril

                        just cloned and read the --help, but still I don't know how to use.
                        To make it a litte less abstract: I have a ethernet gateway (ESP8266) running at 192.168.38.19 with port 5003 to connect to. I want to have this accessible by a serial-only controller on the raspberry.

                        I tried to do this config and make afterwards, but starting gave only FAILs...

                        ./configure --my-gateway=ethernet --my-controller-ip-address=192.168.38.19 --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
                        
                        ~/MySensors$ sudo ./bin/mysgw -d
                        mysgw: Starting gateway...
                        mysgw: Protocol version - 2.1.0
                        mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0
                        mysgw: TSF:LRT:OK
                        mysgw: TSM:INIT
                        mysgw: TSF:WUR:MS=0
                        mysgw: !TSM:INIT:TSP FAIL
                        mysgw: TSM:FAIL:CNT=1
                        mysgw: TSM:FAIL:PDT
                        mysgw: TSM:FAIL:RE-INIT
                        mysgw: TSM:INIT
                        mysgw: !TSM:INIT:TSP FAIL
                        mysgw: TSM:FAIL:CNT=2
                        mysgw: TSM:FAIL:PDT
                        mysgw: TSM:FAIL:RE-INIT
                        mysgw: TSM:INIT
                        mysgw: !TSM:INIT:TSP FAIL
                        mysgw: TSM:FAIL:CNT=3
                        mysgw: TSM:FAIL:PDT
                        mysgw: TSM:FAIL:RE-INIT
                        mysgw: TSM:INIT
                        mysgw: !TSM:INIT:TSP FAIL
                        mysgw: TSM:FAIL:CNT=4
                        mysgw: TSM:FAIL:PDT
                        

                        I think my config is wrong and it tries to connect to a nrf24 at the rpi. So what's the correct config for my case?

                        Thanks in advance.

                        gohanG Offline
                        gohanG Offline
                        gohan
                        Mod
                        wrote on last edited by
                        #310

                        @Anduril
                        Why are you using an esp8266 as a serial gateway? Wouldn't it be easier to use a normal UNO?

                        1 Reply Last reply
                        0
                        • AndurilA Offline
                          AndurilA Offline
                          Anduril
                          wrote on last edited by
                          #311

                          I'm using a ESP8266 as ethernet gateway and want to have this connected as virtuall serial port to my raspberry pi so my controller can connect to that.

                          gohanG 1 Reply Last reply
                          0
                          • lakshmcL Offline
                            lakshmcL Offline
                            lakshmc
                            wrote on last edited by
                            #312

                            I using RPi2 and NRF24 for this. I followed the instructions, to clone the repo, and then added config
                            ./configure --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1 --my-transport=nrf24

                            make

                            when i run with sudo ./bin/mysgw -d, it is failing to connect to MQTT. Can you please help?

                            mysgw: Starting gateway...
                            mysgw: Protocol version - 2.1.0
                            mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0
                            mysgw: TSF:LRT:OK
                            mysgw: TSM:INIT
                            mysgw: TSF:WUR:MS=0
                            mysgw: TSM:INIT:TSP OK
                            mysgw: TSM:INIT:GW MODE
                            mysgw: TSM:READY:ID=0,PAR=0,DIS=0
                            mysgw: MCO:REG:NOT NEEDED
                            mysgw: MCO:BGN:STP
                            mysgw: MCO:BGN:INIT OK,TSP=1
                            mysgw: Attempting MQTT connection...
                            mysgw: connect: Connection refused
                            mysgw: failed to connect
                            mysgw: Attempting MQTT connection...
                            mysgw: connect: Connection refused
                            mysgw: failed to connect
                            mysgw: Attempting MQTT connection...
                            mysgw: connect: Connection refused
                            mysgw: failed to connect
                            mysgw: Attempting MQTT connection...
                            mysgw: connect: Connection refused
                            mysgw: failed to connect

                            P 1 Reply Last reply
                            0
                            • AndurilA Anduril

                              I'm using a ESP8266 as ethernet gateway and want to have this connected as virtuall serial port to my raspberry pi so my controller can connect to that.

                              gohanG Offline
                              gohanG Offline
                              gohan
                              Mod
                              wrote on last edited by
                              #313

                              @Anduril

                              Have you aver considered Using the GatewayESP8266MQTTClient? What controller are you trying to connect?

                              1 Reply Last reply
                              0
                              • AndurilA Offline
                                AndurilA Offline
                                Anduril
                                wrote on last edited by
                                #314

                                I use pimatic which does not have a native compatibility to ethernet or mqtt. Thats why my question came up on how to configure it to do this...

                                Building a Raspberry Pi Gateway:

                                If you are running a controller on the Raspberry Pi that doesn't support communication with the gateway through ethernet, you can use a virtual serial port:
                                ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway

                                mfalkviddM 1 Reply Last reply
                                0
                                • AndurilA Anduril

                                  I use pimatic which does not have a native compatibility to ethernet or mqtt. Thats why my question came up on how to configure it to do this...

                                  Building a Raspberry Pi Gateway:

                                  If you are running a controller on the Raspberry Pi that doesn't support communication with the gateway through ethernet, you can use a virtual serial port:
                                  ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway

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

                                  @Anduril you might be able to use nodered or socat to convert the tcp connection to a serial port.
                                  https://linux.die.net/man/1/socat
                                  https://nodered.org/

                                  1 Reply Last reply
                                  0
                                  • AndurilA Offline
                                    AndurilA Offline
                                    Anduril
                                    wrote on last edited by
                                    #316

                                    that's what I tried in the past and am using now (socat), but it does not reconnect and has some other drawbacks. Reading of an officially supported way sounded interesting

                                    1 Reply Last reply
                                    0
                                    • lakshmcL lakshmc

                                      I using RPi2 and NRF24 for this. I followed the instructions, to clone the repo, and then added config
                                      ./configure --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1 --my-transport=nrf24

                                      make

                                      when i run with sudo ./bin/mysgw -d, it is failing to connect to MQTT. Can you please help?

                                      mysgw: Starting gateway...
                                      mysgw: Protocol version - 2.1.0
                                      mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0
                                      mysgw: TSF:LRT:OK
                                      mysgw: TSM:INIT
                                      mysgw: TSF:WUR:MS=0
                                      mysgw: TSM:INIT:TSP OK
                                      mysgw: TSM:INIT:GW MODE
                                      mysgw: TSM:READY:ID=0,PAR=0,DIS=0
                                      mysgw: MCO:REG:NOT NEEDED
                                      mysgw: MCO:BGN:STP
                                      mysgw: MCO:BGN:INIT OK,TSP=1
                                      mysgw: Attempting MQTT connection...
                                      mysgw: connect: Connection refused
                                      mysgw: failed to connect
                                      mysgw: Attempting MQTT connection...
                                      mysgw: connect: Connection refused
                                      mysgw: failed to connect
                                      mysgw: Attempting MQTT connection...
                                      mysgw: connect: Connection refused
                                      mysgw: failed to connect
                                      mysgw: Attempting MQTT connection...
                                      mysgw: connect: Connection refused
                                      mysgw: failed to connect

                                      P Offline
                                      P Offline
                                      pete1450
                                      wrote on last edited by pete1450
                                      #317

                                      @lakshmc Make sure you don't have the daemon running already

                                      If not, I'm getting the same problem on the 2.1.1 that was just released. 2.1.0 was working "fine"(besides my suspecting a bug that doesn't let any inclusion happen, hence I tried the new version). Time to go back to the serial gateway right into the vera.

                                      M 1 Reply Last reply
                                      0
                                      • P pete1450

                                        @lakshmc Make sure you don't have the daemon running already

                                        If not, I'm getting the same problem on the 2.1.1 that was just released. 2.1.0 was working "fine"(besides my suspecting a bug that doesn't let any inclusion happen, hence I tried the new version). Time to go back to the serial gateway right into the vera.

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

                                        @pete1450 @lakshmc
                                        Make sure you are not using an old version of mosquitto (or any other broker you're using):

                                        $ mosquitto -h
                                        mosquitto version 1.4.10 (build date 2016-09-20 11:02:07-0600)
                                        

                                        It's working fine with the 2.1.1 release:

                                        [alarm@pi3 mysgw]$ sudo ./bin/mysgw -d
                                        mysgw: Starting gateway...
                                        mysgw: Protocol version - 2.1.1
                                        mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
                                        mysgw: TSF:LRT:OK
                                        mysgw: TSM:INIT
                                        mysgw: TSF:WUR:MS=0
                                        mysgw: TSM:INIT:TSP OK
                                        mysgw: TSM:INIT:GW MODE
                                        mysgw: TSM:READY:ID=0,PAR=0,DIS=0
                                        mysgw: MCO:REG:NOT NEEDED
                                        mysgw: MCO:BGN:STP
                                        mysgw: MCO:BGN:INIT OK,TSP=1
                                        mysgw: Attempting MQTT connection...
                                        mysgw: connected to 127.0.0.1
                                        mysgw: MQTT connected
                                        mysgw: Sending message on topic: mysensors-out/0/255/0/0/18
                                        mysgw: TSF:MSG:READ,2-2-0,s=1,c=1,t=17,pt=7,l=5,sg=0:108.12
                                        mysgw: TSF:MSG:ACK REQ
                                        mysgw: TSF:MSG:SEND,0-0-2-2,s=1,c=1,t=17,pt=7,l=5,sg=0,ft=0,st=OK:108.12
                                        mysgw: Sending message on topic: mysensors-out/2/1/1/0/17
                                        mysgw: TSF:MSG:READ,2-2-0,s=2,c=1,t=17,pt=7,l=5,sg=0:48.31
                                        mysgw: TSF:MSG:ACK REQ
                                        mysgw: TSF:MSG:SEND,0-0-2-2,s=2,c=1,t=17,pt=7,l=5,sg=0,ft=0,st=OK:48.31
                                        mysgw: Sending message on topic: mysensors-out/2/2/1/0/17
                                        mysgw: TSF:MSG:READ,2-2-0,s=3,c=1,t=17,pt=7,l=5,sg=0:362.86
                                        mysgw: TSF:MSG:ACK REQ
                                        mysgw: TSF:MSG:SEND,0-0-2-2,s=3,c=1,t=17,pt=7,l=5,sg=0,ft=0,st=OK:362.86
                                        mysgw: Sending message on topic: mysensors-out/2/3/1/0/17
                                        
                                        P 1 Reply Last reply
                                        0
                                        • M marceloaqno

                                          @pete1450 @lakshmc
                                          Make sure you are not using an old version of mosquitto (or any other broker you're using):

                                          $ mosquitto -h
                                          mosquitto version 1.4.10 (build date 2016-09-20 11:02:07-0600)
                                          

                                          It's working fine with the 2.1.1 release:

                                          [alarm@pi3 mysgw]$ sudo ./bin/mysgw -d
                                          mysgw: Starting gateway...
                                          mysgw: Protocol version - 2.1.1
                                          mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
                                          mysgw: TSF:LRT:OK
                                          mysgw: TSM:INIT
                                          mysgw: TSF:WUR:MS=0
                                          mysgw: TSM:INIT:TSP OK
                                          mysgw: TSM:INIT:GW MODE
                                          mysgw: TSM:READY:ID=0,PAR=0,DIS=0
                                          mysgw: MCO:REG:NOT NEEDED
                                          mysgw: MCO:BGN:STP
                                          mysgw: MCO:BGN:INIT OK,TSP=1
                                          mysgw: Attempting MQTT connection...
                                          mysgw: connected to 127.0.0.1
                                          mysgw: MQTT connected
                                          mysgw: Sending message on topic: mysensors-out/0/255/0/0/18
                                          mysgw: TSF:MSG:READ,2-2-0,s=1,c=1,t=17,pt=7,l=5,sg=0:108.12
                                          mysgw: TSF:MSG:ACK REQ
                                          mysgw: TSF:MSG:SEND,0-0-2-2,s=1,c=1,t=17,pt=7,l=5,sg=0,ft=0,st=OK:108.12
                                          mysgw: Sending message on topic: mysensors-out/2/1/1/0/17
                                          mysgw: TSF:MSG:READ,2-2-0,s=2,c=1,t=17,pt=7,l=5,sg=0:48.31
                                          mysgw: TSF:MSG:ACK REQ
                                          mysgw: TSF:MSG:SEND,0-0-2-2,s=2,c=1,t=17,pt=7,l=5,sg=0,ft=0,st=OK:48.31
                                          mysgw: Sending message on topic: mysensors-out/2/2/1/0/17
                                          mysgw: TSF:MSG:READ,2-2-0,s=3,c=1,t=17,pt=7,l=5,sg=0:362.86
                                          mysgw: TSF:MSG:ACK REQ
                                          mysgw: TSF:MSG:SEND,0-0-2-2,s=3,c=1,t=17,pt=7,l=5,sg=0,ft=0,st=OK:362.86
                                          mysgw: Sending message on topic: mysensors-out/2/3/1/0/17
                                          
                                          P Offline
                                          P Offline
                                          pete1450
                                          wrote on last edited by
                                          #319

                                          @marceloaqno I should have specified, I'm getting the connection errors with the ethernet gateway.

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


                                          19

                                          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