joraco-dev / prometeo

Apache License 2.0
6 stars 2 forks source link

Prometeo

In front of natural disasters, such as Wildfires, PROMETEO tries to protect those who protect us, the firefighters.

With our solution, we've developed a prototype sensor which sends basic telemetry (temperature, humidity and smoke concentration). These data is processed by a machine learning algorithm which is able to predict if the health of the firefighter is ok, will be in danger or if it's in danger.

So, let us explain how we achieved this through this readme.

Project website

The solution at a glance

alt text

As you can see, our project has 5 major blocks, The Sensor, IBM IoT Hub, NodeRed, Container service and the client. Lets review them one by one.

Pre-requisites

This project, at least the part of the board, has been developed with Arudino, so you will need the IDE if you want to use our example, you can get it here (https://www.arduino.cc/en/main/software).

Once it’s installed the Arudino IDE, you should install third party libraries for the ESP8266 board (the one that we use).

In order to do that, you should add this repository as follows. Go to preferences, then add on the field “Additional Boards Manager URLs” this URL https://arduino.esp8266.com/stable/package_esp8266com_index.json, if you already have some other repositories, separate them with a comma.

Next thing to do, is add our board. We need to click on Tools Menu, then on Board section, click on “Boards Manager”. We will search esp8266 and install the board called “esp8266 by ESP8266 Community” (at the moment of writing this manual, the selected version is 2.5.0).

The last thing before getting to the real work is install the libraries used by our project, we use libraries for the temperature sensor, for forming a JSON in order to send the data to the IBM IoT Cloud, we will need to install the following libraries.

We go to Sketch menu, then we will select “Include library” and finally “Manage Libraries”, then we will search and install the following libraries

Once all this pre-requisites are met, you can start compiling the code

The Sensor

For this part of the project, we used a board based on the ESP8266 micro-controller with NodeMCU firmware, as this project will be open source. To this controller, we attached a couple of sensors, the DHT11 which give us information about Temperature and Humidity and the MQ-2 sensor which give us, among the concentration of several gases, the concentration of smoke.

In order to do it portable, we decided to power the controller with a portable usb battery and wrap-it with a sports arm band.

The following image is the final result with a firefighter wearing it.

alt text

Finally, the code that makes possible to read those metrics and send it to the next stage (IBM IoT Hub) could be reviewed here. There are some things to have in mind reading this code:

IBM IoT HUB

This was very straight forward step, simply register the new devices and make sure they connect to the platform, also and thanks to the code uploaded to our microcontroller we're able to perform remote actions on our device, such as change the polling interval, restart the device or wipe it.

At last but not at least we created a connection between the IoT Hub and our next step, our NodeRed app.

NodeRed

alt text

At this point, we can conclude that we're in front of our core service. With this app we control all the workflow of the metrics sent by our sensors, store them, analyze them and take actions depending on the readings.

So, lets analyse node by node. Also, you can find the code here, if you want to import to your personal project, just take into account that credentials, tokens and sensitive data are deleted.

IBM Cloud Container Service

At this point, we need somewhere to publish our real time dashboard. We created a service at the IBM Cloud Container Service. This service includes a web-sockets receiver and sender and a NGINX serving our portal written basically with javascript and using datatables library based on jquery.

This service has exposed two ports, one for the web-sockets server and the other for the nginx server.

Inside this folder, you can find the code of the websockets server (server.js), the source for the portal (html/index.html) and also the script we use to deploy and update the code on our POD (deploy.sh).

Client

Finally, the client is just a web browser that supports javascript and web-sockets that is support by almos all new browsers.

You can access to our Live dashboard at this http address , unfortunately, if there is no sensors transmitting data, you will not be able to see it in action.

alt text

Watson Machine Learning

As part of the Prometeo Solution, is used machine learning in order to determine if it is risky to maintain the firefighter in the actual area puting out the fire or if it is necessary to move him away.

We didn't have real data for training the model, so we decided to emulate data creating an ad hoc dataset.

First, we used the dataset to train the model.

After training the model, we created a web service in order to use the model in the NodeRed module explained before.

Training the model

We used the dataset dataset_cut.csv the code here that contains the next variables:

The machine model we'll be trained with this information.

Before starting the training, it's necessary to process the dataset.

Once the dataset is uploaded in the watson studio project, refine the dataset with the next actions:

After that, create a new machine learning model:

Important you select "Status" as the variable you are going to predict. The rest of variables must be selected as feature variables. You have to select Multiclass Classification because we have 3 possible predictions (red, yellow and green).

Finally, train and evaluate the model.

alt text

Using the model

Once the model is created, you can use it creating a web service.

In the trained model, select the Deployments tab and push the Add Deployments option. Name the new deployment and create it.

After creating the deployment, select it. You can test it, in the servie you have all the information about how to use it.

In our case, we created the deployment "Prometeo ML Webservice".

alt text

Graphical explantation of our model

alt text

Authors

License

This project is licensed under the Apache 2 License

Acknowledgments