Preparing the Raspberry Pis for the installation of Raspbian:

Step 1) I followed the next link in order to correctly copy the image file of Raspbian:

Step 2) The image was previously downloaded from this link and I selected the Debian Wheezy version of the Raspbian;


In order to create a Java program able to read the information from the GPIO pins, I followed some examples of programs using Pi4j that I found in the Internet: -> This one is written for Arduino but I used the logic for my program;!topic/pi4j/G307vbzisJ4 -> This one is written in Java, so it was useful to understand the usage of the libraries;

To use Pi4j, it's necessary to download the libraries from their website. This is possible following this link: The libraries of Pi4j include some useful examples.

During this project I wrote the Java code in another machine rather than the Raspberry Pi using Eclipse and then copied the .class file to the Raspberry Pi, but if it was necessary to compile the program (e.g a file named Main) in the Raspberry Pi using the terminal, the command to do this would be: javac -classpath .:/opt/pi4j/lib/'*' Main


The Paho client is used to communicate with the Mosquitto Server. So, Paho will receive the informations that come from the Raspberry Pis. In order to download the Java client, I followed the insructions existent in their own site. These instructions are present in this link:

In the link above is also possible to see an example of the code used in Java to connect with an MQTT Server. My code is based on this example.

The scheme of the two Raspberry Pis, assembled with the flow sensors is the following:


The database has a scheduled event that runs on a daily basis and which purpose is to calculate the sum of the water flow in Liters that was consumed during that day.

Last modified 5 years ago Last modified on Sep 2, 2015, 2:40:19 PM