Sign inSign up

megapearl/gpio2mqtt

By megapearl

•Updated 7 minutes ago

Custom aarch64 mqtt-io for Raspberry Pi. Includes RPi.GPIO support for GPIO over MQTT.

Image
Internet of things
0

10K+

megapearl/gpio2mqtt repository overview

This custom Docker image provides mqtt-io support for Raspberry Pi devices with aarch64 architecture, specifically designed to handle GPIO through RPi.GPIO and Adafruit-Blinka.

⁠Overview

This Docker image is based on the mqtt-io⁠ project, with added dependencies for RPi.GPIO and Adafruit-Blinka. This enables GPIO functionality on Raspberry Pi running aarch64 architecture.

Docker Hub Image: megapearl/gpio2mqtt:latest

⁠Requirements

  1. Hardware: Raspberry Pi (4 or similar) running aarch64.
  2. Docker: Docker should be installed on the Raspberry Pi. Follow the official Docker installation guide for Raspberry Pi⁠ if needed.
  3. Docker Compose: This guide assumes you’re using Docker Compose for easier container management.

⁠Getting Started

⁠Step 1: Create docker-compose.yml

Create a docker-compose.yml file in your working directory with the following configuration:

version: '3.7'
services:
  gpio2mqtt:
    container_name: gpio2mqtt
    hostname: gpio2mqtt
    image: megapearl/gpio2mqtt:latest
    restart: unless-stopped
    tty: true
    privileged: true
    healthcheck:
      test: ["CMD-SHELL", "if grep 'OSError:' /gpio2mqtt.log; then exit 1; else exit 0; fi"]
      interval: 60s
      timeout: 10s
      retries: 2
    volumes:
      - /var/log/gpio2mqtt.log:/gpio2mqtt.log
      - /home/dockers/gpio2mqtt/config.yml:/config.yml
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - PUID=1000
      - PGID=100
      - TZ=Europe/Amsterdam
    devices:
      - /dev/i2c-1:/dev/i2c-1
      - /dev/ttyUSB0:/dev/ttyUSB0
⁠Step 2: Configure the config.yml File
  1. Place your config.yml file in /home/dockers/gpio2mqtt/ on the host machine.
  2. Edit the configuration according to your GPIO setup, defining the pins, MQTT broker, topics, etc. For more details, refer to the mqtt-io configuration documentation⁠.
⁠Step 3: Run the Docker Container

In the terminal, navigate to the directory containing your docker-compose.yml file and run:

docker-compose up -d

This command will:

  • Pull the megapearl/gpio2mqtt:latest image from Docker Hub.
  • Set up the container with required privileges, devices, and environment variables.
  • Enable logging and health check functionalities.
⁠Step 4: Verify Container Health

To confirm that the container is running correctly, check the logs:

docker logs gpio2mqtt

If the health check finds issues, such as an OSError, the container will automatically attempt to restart.

⁠Step 5: Update the Image (Optional)

To ensure you’re using the latest version with possible improvements or fixes:

docker-compose pull gpio2mqtt
docker-compose up -d

⁠Additional Notes

  • This image uses the custom aarch64 architecture version of mqtt-io, which includes necessary GPIO modules (RPi.GPIO, Adafruit-Blinka) to enable hardware support on Raspberry Pi.
  • The Dockerfile has been modified to install the required build tools and libraries. Make sure the Raspberry Pi has sufficient resources to handle these dependencies.

For further assistance or questions, please refer to the original mqtt-io documentation⁠ or the RPi.GPIO documentation⁠.

Tag summary

Content type

Image

Digest

sha256:9e10fb6e5…

Size

137.9 MB

Last updated

7 minutes ago

docker pull megapearl/gpio2mqtt