- Debian 11
- Digital Oceans
- Python 3
- Django
- MQTT
Sensors For the sensors/hardware part you can have information here made by group 5.
The server is hosted on an instance in DigitalOcean cloud.
Follow this tutorial for the initial setup of our server: Initial Server Setup with Debian 11
-
Create a directory where you want to set up Notihub
-
Create a virtual env
virtualenv --system-site-packages -p python3 env/
if you don't have virtualenv install, you can install it with the following command
sudo apt-get -y install virtualenv
-
Install the programs using pip with the requirements.txt
pip3 install -r requirements.txt
-
Edit /core/settings.py. Edit the lines
ALLOWED_HOSTS
andCSRF_TRUSTED_ORIGINS
to add your IP or domain -
To run the server
Python3 manage.py runserver 0.0.0.0:8000
-
Update and refresh your Debian package via the following command
sudo apt update
-
Search for Mosquitto MQTT broker
sudo apt search mosquitto
-
Install the following Mosquitto package
sudo apt install mosquitto mosquitto-clients
-
After the installation, check if the Mosquitto service is working
sudo systemctl is-enabled mosquitto
You should get the following response: enabled
sudo systemctl status mosquitto
You should get a response which includes: active (running)
-
Create a user and password
sudo mosquitto_passwd -c /etc/mosquitto/.passwd username
-
Use your favorite text editor to open the file auth.conf
sudo micro /etc/mosquitto/conf.d/auth.conf
-
Add the following configration t o disable anonymous access and define the password file
allow_anonymous false password_file /etc/mosquitto/.passwd
Save the file and exit your editor (PS: we hope that you're using micro) when you're finished
sudo systemctl restart mosquitto
-
Edit /core/settings.py. Edit the lines
MQTT_USER
andMQTT_USER
to add the user and password you just created You should have someting like thisMQTT_SERVER = 'localhost'
MQTT_PORT = 1883
MQTT_KEEPALIVE = 60
MQTT_USER = 'username'
MQTT_PASSWORD = 'thisIsAVerySecuredPassword'
-
Setup the firewall to accept MQTT requests that use the port 1883 by default
sudo ufw allow 1883
Check it with the following command:
sudo ufw status
you should have this line in your table
To Action From 8000 (v6)
ALLOW
Anywhere (v6)
-
For the change to apply you need to restart the MQQT broker service
Name | Version |
---|---|
Debian | 11 (bullseye) |
Django | 3.2.13 |
Python | 3.9.2 |
Mosquitto | 2.0.15 |
Paho-mqtt | 1.6.1 |
MQTT | 3.9.2 |