Loading...
 

1.  Members:

2.  Schedule:

DayTimeHoursRoom
Monday13:302INE 214
Wednesday13:302INE 214

3. About the project:

In our project we will try to automatize the hydraulic system of a building. To start, we will install in each faucet sensors to measure the water flow and use this flow to power the sensors. With the results of the measurement we can estimate the use

4. Model

ProjetoISHA

4.1. Consumption monitoring

The monitoring of the building water consumption will be realized with the use of water flow meters (one in each tap), coupled to these water flow meters, there will be an Emote which will pass the data collected by the sensor to a central repository.

4.2. Water leaking detection

To perform the leaks detection two approaches were used, fuzzy logic and neural networks.

4.2.1. Fuzzy logic

One of the approaches that we use was fuzzy logic, which generates results within a range, in this case, generates a value between 0 and 1, this results in a degree of certainty the occurrence of leaks where 0 is sure that is not occurring a leak and 1 is sure that is happening a leak.

For the use of fuzzy logic was extended the tool Ptolemy using a Java library for fuzzy logic representation JFuzzy, this library allows the creation of fuzzy systems using a standardized language to generate the predicates with their respective weights and margins of action that will be interpreted by the logic engine library and will generate a result within the specified range. The specification of our problem using the language adopted by JFuzzy was made as shown below:
Fuzzy

After specifying the functioning of our fuzzy logic, we extended the tool to support the using of our implementation, for this the following classes were created:

Fuzze
Fuzzy Actor
LeakDetector

The results obtained with the use of fuzzy logic were not very satisfactory, the reason is that this kind of approach requires a certain knowledge of the kind of problem that you want to solve and we have no leaks specialist, then our specification of what is a leak was not very accurate.

4.2.2. Neural network


Besides the use of fuzzy logic, also chose using neural networks, this approach is simpler, the knowledge that it takes on the problem domain is not defined by us, but by all of the collected data from the environment, thus, It turns the output to be more precise depending on the size and accuracy of the data collected.

The Neural networks workflow is simple, you collect a data set either with an input and the expected output, trains the network with this data set and after training your network already will be able to classify new samples of data, the result of rating will depend on the data set used to train the network and the number of intermediate neurons that were used on the network.

To implement our neural network and perform the tests was used MATLAB. First, we create a script in MATLAB that will load the simulation data in a matrix, after this it will separate the array into two (2), one containing the training set, and another containing the set to be classified, after the network is trained and the remaining data are classified, we did a comparison of the data classified by our network and the original data to determine the network's hit percentage. The script created in MATLAB is shown below:

Matlab
Saturate

The idea of adopting neural networks in our solution is to continuously expand the set of samples for training every time our network make a mistake. The sample that our network wrongly classified will be compared with other samples contained in our training set using a simple similarity technique (a simple multiplication, because both metrics have the same significance), if any sample in training set is similar with the misclassification, then the value contained in this sample response will be updated with the value contained in the sample misclassified, if not, the sample misclassified will be added to the set of samples for training.

To create the training dataset, was done a simulation equivalent to one (1) working day of a building that has 1 (one) central tank and 3 (three) water outlets, the simulation took into account the opening hours of the building between 8:00am and 10:00pm, it was estimated that each person consumes an equivalent of 2 liters of water during they staying in the building but was not taken into account a flow rate limit for each water outlet, it can be noticed a marked change in the building's water consumption during the simulation. The graph above shows the water flow pattern over the day.

Vazao

The spreadsheet with the dataset used to train the neural network can be found here

4.3. Nonfunctional model


Were detected 4 non-functional requirements for this project:

4.3.1. Power source

As illustrated in our model, the EPOS mote, sensors and valves need a source power, however in some cases (in the water reservatory at the roof) where the humidity level and the temperature are high, the source power needs to be resistant to humidity and high temperature.

4.3.2. Sensor Consumption

The water flow sensor needs to have a low power consumption because it will be auto sufficient in power consumption, that means the sensor will be it own source of power.

4.3.3. Sonar sensor

The sonar sensor will be inside a water tank, it means that this sensor needs to be humidity resistant like it source power.

4.3.4. Solenoid valve

The valve needs to support a common water pressure, we think that a default valve supports that but some kinds of edifications have pressurizers that turn the water pressure high and some kinds of valves may get problems with this high pressure. Another requirement about the valve is the lack of energy, the solenoid valve needs to open when not energized and close when energized, its prevent the lack of water when the energy is down at the same time that reduces the energy consumption because the valve will be more time open than closed.

4.3.5. Leak detection

The response needs to have a deterministic processing time to other systems be able to have enough time to work properly.

4.3.6. Sensor update time

Because wireless is used to communicate with the database, it could occur delays between each sensor update. This can be a problem if systems reading the database don't check if the data was updated in the same time.




4.4. Water reservatory monitoring

Hidro
To obtain the water level in the reservatory, we will use two sonar sensors, one to estimate the distance between the ceiling and the floor (H2) or the base that the water box is on and the other to estimate the distance between the ceiling and a board floating on the water surface (H1)...

Be continued

5. Architecture


Architecture

  • Datastore : This entity is the central point of the system. It stores all the data received from the gateway, the result from the LeakDetector and, by also storing commands from the Configuration Manager and the Controller, it works as a facade for the communication between other entities.

  • Gateway : Collects data from all sensors and sends to the Datastore.

  • Water Flow Sensors : This sensor, connected to an EPOS Mote, calculates the water flow rate at the point where it is installed and sends this value to the Datastore via the Gateway. Combined with the water flow rate, the sensor also sends its identification and the current time. This action is executed periodically.

  • Tank Level Sensor : This sensor calculates the water level of the reservoir and sends this value to the Datastore. Combined with the water level, the sensor also sends the current time. This action is executed periodically.

  • Leak Detector : This entity reads a series of datas from the Datastore and, based on that, determine whether or not a leak exists in the building. After having a conclusion, it sends this result back to the Datastore. The data read from the Datastore includes the water flow rate obtained from each sensor, the number of people in the building and the number of machines actively using water. Combined with the result, the Leak Detector also sends a identification of where the leak is occurring and the current time. This action is executed periodically.

  • Configuration Manager : This entity allows the users to provide the schedule of people presence and machine activity at the building. Another responsibility is to receive instructions from the users and register them at the Datastore for use of others entities.

  • Controller : This entity reads the Datastore and, based on user instructions and the results of the Leak Detector, sends back to the Database commands to the Actuator. Combined with the command, the Controller also sends the identification of the target Actuator and the current time.

  • Actuator : This Actuator reads the Datastore and if a command targeted to its identification exists, it opens or closes the flow based on the instruction.

  • Dashboard : This entity reads the Datastore and provides to the user charts and tables with information about the current state of the system.

6. Computer Model

Class WaterFlowSensor {

Var interruptionCount = 0;
Var url = "db.lisha.ufsc.br/persistData";
Var period = 30;
Var readResult = 0;
Var timeout = 10000;
Var sensor = 1;

@interruption GPI/O pin 5
Method void GPI/OinterruptionHandler(){
        interruptionCount ++;
} 

@Atomic
Method void waterflowReader(){
        readResult = interruptionCount / period;
        interruptionCount = 0;
        resultPersists();        
}

Method void resultPersists(){
        Var http = getHttpConection(url);
        http.setMethod("POST");
        Var date = timer.getData();
        Var JSON = "{type:waterflow, timestamp:date, readResult:readResult, sensor:sensor}";
        http.sendRequest(JSON,timeout);
        http.close();
}

Method void main(args[]){      
       Var AlarmReader = new Alarm(period*1000,waterflowReader(),'infinite');
}

}

Class LeakDetector{

Var urlRetrieve = "db.lisha.ufsc.br/retrieve";
Var urlPersist = "db.lisha.ufsc.br/persist";
Var period = 30;
Var timeout = 10000;
Var lastResult = -1;
Var sensorsNumbers = 4;
Var lastRetriviedData = -1;
Var neuralNetwork = loadNeuralNetworkFromFile();
Var trainingSet = getFile("trainingSet");

Method JSON retrieveData(JSONConsulta){
        Var http = getHttpConection(urlRetrieve);
        http.setMethod("GET");
        Var JSON = http.sendRequest(JSONConsulta,timeout);
        http.close();
        return JSON;
}

Method void retrainNeuralNetwork(){
        Var date = timer.getData();
        Var timeInterval = date - period;
        Var JSONConsult = "{type:wrong, timestamp:date}>= && >={type:wrong, timestamp:period}"
        Var JSON = retrieveData(JSONConsult);
        if(JSON.value){
              trainingSet.append(lastRetriviedData + ! lastResult);
              neuralNetwork.train(trainingSet);
        }
}

Method void atualizeRetriviedData(JSON){
        if(JSON.elements.size == sensorsNumbers || lastRetriviedData == -1){
              lastRetriviedData = JSON;
        }else{
              JSON = lastRetriviedData;
        }
}

Method void detectLeak(){
        retrainNeuralNetwork();
        Var date = timer.getData();
        Var timeInterval = date - period;
        Var JSONConsulta = "{ type:waterflow, timestamp:date}" >= && >= "{ type:waterflow, timestamp:date}" ;
        Var JSON = retrieveData(JSONConsulta);
        atualizeRetriviedData(JSON);
        Var result = neuralNetwork.classifie(JSON);
        Var date = timer.getDate();
        Var JSONResult = "{type:leakdetection, result:result, timestamp:date}";
        persistData(JSONResult);

}

Method void persistData(JSON){
        Var http = getHttpConection(urlPersist);
        http.setMethod("POST");
        http.sendRequest(JSON,timeout);
        http.close();
}

Method void main(args[]){
       new Alarm(period*1000,detectLeak(),'infinite');
}

}

Class SolenoidValveActor {

Var url = "db.lisha.ufsc.br/retrieveData";
Var period = 30;
Var timeout = 10000;
Var actuatorId = 1;
Var valve = new GPI/O(pin 5);

Method JSON retrieveData(JSONConsulta){
        Var http = getHttpConection(urlRetrieve);
        http.setMethod("GET");
        Var JSON = http.sendRequest(JSONConsulta,timeout);
        http.close();
        return JSON;
}

Method void actuate(){
        Var date = timer.getData();
        Var timeInterval = date - period;
        Var JSONConsult = "{ type:leakDetection, timestamp:date}" >= && >= "{ type:leakDetection, timestamp:date}"
        Var JSON = retrieveData(JSONConsult);
        if(JSON.result == 1%10 && JSON.result/10 == actuatorid){
            valve.setValue(1);
            return;
        }
        if(JSON.result == 'solved'){
            valve.setValue(0);
        }
}

Method void main(args[]){      
       Var Alarm = new Alarm(period*1000,actuate(),'infinite');
}

}






7. Technologies and project overview:

All the devices used in the project were provided by the Software/Hardware Integration Laboratory (LISHA).

7.1. Water Flow Sensor

Will be used a simple water flow sensor that has a turbine and sends a signal each time the turbine do a complete spin. How the water flows meter consumption is low and have a turbine that rotates with the water flow (this is how it works) it could be powered using the power generated by the rotation of the turbine.

http://bazaar.seeedstudio.com/item_detail.html?p_id=635

7.2. Dynamo

Description

7.3. Eletronic valve (Registro/válvula)

Description

7.4. EPOSMote III

The Embedded Parallel Operational System (EPOS) will run inside of EPOSMote III. The epos mote uses a 3v power source (at least that's what I remember), to support that, we can use AA stacks of 1.5v or a 12v battery with an electrical transformer embedded can also be used.

7.5. Sonar

7.6. Humidity sensor

7.7. 3v power source

7.8. 5v power source

7.9. 220v power source