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. Raspberry PI + MQTT (Mosquitto) + Serial Gateway

Raspberry PI + MQTT (Mosquitto) + Serial Gateway

Scheduled Pinned Locked Moved General Discussion
serialgatewayserial protocolmqttraspberry pi
16 Posts 5 Posters 17.5k 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.
  • L Offline
    L Offline
    lafleur
    wrote on last edited by
    #6

    What changes did you make for Json support??

    Thanks

    M 1 Reply Last reply
    0
    • L lafleur

      What changes did you make for Json support??

      Thanks

      M Offline
      M Offline
      Mrlynx
      Hardware Contributor
      wrote on last edited by Mrlynx
      #7

      @lafleur
      I only changed sub publish to post both timestamp and message in a json message.

      $message = "{\"timestamp\":\"".gettime()."\",\"message\":\"$message\"}"  ;

      http://www.sa2avr.se

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lafleur
        wrote on last edited by
        #8

        I am trying to get the Perl serial gateway code running on a PI-2, but it looks like it wants a number of .PM file that are missing... I'm not well-versed in Linux, so I need a bit of help...

        Anyone know of a complete package for this project??

        Missing so far:

        AnyEvent/Socket.pm
        Net/MQTT/Constants.pm

        It also complains about: use strict; in the program

        Bareword "MQTT_QOS_AT_MOST_ONCE" not allowed while "strict subs" in use at /etc/perl/Net/MQTT/Constants.pm line 74.
        Compilation failed in require at MQTT_Gateway.pl line 32.
        BEGIN failed--compilation aborted at MQTT_Gateway.pl line 32.

        Thanks

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mrlynx
          Hardware Contributor
          wrote on last edited by
          #9

          @lafleur
          you have to install all dependensis with cpan

          http://www.cpan.org/modules/INSTALL.html

          http://www.sa2avr.se

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lafleur
            wrote on last edited by
            #10

            Yes, I did ... heres the last set of error messages...

            perl MQTT_Gateway.pl
            Couldn't require Net::MQTT::Message::ConnAck : Bareword "MQTT_CONNECT_ACCEPTED" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/ConnAck.pm line 19.
            Compilation failed in require at (eval 21) line 2.
             at /usr/share/perl/5.14/Module/Pluggable.pm line 28
            Couldn't require Net::MQTT::Message::Subscribe : Bareword "MQTT_QOS_AT_LEAST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/Subscribe.pm line 16.
            Compilation failed in require at (eval 24) line 2.
             at /usr/share/perl/5.14/Module/Pluggable.pm line 28
            Couldn't require Net::MQTT::Message::Unsubscribe : Bareword "MQTT_QOS_AT_LEAST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/Unsubscribe.pm line 16.
            Compilation failed in require at (eval 25) line 2.
             at /usr/share/perl/5.14/Module/Pluggable.pm line 28
            Couldn't require Net::MQTT::Message::PubRel : Bareword "MQTT_QOS_AT_LEAST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/PubRel.pm line 16.
            Compilation failed in require at (eval 27) line 2.
             at /usr/share/perl/5.14/Module/Pluggable.pm line 28
            Subroutine main::inet_aton redefined at /usr/share/perl/5.14/Exporter.pm line 67.
             at MQTT_Gateway.pl line 34
            Subroutine new redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 25.
            Subroutine new_from_bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 33.
            Subroutine _parse_remaining redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 58.
            Subroutine message_type redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 62.
            Subroutine dup redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 65.
            Subroutine qos redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 68.
            Subroutine _default_qos redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 73.
            Subroutine retain redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 78.
            Subroutine remaining redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 81.
            Subroutine _remaining_string redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 83.
            Subroutine _remaining_bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 88.
            Subroutine string redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 91.
            Subroutine bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 106.
            Bareword "MQTT_QOS_AT_MOST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 74.
            Compilation failed in require at /usr/local/share/perl/5.14.2/AnyEvent/MQTT.pm line 12.
            BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/AnyEvent/MQTT.pm line 12.
            Compilation failed in require at MQTT_Gateway.pl line 36.
            BEGIN failed--compilation aborted at MQTT_Gateway.pl line 36.
            
            1 Reply Last reply
            0
            • L Offline
              L Offline
              lafleur
              wrote on last edited by
              #11

              I'm still having issue with running this on a PI2..

              Anyone have it running that could give me some guidance?? I'm not much of a linux guy...

              Thanks

              Insert /usr/bin/perl  -w MQTT_Gateway.pl
              Couldn't require Net::MQTT::Message::ConnAck : Bareword "MQTT_CONNECT_ACCEPTED" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/ConnAck.pm line 19.
              Compilation failed in require at (eval 21) line 2.
               at /usr/share/perl/5.14/Module/Pluggable.pm line 28
              Couldn't require Net::MQTT::Message::Subscribe : Bareword "MQTT_QOS_AT_LEAST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/Subscribe.pm line 16.
              Compilation failed in require at (eval 24) line 2.
               at /usr/share/perl/5.14/Module/Pluggable.pm line 28
              Couldn't require Net::MQTT::Message::Unsubscribe : Bareword "MQTT_QOS_AT_LEAST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/Unsubscribe.pm line 16.
              Compilation failed in require at (eval 25) line 2.
               at /usr/share/perl/5.14/Module/Pluggable.pm line 28
              Couldn't require Net::MQTT::Message::PubRel : Bareword "MQTT_QOS_AT_LEAST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message/PubRel.pm line 16.
              Compilation failed in require at (eval 27) line 2.
               at /usr/share/perl/5.14/Module/Pluggable.pm line 28
              Subroutine main::inet_aton redefined at /usr/share/perl/5.14/Exporter.pm line 67.
               at MQTT_Gateway.pl line 34
              Subroutine new redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 25.
              Subroutine new_from_bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 33.
              Subroutine _parse_remaining redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 58.
              Subroutine message_type redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 62.
              Subroutine dup redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 65.
              Subroutine qos redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 68.
              Subroutine _default_qos redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 73.
              Subroutine retain redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 78.
              Subroutine remaining redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 81.
              Subroutine _remaining_string redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 83.
              Subroutine _remaining_bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 88.
              Subroutine string redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 91.
              Subroutine bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 106.
              Bareword "MQTT_QOS_AT_MOST_ONCE" not allowed while "strict subs" in use at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 74.
              Compilation failed in require at /usr/local/share/perl/5.14.2/AnyEvent/MQTT.pm line 12.
              BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/AnyEvent/MQTT.pm line 12.
              Compilation failed in require at MQTT_Gateway.pl line 36.
              BEGIN failed--compilation aborted at MQTT_Gateway.pl line 36.
              Code Here
              
              1 Reply Last reply
              0
              • L Offline
                L Offline
                lafleur
                wrote on last edited by
                #12

                I'm still having issue getting this to run on my PI2... I edited the files and fixed the Bareword issues, but now I get this... Not sure what to do from here..

                Thanks

                Insert Code sudo perl -w MQTT_Gateway.pl
                Subroutine main::inet_aton redefined at /usr/share/perl/5.14/Exporter.pm line 67.
                 at MQTT_Gateway.pl line 34
                Subroutine new redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 25.
                Subroutine new_from_bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 33.
                Subroutine _parse_remaining redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 58.
                Subroutine message_type redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 62.
                Subroutine dup redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 65.
                Subroutine qos redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 68.
                Subroutine _default_qos redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 73.
                Subroutine retain redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 78.
                Subroutine remaining redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 81.
                Subroutine _remaining_string redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 83.
                Subroutine _remaining_bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 88.
                Subroutine string redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 91.
                Subroutine bytes redefined at /usr/local/share/perl/5.14.2/Net/MQTT/Message.pm line 106.
                Duplicate message_type number 2:
                  Net::MQTT::Message::ConnAck and
                  Net::MQTT::Message::ConnAck
                Compilation failed in require at /usr/local/share/perl/5.14.2/AnyEvent/MQTT.pm line 12.
                BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/AnyEvent/MQTT.pm line 12.
                Compilation failed in require at MQTT_Gateway.pl line 36.
                BEGIN failed--compilation aborted at MQTT_Gateway.pl line 36.Here
                
                1 Reply Last reply
                0
                • C catcher

                  Hi,

                  I'm looking for combination of those 3 things from topic.

                  I going to use RaspberryPi as a gateway, MQTT broker and controller in one device.

                  I need MQTT (in future I going to use WiFi sensors too), but MQTT gateway from MySensors on Arduino is not enough for me because it allows only for one connections and has too simple logic regarding subscripitions.

                  I was going to use SerialGateway (or direct nRF24L01 connection to RPi) because I want to connect whole controller/gateway stuff to UPS - if I have Ethernet or MQTT gateway separately to RPi then I need to connect RPI, Ethernet/MQTT gateway and router to UPS, but I have it in diferent localizations.

                  I've fount that there is RPi port of MySensors lib: https://github.com/mysensors/Raspberry, but without MQTT support.

                  I've also found bridge between Arduino ethernet gateway and MQTT broker with Perl script: https://github.com/mysensors/PerlMQTTGateway

                  ... but cannot find compilation of those 3 things together. Maybe I missed someting and maybe there is reason for that is not connected together. I've gone through this forum but without success.

                  Maybe you can give me some hints how to deal with it?

                  Thanks.
                  Regards,
                  Michal

                  G Offline
                  G Offline
                  gvorster
                  wrote on last edited by gvorster
                  #13

                  @catcher bit late, but do you have this serial to mqtt bridge working?
                  I would like to use RFM69 radio's which I think don't have a direct MySensors MQTT gateway.
                  I have the serial gateway working and can see data on a RasPi 3 via serial0.

                  Would like to publish to OpenHab2 via MQTT so this bridge would be great if it works.

                  1 Reply Last reply
                  0
                  • CarywinC Offline
                    CarywinC Offline
                    Carywin
                    wrote on last edited by
                    #14

                    I managed to get an RFM69 MQTT Gateway going: https://forum.mysensors.org/topic/6249/mqtt-ethernet-gateway-using-leonardo-32u4-w5100-rfm69h-hard-spi

                    1 Reply Last reply
                    1
                    • C Offline
                      C Offline
                      catcher
                      wrote on last edited by
                      #15

                      @gvorster It was some time ago but remember that finally was able to use this script: https://github.com/Yveaux/MySensors_MQTTGateway/blob/master/mqttGateway2.pl
                      However currently switched to this: https://www.mysensors.org/build/raspberry
                      and must say that works fine for me, and without extra Arduino (just RPi3 and nRF24L01+).

                      G 1 Reply Last reply
                      1
                      • C catcher

                        @gvorster It was some time ago but remember that finally was able to use this script: https://github.com/Yveaux/MySensors_MQTTGateway/blob/master/mqttGateway2.pl
                        However currently switched to this: https://www.mysensors.org/build/raspberry
                        and must say that works fine for me, and without extra Arduino (just RPi3 and nRF24L01+).

                        G Offline
                        G Offline
                        gvorster
                        wrote on last edited by
                        #16

                        @catcher Thanks, I tried this Perl script and it is working out of the box with OpenHAB2! And I'm sending with MySensors 2.

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


                        24

                        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