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. Troubleshooting
  3. Rpi MQTT Gateway on Docker

Rpi MQTT Gateway on Docker

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 4 Posters 1.1k Views 4 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.
  • magpernM Offline
    magpernM Offline
    magpern
    wrote on last edited by magpern
    #1

    Has anyone successfully installed a raspberry pi Mysensors MQTT Gateway in a docker container?
    There is a docker file with a mysensors mqtt online, but it does not work.
    And if it where, it is lacking personalization files and config files.

    1 Reply Last reply
    0
    • magpernM Offline
      magpernM Offline
      magpern
      wrote on last edited by magpern
      #2

      If anyone is interested.. I got MySensors Ethernet Gateway working in a docker container on a RPi, with a radio connected physically to the Pi.

      0_1549915308677_f7d902cb-9819-421f-ae76-7ed4a6acc9b3-image.png

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jrbenito
        wrote on last edited by
        #3

        Hi,

        I am starting with MySensors to switch my mighthat gateway in near future. Could you share a bit more? I have some experience with docker.

        Thanks

        magpernM 1 Reply Last reply
        0
        • J jrbenito

          Hi,

          I am starting with MySensors to switch my mighthat gateway in near future. Could you share a bit more? I have some experience with docker.

          Thanks

          magpernM Offline
          magpernM Offline
          magpern
          wrote on last edited by
          #4

          @jrbenito I did jump the gun a little early. Sure, the gateway works, if you have externally connected devices, like an external MySensors gateway, but it does not work if you have the radio wired directly onto the RPi. It cannot fint the SPI.

          Basically I did this:

          A DockerFile (the .configure section needs to be modified to personal preferences)

          FROM balenalib/raspberrypi3-debian
          
          RUN apt-get update && apt-get install -y --no-install-recommends git bash make g++ \
            && cd /root \
            && git clone https://github.com/mysensors/MySensors.git --branch development \
            && cd /root/MySensors \
            && mkdir -p /data \
            && LDFLAGS="-static" ./configure --my-transport=rfm69 --my-rfm69-frequency=868 --my-is-rfm69hw --my-gateway=ethernet --my-port=5003 --my-leds-err-pin=29 --my-leds-rx-pin=31 --my-leds-tx-pin=33 --my-rfm69-encryption-enabled --my-signing-request-signatures --my-signing=software --my-config-file="/data/mysensors.conf" \
            && make \
            && cd /root \
            && apt-get remove -y git make g++ && apt-get autoremove -y
          
          EXPOSE 5003
          
          ENTRYPOINT ["/root/MySensors/bin/mysgw"]
          

          And a Docker-compose.yml file (ports needs to be configured. I think 5003 is not needed, since 5003 would be used if the gateway was handling the radio wired to the pins of the pi. Run with serial instead)

          version: '3'
          services:
            portainer:
              container_name: portainer
              image: portainer/portainer:arm
              restart: always
              volumes:
                - '/var/run/docker.sock:/var/run/docker.sock'
              expose:
                - 9000
              ports:
                - 9000:9000
            
            mysensors:
              build:
                context: .
                dockerfile: Dockerfile
              container_name: mysensor_eth
              restart: unless-stopped
              privileged: true
              devices:
                - /dev/ttyACM0:/dev/ttyACM0
              ports:
                - 5003:5003  
              volumes:
                - /mnt/usb1/mysensorsd/data:/data:rw
                - /sys:/sys:rw
                - /tmp:/tmp
          
          

          The config file needs to be on a exposed volume and have the eeprom file pointed to the same volume
          File mysensors.conf and it needs to be modified for signing keys and path to log aqnd eeprom

          i had everything on /mnt/usb1/mysensors and folders data created within that path. I set access to full RW for everyone

          # Logging
          # Verbosity: debug,info,notice,warn,err
          verbose=debug
          
          # Enable logging to a file.
          log_file=1
          # Log file path.
          log_filepath=/mnt/usb1/mysensors/data/mysgw.log
          
          # Enable logging to a named pipe.
          # Use this option to view your gateway's log messages
          # from the log_pipe_file defined bellow.
          # To do so, run the following command on another terminal:
          #   cat "log_pipe_file"
          log_pipe=1
          log_pipe_file=/tmp/mysgw.pipe
          
          # Enable logging to syslog.
          syslog=0
          
          # EEPROM settings
          eeprom_file=/mnt/usb1/mysensors/data/mysensors.eeprom
          eeprom_size=1024
          
          # Software signing settings
          # Note: The gateway must have been built with signing
          #       support to use the options below.
          #
          # To generate a HMAC key run mysgw with: --gen-soft-hmac-key
          # copy the new key in the line below and uncomment it.
          soft_hmac_key=****************
          # To generate a serial key run mysgw with: --gen-soft-serial-key
          # copy the new key in the line below and uncomment it.
          soft_serial_key=*******************
          
          # Encryption settings
          # Note: The gateway must have been built with encryption
          #       support to use the options below.
          #
          # To generate a AES key run mysgw with: --gen-aes-key
          # copy the new key in the line below and uncomment it.
          aes_key=**************
          

          I do not use the MySensors on a docker. I had som many problems with it, SPI beeing one, and the LEDs an other.
          It literally takes 3 minutes to set it up and run nativelly on a Pi, and this gives you full access to everything.

          I run everything else in a docker.

          Z 1 Reply Last reply
          0
          • magpernM magpern

            @jrbenito I did jump the gun a little early. Sure, the gateway works, if you have externally connected devices, like an external MySensors gateway, but it does not work if you have the radio wired directly onto the RPi. It cannot fint the SPI.

            Basically I did this:

            A DockerFile (the .configure section needs to be modified to personal preferences)

            FROM balenalib/raspberrypi3-debian
            
            RUN apt-get update && apt-get install -y --no-install-recommends git bash make g++ \
              && cd /root \
              && git clone https://github.com/mysensors/MySensors.git --branch development \
              && cd /root/MySensors \
              && mkdir -p /data \
              && LDFLAGS="-static" ./configure --my-transport=rfm69 --my-rfm69-frequency=868 --my-is-rfm69hw --my-gateway=ethernet --my-port=5003 --my-leds-err-pin=29 --my-leds-rx-pin=31 --my-leds-tx-pin=33 --my-rfm69-encryption-enabled --my-signing-request-signatures --my-signing=software --my-config-file="/data/mysensors.conf" \
              && make \
              && cd /root \
              && apt-get remove -y git make g++ && apt-get autoremove -y
            
            EXPOSE 5003
            
            ENTRYPOINT ["/root/MySensors/bin/mysgw"]
            

            And a Docker-compose.yml file (ports needs to be configured. I think 5003 is not needed, since 5003 would be used if the gateway was handling the radio wired to the pins of the pi. Run with serial instead)

            version: '3'
            services:
              portainer:
                container_name: portainer
                image: portainer/portainer:arm
                restart: always
                volumes:
                  - '/var/run/docker.sock:/var/run/docker.sock'
                expose:
                  - 9000
                ports:
                  - 9000:9000
              
              mysensors:
                build:
                  context: .
                  dockerfile: Dockerfile
                container_name: mysensor_eth
                restart: unless-stopped
                privileged: true
                devices:
                  - /dev/ttyACM0:/dev/ttyACM0
                ports:
                  - 5003:5003  
                volumes:
                  - /mnt/usb1/mysensorsd/data:/data:rw
                  - /sys:/sys:rw
                  - /tmp:/tmp
            
            

            The config file needs to be on a exposed volume and have the eeprom file pointed to the same volume
            File mysensors.conf and it needs to be modified for signing keys and path to log aqnd eeprom

            i had everything on /mnt/usb1/mysensors and folders data created within that path. I set access to full RW for everyone

            # Logging
            # Verbosity: debug,info,notice,warn,err
            verbose=debug
            
            # Enable logging to a file.
            log_file=1
            # Log file path.
            log_filepath=/mnt/usb1/mysensors/data/mysgw.log
            
            # Enable logging to a named pipe.
            # Use this option to view your gateway's log messages
            # from the log_pipe_file defined bellow.
            # To do so, run the following command on another terminal:
            #   cat "log_pipe_file"
            log_pipe=1
            log_pipe_file=/tmp/mysgw.pipe
            
            # Enable logging to syslog.
            syslog=0
            
            # EEPROM settings
            eeprom_file=/mnt/usb1/mysensors/data/mysensors.eeprom
            eeprom_size=1024
            
            # Software signing settings
            # Note: The gateway must have been built with signing
            #       support to use the options below.
            #
            # To generate a HMAC key run mysgw with: --gen-soft-hmac-key
            # copy the new key in the line below and uncomment it.
            soft_hmac_key=****************
            # To generate a serial key run mysgw with: --gen-soft-serial-key
            # copy the new key in the line below and uncomment it.
            soft_serial_key=*******************
            
            # Encryption settings
            # Note: The gateway must have been built with encryption
            #       support to use the options below.
            #
            # To generate a AES key run mysgw with: --gen-aes-key
            # copy the new key in the line below and uncomment it.
            aes_key=**************
            

            I do not use the MySensors on a docker. I had som many problems with it, SPI beeing one, and the LEDs an other.
            It literally takes 3 minutes to set it up and run nativelly on a Pi, and this gives you full access to everything.

            I run everything else in a docker.

            Z Offline
            Z Offline
            zurajm
            wrote on last edited by
            #5

            @magpern SPI access in Docker container is possible, you have to use --privileged switch when creating container and some other switches when compiling. I ended up with the following Dockerfile:

            FROM raspbian/stretch AS build
            
            WORKDIR /root
            RUN apt-get update && apt-get install -y --no-install-recommends git bash make g++ \
              && git clone https://github.com/mysensors/MySensors.git --branch development 
            WORKDIR MySensors
            RUN echo "##### Building version: $(cat library.properties | grep version | cut -d= -f2)-$(git describe --tags)"
            RUN LDFLAGS="-static" ./configure --my-transport=rfm69 --my-rfm69-frequency=433 --my-is-rfm69hw --my-gateway=mqtt --my-controller-ip-address=<ip of the mqtt server> --my-mqtt-user=<user> --my-mqtt-password=<password> --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in  --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18 --my-config-file=/data/mysensors.conf --spi-driver=BCM --soc=BCM2836 --cpu-flags="-mcpu=cortex-a53 -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits -mtune=cortex-a53" \
              && make
            
            FROM hypriot/rpi-alpine-scratch
            RUN mkdir /data
            WORKDIR /root
            COPY --from=build /root/MySensors/bin/mysgw .
            
            EXPOSE 5003
            ENTRYPOINT ["./mysgw"]
            

            I couldn't get ethernet mode to work (I got core dump as soon as client connected to gateway) so I'm using MQTT mode which works great. Here is the relevant run command:

            docker run --privileged --volume /opt/mysensors:/data --restart unless-stopped --name mysgw zurajm/mysgw-mqtt-alpine:latest
            

            the mysensors.conf resides in /opt/mysensors:

            # Logging
            # Verbosity: debug,info,notice,warn,err
            verbose=debug
            
            # Enable logging to a file.
            log_file=0
            # Log file path.
            log_filepath=/tmp/mysgw.log
            
            # Enable logging to a named pipe.
            # Use this option to view your gateway's log messages
            # from the log_pipe_file defined bellow.
            # To do so, run the following command on another terminal:
            #   cat "log_pipe_file"
            log_pipe=0
            log_pipe_file=/tmp/mysgw.pipe
            
            # Enable logging to syslog.
            syslog=0
            
            # EEPROM settings
            eeprom_file=/data/mysensors.eeprom
            eeprom_size=1024
            
            # Software signing settings
            # Note: The gateway must have been built with signing
            #       support to use the options below.
            #
            # To generate a HMAC key run mysgw with: --gen-soft-hmac-key
            # copy the new key in the line below and uncomment it.
            #soft_hmac_key=
            # To generate a serial key run mysgw with: --gen-soft-serial-key
            # copy the new key in the line below and uncomment it.
            #soft_serial_key=
            
            # Encryption settings
            # Note: The gateway must have been built with encryption
            #       support to use the options below.
            #
            # To generate a AES key run mysgw with: --gen-aes-key
            # copy the new key in the line below and uncomment it.
            #aes_key=
            

            I only modified eeprom_file location to /data folder.

            I hope someone can benefit from it.

            BR, Miha

            1 Reply Last reply
            3
            • joaoabsJ Offline
              joaoabsJ Offline
              joaoabs
              wrote on last edited by
              #6

              Hi,

              I was looking for this!
              How can I get this docker container?
              Cheers,
              Joaoabs

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


              21

              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