wiki:Documentation

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: https://www.raspberrypi.org/documentation/installation/installing-images/linux.md

Step 2) The image was previously downloaded from this link https://www.raspberrypi.org/downloads/ and I selected the Debian Wheezy version of the Raspbian;

Pi4j:

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:

https://github.com/adafruit/Adafruit-Flow-Meter/blob/master/Adafruit_FlowMeter.pde -> This one is written for Arduino but I used the logic for my program;

https://groups.google.com/forum/#!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: http://pi4j.com/download.html 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

Paho:

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: https://www.eclipse.org/paho/clients/java/

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:

http://s24.postimg.org/44mb5s079/raspb_B_sensor_diagram.jpg

Database:

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