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. General Discussion
  3. Using mqttGateway2.pl for Serial to MQTT on RaspberryPI

Using mqttGateway2.pl for Serial to MQTT on RaspberryPI

Scheduled Pinned Locked Moved General Discussion
31 Posts 6 Posters 10.0k Views 6 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.
  • aaron832A Offline
    aaron832A Offline
    aaron832
    wrote on last edited by aaron832
    #20

    Try typing

    "uname -m"
    

    into your console (that hosts the gateway). If it does not say
    "armv6l" or "armv7l" (edit: correction)
    then the Makefile will not include -lrf24-bcm in the LDFLAGS (libraries include). If this is the problem then what hardware are you making the gateway on?

    Artur MajA 1 Reply Last reply
    0
    • aaron832A aaron832

      Try typing

      "uname -m"
      

      into your console (that hosts the gateway). If it does not say
      "armv6l" or "armv7l" (edit: correction)
      then the Makefile will not include -lrf24-bcm in the LDFLAGS (libraries include). If this is the problem then what hardware are you making the gateway on?

      Artur MajA Offline
      Artur MajA Offline
      Artur Maj
      wrote on last edited by
      #21

      @aaron832 It says armv7l. Please, note it is not armv71 the last character is small "L" not 1 (one). This is raspberry pi 2 with ubuntu mate 15.10. I am going to edit Makefile replacing armv71 with armv7l and see what's happening. Thanks again.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cingolanifede
        wrote on last edited by
        #22

        Hi, i tried to make the script work but i couldnt. did anybody make it work? I used the serial gateway option, installed all the libraries.

        . thankspi@raspberrypi:/ $ sudo ./mqttGateway2.pl --serial /dev/ttyUSB0
        Subroutine main::inet_aton redefined at /usr/share/perl/5.20/Exporter.pm line 66.
        at ./mqttGateway2.pl line 42.
        given is experimental at ./mqttGateway2.pl line 267.
        when is experimental at ./mqttGateway2.pl line 269.
        when is experimental at ./mqttGateway2.pl line 270.
        when is experimental at ./mqttGateway2.pl line 271.
        when is experimental at ./mqttGateway2.pl line 272.
        Smartmatch is experimental at ./mqttGateway2.pl line 313.
        Smartmatch is experimental at ./mqttGateway2.pl line 332.
        given is experimental at ./mqttGateway2.pl line 400.
        when is experimental at ./mqttGateway2.pl line 402.
        when is experimental at ./mqttGateway2.pl line 411.
        Name "main::fh" used only once: possible typo at ./mqttGateway2.pl line 207.
        can't create /var/run/mqttMySensors/Gateway__dev_ttyUSB0: No existe el fichero o el directorio at ./mqttGateway2.pl line 452.
        What does it means?
        Thanks

        YveauxY 1 Reply Last reply
        0
        • C Offline
          C Offline
          cingolanifede
          wrote on last edited by
          #23

          @Yveaux Keep on getting this error

          1 Reply Last reply
          0
          • C cingolanifede

            Hi, i tried to make the script work but i couldnt. did anybody make it work? I used the serial gateway option, installed all the libraries.

            . thankspi@raspberrypi:/ $ sudo ./mqttGateway2.pl --serial /dev/ttyUSB0
            Subroutine main::inet_aton redefined at /usr/share/perl/5.20/Exporter.pm line 66.
            at ./mqttGateway2.pl line 42.
            given is experimental at ./mqttGateway2.pl line 267.
            when is experimental at ./mqttGateway2.pl line 269.
            when is experimental at ./mqttGateway2.pl line 270.
            when is experimental at ./mqttGateway2.pl line 271.
            when is experimental at ./mqttGateway2.pl line 272.
            Smartmatch is experimental at ./mqttGateway2.pl line 313.
            Smartmatch is experimental at ./mqttGateway2.pl line 332.
            given is experimental at ./mqttGateway2.pl line 400.
            when is experimental at ./mqttGateway2.pl line 402.
            when is experimental at ./mqttGateway2.pl line 411.
            Name "main::fh" used only once: possible typo at ./mqttGateway2.pl line 207.
            can't create /var/run/mqttMySensors/Gateway__dev_ttyUSB0: No existe el fichero o el directorio at ./mqttGateway2.pl line 452.
            What does it means?
            Thanks

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

            @cingolanifede said:

            /var/run/mqttMySensors/Gateway__dev_ttyUSB0: No existe el fichero o el directorio at

            This path doesn't exist. Create it, or change the path.
            All others are warnings, due to an incompatible perl version you're using.

            http://yveaux.blogspot.nl

            C 1 Reply Last reply
            0
            • YveauxY Yveaux

              @cingolanifede said:

              /var/run/mqttMySensors/Gateway__dev_ttyUSB0: No existe el fichero o el directorio at

              This path doesn't exist. Create it, or change the path.
              All others are warnings, due to an incompatible perl version you're using.

              C Offline
              C Offline
              cingolanifede
              wrote on last edited by
              #25

              @Yveaux ok. Thanks. I did it. But i am having a different problem now. I have serial gateway running fine. I installed mosquitto and try to follow different steps from the forum and I dont know how to make this work.K cant make the connection beetwen openhab--mosquitto-script--serial gateway. Can you help me ? Is there any post where this is done? Thanks in advance.

              YveauxY 1 Reply Last reply
              0
              • C cingolanifede

                @Yveaux ok. Thanks. I did it. But i am having a different problem now. I have serial gateway running fine. I installed mosquitto and try to follow different steps from the forum and I dont know how to make this work.K cant make the connection beetwen openhab--mosquitto-script--serial gateway. Can you help me ? Is there any post where this is done? Thanks in advance.

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

                @cingolanifede I don't have a step by step description for your solution. Searching (and reading) the forum sounds like a good start. If you give us a clear description of what seems to be working and what not, or where you get stuck, it's easier to help.

                http://yveaux.blogspot.nl

                C 1 Reply Last reply
                0
                • YveauxY Yveaux

                  @cingolanifede I don't have a step by step description for your solution. Searching (and reading) the forum sounds like a good start. If you give us a clear description of what seems to be working and what not, or where you get stuck, it's easier to help.

                  C Offline
                  C Offline
                  cingolanifede
                  wrote on last edited by
                  #27

                  @Yveaux 1) The script is running. It reads from serial port, this is what I get, then it crashes, and says broken pipe.

                  20160509-10:48:33 RX: [0;0;3;0;9;read: 30-30-0 s=1,c=1,t=16,pt=2,l=2,sg=1:1] fr=000 ci=000 c=C_INTERNAL st=I_LOG_MESSAGE noack 'read: 30-30-0 s=1,c=1,t=16,pt=2,l=2,sg=1:1' -> Publish to broker 'MyMQTT/0/0/I_LOG_MESSAGE':'read: 30-30-0 s=1,c=1,t=16,pt=2,l=2,sg=1:1'
                  20160509-10:48:33 RX: [30;1;1;0;16;1 ] fr=030 ci=001 c=C_SET st=V_TRIPPED noack '1' -> Publish to broker 'MyMQTT/30/1/V_TRIPPED':'1'
                  20160509-10:48:43 Exception: Error: Tubería rota

                  20160509-10:48:43 Restarting...
                  20160509-10:48:43 trying to restore subscriptions

                  ====2)On openhab log I get this========

                  2016-05-09 10:48:33.189 [ERROR] [o.i.t.m.i.MqttBrokerConnection] - MQTT connection to broker was lost
                  org.eclipse.paho.client.mqttv3.MqttException: Se ha perdido la conexión
                  at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) [mqtt-client-0.4.0.jar:na]
                  at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
                  Caused by: java.io.EOFException: null
                  at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[na:1.8.0]
                  at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) ~[na:na]
                  at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) [mqtt-client-0.4.0.jar:na]
                  ... 1 common frames omitted
                  2016-05-09 10:48:33.191 [ERROR] [o.i.t.m.i.MqttBrokerConnection] - MQTT connection to 'mysensor' was lost: Se ha perdido la conexión : ReasonCode 32109 : Cause : null
                  2016-05-09 10:48:33.193 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mysensor'

                  On openhab.cfg i put this and i have the addons installed

                  mqtt:mysensor.url=tcp://192.168.1.109:1883
                  mqtt:mysensor.clientId=mys

                  A simple switch setting
                  Switch node2_sw1 "sw1" (node2,all) {mqtt=">[mysensor:MyMQTT/30/10/V_LIGHT:command:ON:1],>[mysensor:MyMQTT/30/10/V_LIGHT:command:OFF:0]"}

                  I think the problem is that i am not setting mosquitto well beetwen openhab and your script. I tested an example publishing and i get the message. Do I have to change conf.d file? or setting?

                  Thanks.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    cingolanifede
                    wrote on last edited by
                    #28

                    @Yveaux I made improvement:
                    I am using mosquitto_sub to read what the script posted. Thats ok.

                    pi@domotic /opt/domotic/runtime $ mosquitto_sub -d -t MyMQTT/30/1/V_TRIPPED
                    Client mosqsub/3629-domotic sending CONNECT
                    Client mosqsub/3629-domotic received CONNACK
                    Client mosqsub/3629-domotic sending SUBSCRIBE (Mid: 1, Topic: MyMQTT/30/1/V_TRIPPED, QoS: 0)
                    Client mosqsub/3629-domotic received SUBACK
                    Subscribed (mid: 1): 0
                    Client mosqsub/3629-domotic received PUBLISH (d0, q0, r1, m0, 'MyMQTT/30/1/V_TRIPPED', ... (1 bytes))
                    1
                    Client mosqsub/3629-domotic received PUBLISH (d0, q0, r0, m0, 'MyMQTT/30/1/V_TRIPPED', ... (1 bytes))
                    0
                    Client mosqsub/3629-domotic sending PINGREQ
                    Client mosqsub/3629-domotic received PINGRESP
                    Client mosqsub/3629-domotic sending PINGREQ
                    Client mosqsub/3629-domotic received PINGRESP
                    Client mosqsub/3629-domotic sending PINGREQ
                    Client mosqsub/3629-domotic received PINGRESP

                    The thing is when I start openhab this happens, it crashes and i get this error. What could it be?

                    2016-05-09 11:56:52.216 [ERROR] [o.i.t.m.i.MqttBrokerConnection] - MQTT connection to broker was lost
                    org.eclipse.paho.client.mqttv3.MqttException: Se ha perdido la conexión
                    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) [mqtt-client-0.4.0.jar:na]
                    at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
                    Caused by: java.io.EOFException: null
                    at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[na:1.8.0]
                    at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) ~[na:na]
                    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) [mqtt-client-0.4.0.jar:na]
                    ... 1 common frames omitted
                    2016-05-09 11:56:52.219 [ERROR] [o.i.t.m.i.MqttBrokerConnection] - MQTT connection to 'mysensor' was lost: Se ha perdido la conexión : ReasonCode 32109 : Cause : null
                    2016-05-09 11:56:52.220 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mysensor'

                    1 Reply Last reply
                    0
                    • YveauxY Offline
                      YveauxY Offline
                      Yveaux
                      Mod
                      wrote on last edited by
                      #29

                      The script is running for months without issues on my place; both for serial and Ethernet gateway. I am not using the script in combination with a raspberry pi. Maybe there is an issue with the version of mosquitto and/or AnyEvent::MQTT.
                      I remember other people having issues in combination with raspberry pi - search the forum.

                      http://yveaux.blogspot.nl

                      C 1 Reply Last reply
                      0
                      • YveauxY Yveaux

                        The script is running for months without issues on my place; both for serial and Ethernet gateway. I am not using the script in combination with a raspberry pi. Maybe there is an issue with the version of mosquitto and/or AnyEvent::MQTT.
                        I remember other people having issues in combination with raspberry pi - search the forum.

                        C Offline
                        C Offline
                        cingolanifede
                        wrote on last edited by
                        #30

                        @Yveaux Thanks again. I used a phyton script. Now is working.

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          robosensor
                          wrote on last edited by robosensor
                          #31

                          Not sure I'm doing this right way, but changing this line:

                                  fh => $serialDevice->{'HANDLE'},
                          

                          to this line

                                  fh => new_from_fd IO::Handle ($serialDevice->{FD}, "w"),
                          

                          Fixed Filehandle GEN0 opened only for input bug for me on RPi 2. Fix works because of $serialDevice->{'HANDLE'} is opened as read only in SerialDevice and should not be used for write:

                              # a handle object for ioctls: read-only ok
                              $self->{HANDLE} = new_from_fd IO::Handle ($self->{FD}, "r");
                          
                          1 Reply Last reply
                          1
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          14

                          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