Skip to content

This Repo refers to my final project of Internet of Thingd of the related course of the University of Genova, A.Y. 2021/2022

License

Notifications You must be signed in to change notification settings

edo-pasto/IoTProject2022

Repository files navigation

INSTRUCTIONS

PASTORINO EDOARDO,

Matricola: 5169595,

Internet Of Things

Requirements

Download and install Docker (https://www.docker.com/products/docker-desktop/) Download and install Node.js (https://nodejs.org/it/download/) Download and install DB Browser for Sqlite (https://sqlitebrowser.org/dl/)

npm install parcel axios mqtt http sqlite3

Start the project

For starting the MQTT Broker, the Orion Context Broker and the IoT agent of Fiware we have to run the following command in the prompt in the directory of the project:

./services start

if you have to first create all the services:

./services create

Start the U.I.

For starting the user interfaces we have to run in the terminal (for example in the terminal of VSCode) the command:

parcel index.html

and go the the URL: http://localhost:1234

Start the dummy devices

For starting a dummy devices we have first to run the following command using node:

node {FileName.js}

for example:

node waterSensorMQTT.js

After that, the sensor is listening for the start command that is activated by the button on the user interface. The dummy devices are waterSensorMQTT.js, airSensorMQTT.js, TemperatureSensorMQTT.js, humiditySensorMQTT.js and the actuator IrrigatorMQTT.js

Start the Subscribers

For showing the measures sent by the sensor we can start the subscriber of fiware with this command:

docker run -it --rm --name mqtt-subscriber \
  --network fiware_default efrecon/mqtt-client sub -h mosquitto -t "/#"

For registering the measure in an external database (IOTProjectDB.db) we have to start another subscriber that read the published data and write them on the DB:

node SubscriberMQTT.js

Get Data with curl

For getting the data of device we have to use curl, for example for the waterSensor:

curl -G -X GET \
  'http://localhost:1026/v2/entities/urn:ngsi-ld:WaterSensor:001' \
  -d 'type=Sensor' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /'

Links