|Software apps and online services:|
The client code also:
- Runs webserver for displaying MQTT data charts and diagrams.
- Talks to Pi GPIO hardware, reading switches and controlling LEDs.
node.js - Recommend node.js installation using NVM. Tested with latest node.js (v7.3.0).
- Refer to PI_PREP.md
MQTT Broker running on network, with WebSockets enabled
Raspberry Pi. - Tested with Raspbian jessie on Pi 2 and Pi B+ models
- (OPTIONAL) LEDs, Resistors, capacitor, a switch and wiring. See SCHEMATICS.md for details.
MQTT PubSub topic structure being used in this demo
// Topic Structure // ================= // iot-demo \ // `-<clientId> } base topic for this client // | / // |-> connected - 'true' or 'false' // `-raspi // |-> redled - 'on' or 'off' // |-> greenled - 'on' or 'off' // |-> cputemp - degrees C // `-> gputemp - degrees C
So Topic "
iot-demo/+/connected" is status across all the clients
- Publishes information topics using MQTT
- Web server, for displaying MQTT data pages (described below)
- Read and Control GPIO pins on a Raspberry Pi (Switch, LEDs)
- Uses web technologies like WebSockets and SVG. Uses MQTT (over WS) for realtime updates.
For the MQTT Broker used in this demo, see PI_PREP.md. Can run broker on same Pi as client.
Assuming requirements are met, you can get a copy of the code by cloning git repository from GitHub:
git clone https://github.com/idcrook/rpi-iot-demo-2017.git iot-demo
create-config.js script to match your environment. It has values for broker name/WS port.
cd iot-demo cd client npm install ./create-config.js node index.js
If everything is working, can visit URL to view
index.html ( e.g., http://client:3000 ) for a "real-time" graph of the Pi temperatures. Your browser must support WebSockets for graphing to work-- most modern ones do.
Breadboard wiring schematics
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!