This is an IoT project comprising of Raspberry Pi as a gateway and NodeMCUs as agent devices to log events. Objective of this project is to add items that are running low to a "Shopping List" in iOS Reminder application.
NodeMCUs are deployed either with a switch or load cell. When switch is pressed or weight changes, it sends a MQTT message to broker running on Raspberry Pi. Each agent device represents an item that can be added to shopping list.
Raspberry Pi is running a Node.js application along with a MQTT broker (Mosquitto). Node.js application comprises of web application (for provisioning event devices) and MQTT client that subscribes to topics from agent devices. It examines MQTT payloads and determines if an item needs to be added to shopping list. Both Node.js application and MQTT broker are running in their respective docker containers and entire project is run as multi-container docker application on Raspberry Pi. Balena Cloud has been used to deploy the multi-container docker application to Raspberry Pi.
This project uses multi-docker container it can be run on Raspberry Pi as well as on desktop. Prerequisite is that git and docker have to be installed on Raspberry Pi (or desktop).
- Download source code on Raspberry Pi
git clone https://github.com/prashanta/iot-refill.git
cd iot-refill
-
Rename
docker-compose.yml.rpi
file todocker-compose.yml
-
Create IFTTT applet to send events to iOS Reminder using WebHooks
-
Copy token at end of WebHook URL from IFTTT Setting
-
Edit file
node\Dockerfile
to replace 'insert_key_here' with the IFTTT token, to setup environment variable for the container -
Run application
docker-compose up
The same result can be achieved using Balena Cloud, without the hassle of setting up git and docker on Raspberry Pi (follow instruction here).
- Download source code on desktop
git clone https://github.com/prashanta/iot-refill.git
cd iot-refill
-
Rename
docker-compose.yml.dev
file todocker-compose.yml
-
Create IFTTT applet to send events to iOS Reminder using WebHooks
-
Copy token at end of WebHook URL from IFTTT Setting
-
Edit file
docker-compose.yml
to replaceinsert_key_here
with the IFTTT token, to setup environment variable for the container -
Run application
docker-compose up
Once the application is running follow these steps:
-
Open application web interface using browser (http://ip_address_of_raspberrypi)
-
Click 'Add Device' to add either a switch or weight based device.
The firmware for NodeMCU are located in nodemcu_firmware
folder. The folder contains two firmwares for weight and switch based agent devices. Project can be tested without NodeMCU hardware, by using a MQTT Client (like MQTT.fx) to mimic MQTT message from agent devices.
Once the desktop MQTT Client is connected to the broker on Raspberry Pi, send the following MQTT packets to mimic the NodeMCU device:
- For switch based agent device send:
Topic: iot/switch
Message: {"deviceId":"10", "trigger":"1"}
- For weight based agent device send:
Topic: iot/weight
Message: {"deviceId":"11", "weight":"90"}
Once these messages are received by Raspberry Pi, it will send out IFTTT web request to add respective items to shopping list on iOS Reminders application.
For HD video click here