-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: MQTT with Raspberry Pi | ||
author: JAlcocerT | ||
date: 2024-02-15 00:34:00 +0800 | ||
categories: [Make your Raspberry Useful] | ||
tags: [IoT, Sensors] | ||
--- | ||
|
||
## Learning MQTT with a RPi | ||
|
||
### Why MQTT for IoT? | ||
|
||
### To Do list | ||
|
||
- [ ] Send DHT Data to MongoDB | ||
+ [x] Install a MQTT Client | ||
+ [ ] Install a MQTT Broker | ||
+ [ ] Testing the MQTT Broker | ||
+ [ ] Test the Connection | ||
|
||
## Install MQTT Client | ||
|
||
There are many options - I like [MQTTX](https://mqttx.app/) which is free. | ||
|
||
Which you can install in any platform (and even SelfHost MQTTX with Docker). | ||
|
||
Here is how to install MQTTx with [Flatpak](https://jalcocert.github.io/Linux/docs/debian/linux_installing_apps/#flatpak): | ||
|
||
```sh | ||
flatpak install flathub com.emqx.MQTTX | ||
``` | ||
|
||
## Install MQTT Broker | ||
|
||
```sh | ||
docker pull emqx/emqx:5.5.0 | ||
docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx:5.5.0 | ||
``` | ||
|
||
You have other MQTT Broker options like [Eclipse Mosquitto](https://github.com/eclipse/mosquitto) | ||
|
||
### Testing EMQx | ||
|
||
```py | ||
import paho.mqtt.publish as publish | ||
|
||
# MQTT Broker (EMQX) details | ||
broker_address = "broker.emqx.io" | ||
port = 1883 | ||
topic = "python/mqtt" | ||
|
||
# Message to publish | ||
message = "Hello from Python!" | ||
|
||
# Publish the message | ||
publish.single(topic, message, hostname=broker_address, port=port) | ||
print(f"Message Published to {topic}") | ||
``` | ||
|
||
--- | ||
|
||
## FAQ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: RustBerry Pi - Learning Rust with a RPi | ||
author: JAlcocerT | ||
date: 2024-12-15 00:34:00 +0800 | ||
categories: [Make your Raspberry Useful] | ||
tags: [IoT] | ||
--- | ||
|