Code Monkey home page Code Monkey logo

roomtempmqttconsumer's Introduction

RoomTempMQTTConsumer

Build Docker CLI

A MQTT client that consumes and saves metric data sent from the MXChip AZ3166 IoT Devkit see RoomTempDevice-MQTT. For viewing the metrics in a browser see RoomTempDashboard

Getting Started

These instructions will get your clone of RoomTempMQTTConsumer up and running on your local machine for development.

Clone this repository.

git clone https://github.com/SeanoNET/RoomTempMQTTConsumer.git

  • Download and install .NET Core 3.1+
  • cd /RoomTempMQTTConsumer/src
  • dotnet restore
  • dotnet build
  • Create appsettings.json file see Configuration
  • dotnet run

Configuration

Create and configure the MqttClient and the Postgres DataSource connection string in appsettings.json.

Name Description
ClientId The MQTT device client id
MqttServerIp The MQTT broker server IP
MqttServerPort The MQTT broker server port
MqttSubscribeTopic The MQTT topic if using the RoomTempDevice-MQTT this will be the same topic set in topic
DataSource MSSQL connection string

appsettings.json

{
  "ClientId": "metric-consumer",
  "MqttServerIp": "localhost",
  "MqttServerPort": "1883",
  "MqttSubscribeTopic": "home/room/temp-mon/data",
  "DataSource": "Host=dbdata;Database=MQTT;Username=postgres;Password=St0ngPassword1!;"
}

Running locally in Docker

Install Docker and Docker Compose

Running in Docker Compose

Create docker-compose.yml

version: '3'

services:

  consumer:
    build: .
    image: roomtempmqttconsumer
    environment:
      DataSource: Host=dbdata;Database=MQTT;Username=postgres;Password=St0ngPassword1!;
      ClientId: metric-consumer
      MqttServerIp: mqtt
      MqttServerPort: 1883
      MqttSubscribeTopic: home/room/temp-mon/data
    depends_on:
        - mqtt
        - dbdata
  mqtt:
    image: eclipse-mosquitto:1.6
    ports:
        - 1883:1883
        - 9001:9001
    volumes:
        - mosquitto:/mosquitto/data
        - mosquitto:/mosquitto/log eclipse-mosquitto
  dbdata:
    image: postgres:12
    ports:
    - 5432:5432
    environment:
        POSTGRES_PASSWORD: St0ngPassword1!
    volumes:
        - dbsql:/var/lib/postgresql/data
  dashboard:
    image: seanonet/roomtempdashboard:latest
    ports:
        - 5000:5000
    environment:
        DataSource: Server=dbdata;Database=MQTT;User Id=sa;Password=St0ngPassword1!;
        ASPNETCORE_URLS: http://0.0.0.0:5000

volumes:
    mosquitto:
    dbsql:

Start the stack with docker-compose up --build

Running Stack in Production on Swarm

For running in production see RoomTempStack

MQTT device

To send data to this consumer see RoomTempDevice-MQTT or you can test with MQTT Explorer

roomtempmqttconsumer's People

Contributors

seanonet avatar snyk-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.