Simple IoT Server, Configuration Tool & Dashboard
- Python 3.9+
- Git
- Mosquitto
- PostgreSQL
- PostGIS
- gdal
git clone https://github.com/hacklabza/iotserver.git
cd iotserver/
brew bundle install # On MacOS, see Brewfile - if you're not using docker compose
pyenv local 3.10.*
curl -sSL https://install.python-poetry.org | python3 -
poetry install
poetry run pre-commit install
poetry run ./manage.py migrate
poetry run ./manage.py runserver
poetry run pytest -s . --cov
To create a super user which you can use to populate your devices and users, execute the following command in your terminal and follow the prompts.
./manage.py createsuperuser
The recommended way to install the API and it's service dependancies is with docker, however the docker compose config can also be used in development. I've found that this is best done if you're using a PC or Server.
Doesn't play well with RPi!
sudo apt update && sudo apt upgrade
sudo apt install libffi-dev libssl-dev python3-dev python3 python3-pip git
curl -fsSL test.docker.com -o get-docker.sh && sh get-docker.sh
sudo usermod -aG docker ${USER}
sudo systemctl enable docker
sudo reboot now # or logout of the pi user account
pip3 install docker-compose
git clone https://github.com/hacklabza/iotserver.git
cd iotserver/
curl -#fLo- 'https://raw.githubusercontent.com/hyperupcall/autoenv/master/scripts/install.sh' | sh # install autoenv - optional
cp .env.example .env # update as required
mkdir -p docker/mqtt
cp mosquitto.conf.example docker/mqtt/mosquitto.conf
docker compose -f docker-compose.yml up
Recommend for 64bit/32bit rasbian installation, in my case a raspberrypi zero.
sudo apt update && sudo apt upgrade
sudo apt install -y --no-install-recommends git vim python3-pip python3-dev gdal-bin libgdal-dev libffi-dev openssl
sudo apt install -y postgresql
sudo chown postgres:postgres /var/lib/postgresql/13/main
sudo apt install -y postgresql-13-postgis-3-scripts
sudo su - postgres
createdb iotserver
psql -d iotserver
$postgres-# CREATE EXTENSION postgis;
$postgres-# ALTER USER postgres WITH PASSWORD '<your-postgres-password>';
sudo apt install -y --no-install-recommends memcached
sudo apt install -y --no-install-recommends mosquitto
Add the following lines to /etc/mosquitto/mosquitto.conf
and restart the service
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883
max_keepalive 0 # Remove if this causes startup issues
allow_anonymous true
You may need to install the rust toolchain for RPi 32 bit OS versions due to cryptography
.
git clone https://github.com/hacklabza/iotserver.git
cd iotserver/
pip install --upgrade pip
curl -sSL https://install.python-poetry.org | python3 -
poetry install
curl -#fLo- 'https://raw.githubusercontent.com/hyperupcall/autoenv/master/scripts/install.sh' | sh # install autoenv - optional but recommended
cp .env.example .env # update as required
cp manage.py ~/.local/bin/
chmod +x ~/.local/bin/manage.py
poetry run manage.py migrate
poetry run manage.py collectstatic
poetry run manage.py createsuperuser
sudo cp systemd/iot.api.service /etc/systemd/system/iot.api.service
sudo cp systemd/iot.mqttsubscriber.service /etc/systemd/system/iot.mqttsubscriber.service
sudo systemctl start iot.api.service
sudo systemctl start iot.mqttsubscriber.service
sudo systemctl enable iot.api.service
sudo systemctl enable iot.mqttsubscriber.service
Read more here: https://howchoo.com/pi/create-a-backup-image-of-your-raspberry-pi-sd-card-in-mac-osx. this pretty useful as cards can become corrupt if power is cut or the device is not powered down correctly.