Giter VIP home page Giter VIP logo

mqtt-connector's Introduction

mqtt-connector

This is an MQTT connector for OpenFaaS.

build

About

Once configured and deployed it will deliver messages from selected topics to OpenFaaS functions.

There are various other connectors available for OpenFaaS which form "triggers" for event-driven architectures.

Prior work:

This is inspired by prior work by Alex Ellis: Collect, plot and analyse sensor readings from your IoT devices with OpenFaaS

Component parts:

Deploy in-cluster with Kubernetes

See helm chart for deployment instructions. Then continue at "Test the connector".

export TAG=0.3.1

make build push

Deploy out of cluster

go build

export GATEWAY_PASSWORD=""
export BROKER="tcp://test.mosquitto.org:1883"
export TOPIC="openfaas-sensor-data"

./mqtt-connector --gateway http://127.0.0.1:8080 \
  --broker $BROKER \
  --gw-username admin \
  --gw-password $GATEWAY_PASSWORD \
  --topic $TOPIC

Deploy a function:

faas-cli deploy --name echo --image ghcr.io/openfaas/alpine:latest \
  --fprocess=cat \
  --annotation topic="openfaas-sensor-data"

Test the connector

Annotate a function with the annotation topic: $TOPIC <- where $TOPIC is the MQTT topic you care about.

2019/12/03 16:43:26 Topic: topic        Broker: tcp://test.mosquitto.org:1883
2019/12/03 16:43:29 Invoking (http://192.168.0.35:8080) on topic: "topic", value: "{\"sensor\": \"s1\", \"humidity\": \"52.09\", \"temp\": \"23.200\", \"ip\": \"192.168.0.40\", \"vdd33\": \"65535\", \"rssi\": -45}"
2019/12/03 16:43:29 Invoke function: print-out
Send: "{\"sensor\": \"s1\", \"humidity\": \"52.09\", \"temp\": \"23.200\", \"ip\": \"192.168.0.40\", \"vdd33\": \"65535\", \"rssi\": -45}"
2019/12/03 16:43:29 connector-sdk got result: [200] topic => print-out (24) bytes
[200] topic => print-out
{"temperature":"23.200"}
2019/12/03 16:43:29 tester got result: [200] topic => print-out (24) bytes

This data was generated on the topic topic by my NodeMCU device which publishes sensor data.

A node12 function named print-out returned the temperature as reported.

License

MIT

mqtt-connector's People

Contributors

alexellis avatar shikachuu avatar viveksyngh avatar

Watchers

 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.