https://github.com/imshakil/pub-sub-with-mqtt
https://github.com/imshakil/pub-sub-with-mqtt
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/imshakil/pub-sub-with-mqtt
- Owner: imShakil
- Created: 2025-06-30T11:13:32.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-06-30T12:08:36.000Z (3 months ago)
- Last Synced: 2025-06-30T12:36:31.565Z (3 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A Simple MQTT Project on (Pub/Sub)
This is a simple real-world MQTT-based project that simulates a smart home temperature monitoring system. It uses **Node.js** and **MQTT** to demonstrate how IoT devices communicate using the **publish-subscribe** model.
## 📌 Overview
- A **publisher** simulates a temperature sensor by sending random temperature data to a public MQTT broker.
- A **subscriber** listens for temperature messages and logs them.
- If the temperature exceeds **35°C**, the subscriber triggers an **alert**.## ⚙️ Tech Stack
- Node.js
- MQTT.js (`mqtt` npm package)
- [Setup your own broker](./setup-own-mqtt-broker.md) or use Public MQTT broker: [test.mosquitto.org](https://test.mosquitto.org)## How to Test?
1. Clone the repository
```sh
git clone git@github.com:imShakil/pub-sub-with-mqtt.git
cd pub-sub-with-mqtt
```2. Install Dependencies
```sh
npm install mqtt
```3. Run pub-sub
Take two tab in your terminal, and run:
```sh
node subscriber.js
``````sh
node publisher.js
```After then they will communicate each other and keep updating temparature.
