Adafruit_MQTT_Library/examples/mqtt_arbitrary_buffer/README.md
Stuart Feichtinger 713fdac029 Tweaks
2016-01-31 19:22:40 -06:00

77 lines
1.7 KiB
Markdown

# Adafruit MQTT Library example with support
This example illustrates Publish an arbitrary data packet using the Adafruit MQTT library to an MQTT feed which can then be parsed by the included python subscriber client.
## Installing and configuring Mosquitto (minimal working setup)
####On Raspberry Pi/Linux:
```bash
sudo apt-get install mosquitto
cd /etc/mosquitto/
#See "Both" Setup Instructions Below
```
####On a Mac:
```bash
brew install mosquitto
cd /usr/local/etc/mosquitto
#See "Both" Setup Instructions Below
```
####Both
```bash
sudo nano mosquitto.conf
```
Now we have to enable a password file to correctly interface with the Adafruit MQTT library. Scroll about two thirds of the way down until you see:
```bash
# -----------------------------------------------------------------
# Default authentication and topic access control
# -----------------------------------------------------------------
```
You should see `#password_file` about a paragraph after that.
Change
```bash
#password_file
```
To
```bash
password_file pwfile
```
Now `ctrl-x` to save and exit.
You're almost done! We just have to create and populate the password file we just configured. The default user names are:
-#####Arduino publisher:
--Username: TestUser
--Password: TestUser
```bash
touch pwfile #create the password file
```
## Using Example Python Subscriber:
Install dependencies if haven't already
```bash
cd ../Adafruit_MQTT_Library/examples/mqtt_arbitrary_buffer/python_subscriber
pip install -r requirements.txt
```
Run python script with default values and watch your parsed data print out.
```bash
python subscriber.py
```
Use help to see a list of modifiable options
```bash
python subscriber.py -h
```