Use this guide to set up the Raspberry Pi with the DHT22 temperature and humidity sensor and install the Adafruit python library for reading sensor data.
First of all you need a running database. We choose PostgreSQL because it was one of the most supported ones.
To set up this datebase follow these steps:
- Install database with
sudo apt-get install postgresql postgresql-contrib
- Change user to be this database
sudo su - postgres
- Create a user with
createuser postgres
You will be propted to enter password and here we assume that the password is password. - Create database with
createdb -O postgres mosquitto
and this also sets postgres as owner of this database. - Log into this database with
psql mosquitto
- In this shell one can use normal postsql to communicate with the database.
- exit shell with ctrl+d
- Logout from user either with
ctrl+d
or with the commandlogout
- Go to the the folder postgres and run teh setup.sh as sudo and enter password when pormpted
- Now the database is ready to go!
For now the setup script creates two tables in the database for authetication. It also creates a superuser for our raspberrie py. This user is called user1 and has password 'password'
To set up the Mosquitto server with authentication follow these steps:
- Download both the Mosquitto server and Mosquitto auth plug from git by running the comand.
git clone https://github.com/eclipse/mosquitto.git git clone https://github.com/jpmens/mosquitto-auth-plug.git
- Then we need to build the mosquitto broker from the source files with some dependencis installed.
cd mosquitto
sudo apt install build-essential
sudo apt install libc-ares-dev
sudo apt install uuid-dev
sudo apt install libssl-dev
make binary
make install
- Now copy the comfig.mk to mosquitto auth plug sources.
cp ../config.mk ../mosquitto-auth-plug/config.mk
- Now install dependencis:
sudo apt install openssl
sudo apt install libssl-dev
sudo apt install libcurl4-openssl-dev5.
- As the config file takes absolute paths you need to make sure that these paths are correct:
MOSQUITTO_SRC =/home/steffen/dev/iota-research-project/mosquitto
OPENSSLDIR = /usr/bin
- Now go back one folder with
cd ..
and edit mosquitto conf so that it points to the correct path for the file auth-plug.so. It's in this line, replace USER home/USER/dev/iota-research-project/mosquitto-auth-plug/auth-plug.so - Run mosquitto server with:
mosquitto -c /path/to/mosquitto.conf
Make one terminal run the command:
mosquitto_sub -u user1 -P password -t test/topic
And another one run the command:
mosquitto_pub -u user1 -P password -t test/topic -m "Hello world"
cd server
npm run check_payment
Install tsfmt
in VS-Code and enable auto formatting for typescript files in the settings. Or run from terminal using tsfmt -r path/to/file.ts
.