Django project and django-plantgrower app
- Django
- Django Channels for websockets interface with frontend
- Django REST framework for API
- Python Celery for:
- Periodic tasks such as monitoring and sending data to front end
- Task Queue for monitoring tasks
- Redis for Channels and Celery backend
- Instructions to IoT devices over MQTT
-
Topic Message Format Description grow/{grow_id}/instruction
({pin_number}, {boolean})
Turning pins on and off grow/{grow_id}/sensors
Sensor mapping Send sensor mapping and expects readings back
-
All components have a Dockerfile and therefore is easily deployed with Kubernetes. You can deploy this locally on a Raspberry Pi, for example, for maximum privacy. However it is scalable so you can deploy in to a managed container engine and run there.
There are a couple of things to do before we deploy the application, I will not try and do a better job of explaining than Alex Ellis who has already done it so well. My scripts are based on his.
-
Install Docker on a Raspberry Pi
curl -sSL https://get.docker.com | sh
-
Set Docker to auto-start
sudo systemctl enable docker
-
Reboot the Pi, or start the Docker daemon with:
sudo systemctl start docker
-
Enable Docker client
The Docker client can only be used by root or members of the docker group. Add pi or your equivalent user to the docker group:
sudo usermod -aG docker pi
-
Install Docker Compose
Compose can also be run inside a container, from a small bash script wrapper. To install compose as a container run this command:
sudo curl -L --fail https://github.com/docker/compose/releases/download/1.24.0/run.sh -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose