EMQXis a popular
MQTT Brokerin the world. It has a cloud-native architecture based on
Kubernetes, making it extremely suitable for the increasingly complex IoT scenarios and making the transmission of device messages more efficient. Shifu, as a
Kubernetesnative framework, can be perfectly combined with
EMQXwith intelligent multi-protocol device linkage capabilities.
This article will show you how to deploy
EMQX and Shifu in a cluster, integrate a thermometer with
MQTT as the communication method and a Hikvision camera with
RTSP as the transmission protocol, and add an application to interact with Shifu so that every time the thermometer detects a body temperature above 37 degrees it will ask the camera to take a photo.
The simple architecture used in this article is as follows.
The following services and tools are used in this article.
Step 1 Deploy Kubernetes
For this step, you can refer to the official
Kubernetes tutorial for deployment:
After the deployment is complete we should see the following message printed on the terminal.
Step 2 Deploy Shifu
Clone the GitHub repository for Shifu locally to.
git clone https://github.com/Edgenesis/shifu.git
You can then deploy Shifu with the following command.
kubectl apply -f shifu/pkg/k8s/crd/install/shifu_install.yml
Once deployed we should see that the
CRD controller for Shifu has been deployed.
Step 3 Deploy EMQX
First you need to install
$ curl -f -L "https://github.com/emqx/emqx-operator/releases/download/1.1.6/emqx-operator-controller.yaml" | kubectl apply -f -
Then we write the simplest
Then it's time to deploy an EMQX:
kubectl apply -f deployment.yaml
Step 4 Integrate into the device
For the thermometer, we just need to adjust its
MQTT settings so that it can post
MQTT messages to
(For thermometers outside the cluster, we can open up
External IP for access via
In terms of cameras, Shifu's repository already includes a configuration file for Hikvision cameras using
RTSP that we can simply change IP, username, password in the config file to integrate the camera into Shifu.
At this point, our device is connected and we are ready to start linking below.
We can write a
Python application to implement the following logic.
The app subscribes to
temperature-shifu-mqtt messages, each message includes only a number refering the current temperature; if the current temperature is higher than 37 degrees, the camera is asked take a picture and save it locally.
The application code is as follows.
capture function to encapsulate all camera actions. Then we can deploy it to the cluster and start monitoring.
python3 app.py 10.244.0.33
This article shows how to get
EMQX to empower Shifu with more efficient
MQTT Broker capabilities, and make Shifu to work with
MQTT to provide linkage capabilities to devices. In a real-world application scenario, we can use a cheap combination of IR thermometer and camera to replace thousands of dollars of unstable temperature cameras, saving huge costs in a large-scale deployment scenario.