mqtt-playground

CPE314 Computer Network MQTT Project

Stars
8

MQTT Project

This is a part of CPE314 Computer Networks project for learning/practicing about the MQTT

Prequisite

  • GO 1.19
  • Docker
  • Make
    • For window: GNU make, MinGW

Architecture

Getting Started

  1. Run InfluxDB for storing sensors data and Grafana for visualize the data on Docker by using the command below on your terminal:
cd ./.docker
docker compose up -d

(grafana) http exposed at port 4000

default username admin default password admin

(influxdb) http exposed at port 8086

default username admin default password adminadmin

  1. Build broker/publisher/subscriber by just typing:
make build
  1. Run broker from built output directory:
  • Required flags:
    • port: port of broker to exposed
./dist/broker --port 1883
  1. Run subscriber:
  • Required flags:
    • id: unique id to identify the subscriber
    • topic: topic to subscribe
    • hostname: hostname to subscribe to the broker
    • influx-token: token for authenticate to influxDB
    • influx-org: org name for influxDB
    • influx-bucket: bueckt name to connect to influxDB
    • influx-hostname hostname to connect to influxDB
  • Example:
      ./dist/sub --id sub-1 --topic hello-world --hostname localhost:1883 --influx-token "tokentoken" --influx-org admin --influx-bucket mqtt --influx-hostname http://localhost:8086
    
  1. Run publisher:
  • Required flags:
    • id: unique id to identify the publisher
    • topic: topic to publish
    • hostname: hostname to publish to the broker
    • interval: interval to publish the next message to the broker (second)
  • Example:
      ./dist/pub --id pub-1 --topic hello-world --hostname localhost:1883 --interval 180
    
  1. Chill with your coffee

Preview

Dashboard