The HomeLab-pH board is just a measuring block. It has to be assisted by an external CPU-board and corresponding software to perform the calculations. The software package, which can be downloaded here, is intended to work with Raspberry Pi or compatible computer as server. (For Arduino boards read this page.) It visualizes the measured data and presents to the user an interface to log the pH, set timing for periodic unassisted measurements and calibrate the device. Visualization is done by a browser residing on a smartphone, laptop, tablet, etc. that connects to a LAN-address where the server is installed.
Additionally, interested users can access the measured data at the Raspbian/Ubuntu Mate console or get it remotely via an http request.
Access the visual interface by pointing a web browser to
The visual interface consists of a button bar and three areas where digital values are displayed. Just below the button bar is the pH value. The other two areas show the voltage generated by the pH-sensor and the sample temperature measured by the temperature sensor.
A tiny display bottom right shows the difference between the current temperature and the one measured during the calibration.
Measured data can also be accessed at the shell by:
For json-formated output use "-json" or "-j" option:
If error or warning messages are present they are shown as "errorStrings" - a comma-separated list of strings. This case is illustrated at the lower part of the picture above, where a missing temperature sensor is reported. Some members may get the value of "skipped" (or boolean "false" in json-formated response).
It is possible to read HomeLab-pH data also using Python. The script has to execute the above shell command.see how
import os, json
# execute the shell command and assign the result
data = os.popen('/var/www/homelab/cgi-bin/get_pH.sh -json').read()
# just to see the result
# convert the json string
d = json.loads(data)
# see the pH value
# see the temperature
To see the json-formated output above, type at the browser address field the following address:
replacing accordingly the <rpi-ip-address>.
Of course, to see the http response you may also simply invoke cURL at the console.
The package installation is performed under Raspbian or Ubuntu Mate operating systems. They should be downloaded at the Raspberry Pi web site. Raspbian is in fact a Debian GNU-Linux. Supported are 7.8, 8.0 and all later Debian versions. Ubuntu supported version is "Ubuntu Mate for the RPi 2 & RPi 3", versions 16.04 and 18.04.
The operating system should have Apache web-server installed to send the module readings to the browser. If it is not found the installation script will try to install the Apache package. Other modules and packages to be installed if not present are: i2c_bcm2708, i2c_dev, i2c-tools, w1-gpio, w1-therm and bc.
An active internet connection has to be available during the installation.
Be sure the RPi, which the HomeLab-pH board is mounted on, is connected to the LAN and powered. Plug in the temperature sensor and a pH-electrode in their sockets on the board. Start a web-browser on a whatever device (laptop, tablet, smartphone) connected to the same LAN and point it to the device's IP-address. You will see the HomeLab-pH page main screen with the meter readings.
What if you do not know the local IP-address of the RPi? Well, you may try the address printed at the end of the installation procedure. If you have just installed the software there is a good chance for the IP-address to not being changed by the router. Otherwise you have to use a LAN-scanner to find the address.
If the RPi is configured to use a dynamic IP-address, when restarted it may be assigned a different one by the router. So, if you are forced to do address searching frequently when measuring pH, it is better to assign a static (not changing) IP-address to the RPi computer.
If you have found a bug or have a proposal for improving the user experience, please share it with us at the contact form.
This software may take continuous unassisted measurements - PUM. The time interval between measurements is user-selectable ranging from 5 min to 24 hours. For intervals greater then 1 hour the user additionally may set the full hour at which the measurement is to be taken.
The PUM rely on a cron job which fires every five minutes starting at full hour. The job is not registered to crontab by default. Its availability is managed in two ways: by the installation script or by shell commands.
To make the cron job running the software installation script should be started with an argument:
sudo bash homelab_install.sh --enable-pum
Alternatively if present the job is removed during installation with:
sudo bash homelab_install.sh --disable-pum
If neither option is set the user would be asked to decide intaractivelly.
The cron job is also managed by shell console commands. May be started by:
and removed by:
Only one PUM-task can be active at a time. A prerequisite to start a task is to have a running PUM cron job. The cron job reads the task's configuration file to determine if it's time to take a measurement. This file location is:
The file content is governed by the visual interface ( click [see how] button here ). So it's not good practice to change the contents manually.
Below is an example of a PUM-task configuration data. The data is in JSON format.
The "id" of each task is unique and reflects the time the task has been set at.
Each task has its own log file. Below is a short excerpt from a common PUM log. This is what is logged when calibration is available and both sensors are in place.
The data log is JSON-formated, the first line being a copy of the PUM-task's configuration data. Each time a new measurement is taken for the task, a new line with data is appended, where:
The directory where the PUM log files are placed is:
The file rotation feature allows data logging to be done in a special way. If file rotation is active a new log file is started every 24 hours. Unlike the usual PUM task's the file rotation task has multiple files and an "id" in such a file reflects the time (future) when the file will be rotated at.
To use or not 24 hour file rotation is controlled by the visual interface (default is NO). The time when the rotation is to be done is set in a configuration file. To change the time edit this file:
Data accumulated from periodic unassisted measurements (PUM) is periodically send to the cloud and at user demand its plot is retrieved from there. Currently the ThingSpeak cloud service is used for the purpose.
The usage of the feature is controlled by shell commands. To start/stop sending data to the Thingspeak cloud use:
There are two prerequisites before seeing your data plotted: register a data channel at thingspeak.com (they offer a free account, which is suitable for this usage) and enter the channel's connection attributes in a configuration file.
So, the first step is to register an account at ThingSpeak. It would not take more than a couple of minutes. Go to thingspeak.com and do it. An email box has to be available for the account verification.
Second - create a data channel. In the freshly created account go to Channels > My Channels and click the New Channel button. Give a name to the channel and activate the first 3 fields of the channel. These will be accessed by our software to write the pH, temperature and voltage values respectively, in this order. See the picture.
Save the channel.
In the new screen go to API keys and look for 3 items: the Channel ID, the Write API Key and the Read API Key. See the picture.
Write down or copy their values for later use. Click around the channel menu to see you can do other useful things here like clearing your data or making the channel private.
The third step is to edit a configuration file of the installed HomeLab software. The simplest way is to start the nano editor at the shell:
and replace there the values of the channel_id, the write_api_key and the read_api_key with the ones from the ThingSpeak channel. See the picture.
Save the changes.
Now - time for a test.
The changes to the previuos 181126B BETA version include
- support for Rev.4 of the HomeLab-pH module,
- the Periodic Unassisted Measurements will not be available by default and can be enabled (and disabled) via shell commands or during installation,
- the GPIOs to read the temperature sensor and the button may be set in the installation script
- other minor changes and bug fixes (see versions' log below).
Log of the versions' changes.