Skip to content

Keepy AI

elRaulito edited this page Nov 17, 2020 · 10 revisions

If you want more detailed informations regarding keepy, check the official page here. The following information comes from the official documentation:

Preparing the system

Assuming you are on a fresh VPS you will need to install Git, Nodejs, NPM and Mysql. Feel free to skip those you know are already installed on your system.

sudo apt update
sudo apt install git nodejs npm mysql-server

Next, we will secure our Mysql Server. Here you will be able to define your user password, which will be needed later. You should answer "Yes" to most of the questions the script will do in order to get a secure/clean Mysql Server.

sudo mysql_secure_installation

By default, Keepy runs on the port 3002. We found that some Raspberries do not have that port available, so if you are going to be using the default port you may want to be sure it is open. Install ufw, enable it and allow traffic on the port 3002. If you are installing Keepy on a VPS, this step is not needed.

sudo apt-get install ufw
sudo ufw enable 
sudo ufw allow 3002

Keepy Installation

Get the Keepy repository from the I2T Hub

git clone https://github.com/iot2tangle/Keepy.git

Head to the Keepy directory and edit the keepy.sql file to setup your mysql user and password. By default the user is keepy but you can change that.

CREATE USER 'keepy'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON * . * TO 'keepy'@'localhost';
ALTER USER 'keepy'@localhost IDENTIFIED WITH mysql_native_password BY 'your_password';

Once all the mysql related changes are done, run this command to import the database and tables needed by Keepy (it will ask for the mysql root password you set during the mysql_secure_installation configuration)

sudo mysql -u root -p < keepy.sql

Edit the database-config.js to provide the correct database name (by default, "keepy"), mysql user and password.

nano database-config.js

Run npm install to get all the needed Nodejs modules.

npm install

Edit the .env.example file and set your Streams Gateway URL, port and endpoint.

# Rename this file to .env
GATEWAY_URL=http://YOUR_GW_IP:8080/sensor_data

Then rename .env.example to .env to launch Keepy with the necessary ENV variables.

mv .env.example .env

Finally, run Keepy!

node keepy.js

You can now send POST/GET requests with your sensors data formatted with the I2T Standard to Keepy. Check the Endpoints section coming next to learn more about it.

http://YOUR_KEEPY_HOST:3002/messages

AICAM

AIcam will send REST requests to Keepy, the code will be structured like this:

POST /messages HTTP/1.1
Host: <KEEPY_IP>:3002
Content-Type: application/json

{ "iot2tangle": 
[ { "sensor":"Address", "data": [ { "name": "Tangle street" } ] } ,
{"sensor": "Camera","data":[{"cars":"2","pedestrians":"3","scooters":"0","accidents":"0"}]}],
 "device": "YOURDEVICE_ID_IN_CONFIG.JS_FILE", "timestamp": 0  }

The objects to detect and the device ID will be set using the dashboard of the device, it will not be neccesary to hard code these parameters.

The only parameter that is not configurable is the name of the street, if you want to change it in the file tasks.c the string startTangleBody

You can use postman to test if streams is working properly with keepy.

Clone this wiki locally