This gist demonstrates feed + group context support for Adafruit IO's MQTT service.
On Adafruit IO
- Create group: "Garage"
- Create group: "Office"
- Create a feed, "Signal" and add it to both groups
Get the code:
- Git clone this gist:
git clone https://gist.github.com/a04694748ad887d5aa7e644e3292fa81.git io-mqtt-demo
- Navigate to the new project.
- Install dependencies with
bundle install
(installing bundler first, if you haven't yet)
Setup environment variables, run the following commands in your shell or add them to your .profile
. NOTE: this step requires MacOS or other linux-friendly shell.
export IO_USERNAME='yourusername'
export IO_KEY='your-adafruit-io-key'
Run the code:
- Run
ruby subscriber.rb
- In a new terminal, with the environment variables set, run
ruby publisher.rb
And watch the data fly!