Coder Social home page Coder Social logo

knutanderss / iota-research-project Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 2.21 MB

TeX 0.75% Shell 0.53% Makefile 2.86% TypeScript 0.29% Python 19.34% C 65.71% C# 0.32% PHP 0.12% Go 0.06% Java 0.36% JavaScript 0.59% Ruby 0.10% Roff 1.66% CMake 0.82% HTML 0.89% Dockerfile 0.34% C++ 4.38% NSIS 0.56% XSLT 0.14% Perl 0.18%

iota-research-project's Introduction

IOTA Research Project

DHT122 sensor on Raspberry Pi

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.

MQTT With Authentication

As Mosquitto Auths readme is pretty flaued we include the setup here

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:

  1. Install database with sudo apt-get install postgresql postgresql-contrib
  2. Change user to be this database sudo su - postgres
  3. Create a user with createuser postgres You will be propted to enter password and here we assume that the password is password.
  4. Create database with createdb -O postgres mosquitto and this also sets postgres as owner of this database.
  5. Log into this database with psql mosquitto
  6. In this shell one can use normal postsql to communicate with the database.
  7. exit shell with ctrl+d
  8. Logout from user either with ctrl+d or with the command logout
  9. Go to the the folder postgres and run teh setup.sh as sudo and enter password when pormpted
  10. 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'

Mosquitto for linux based systems

To set up the Mosquitto server with authentication follow these steps:

  1. 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
  2. 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
  1. Now copy the comfig.mk to mosquitto auth plug sources. cp ../config.mk ../mosquitto-auth-plug/config.mk
  2. Now install dependencis:
sudo apt install openssl
sudo apt install libssl-dev
sudo apt install libcurl4-openssl-dev5.
  1. 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
  1. 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
  2. Run mosquitto server with: mosquitto -c /path/to/mosquitto.conf

To test it

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"

Run check_payment

cd server
npm run check_payment

Lint server code

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.

iota-research-project's People

Contributors

knutanderss avatar steffensande avatar mathiasgronstad avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.