Software Description - SmartMilk/SmartMilk GitHub Wiki

The software developed for this project has been written predominantly in C++, accessible through github via this link: https://github.com/SmartMilk/SmartMilk

The scripts contained within the repository serve distinctive purposes, and this page describes the main components (or classes) of each of these scripts, and their purpose towards the overall software. Please refer to the code itself for details on each of the individual functions (e.g. those to create GUI plot and buttons, read in temperature, etc).

Qt5 Graphical User Interface (GUI)

The programs involved in the design and construction of the Qt5 GUI are listed below:

  1. main.cpp: loads a splash screen while the program loads, constructs the GUI window and executes the application.

  2. window.h: contains the variables, classes, and objects needed to build the GUI window (e.g. buttons, labels, plot layout, threshold colours and values, etc) and attach data to the figure. Also defines the shell scripts for accessing prowl scripts.

  • shellScript1, shellScript2, and shellScript3: to send the messages to your phone automatically (as opposed to sending them manually, via the Home page instructions) we defined three shell scripts at the end of window.h, one for each prowl.pl script. The shell scripts act as a bridge between the Perl and C++ programs, and work by accessing their respective prowl scripts using the perl command, and then running when a particular condition is satisfied. The appropriate shell script is then called by invoking the system() function.
  1. window.cpp: contains the implementations of the everything defined in window.h, it creates all the main features of the GUI and plots the temperature values in real time. It also uses said temperature values to determine whether a countdown timer to send Prowl messages will be started.

  2. tempread.cpp : is a QThread class which intakes values from the temperature sensor and passes it to the Window class. The thread is initialized in Window's constructor Window::Window() and closed in Window's destructor Window::~Window().

  3. tempread.h : header file for the Tempread QThread class.

The figure below shows the Qt5 GUI in action:

alt text

We set our room and fridge temperature thresholds to 21degC and 5degC respectively. To account for fluctuations in the milk temperature once it reached room temperature, we defined a tolerance of 1.5degC (i.e. a lower bound of 19.5degC and upper bound of 21degC).

Prowl App Communication

The scripts involved in sending and receiving the user-defined messages from the RPi to the smartphone app, respectively, are listed below:

  1. prowl1.pl: contains the code to specify user message options, establish HTTP request to Prowl server, send the message, and evaluate response received from Prowl (i.e. whether notification was successfully posted to phone or not). Called from shellScript1 when system(shellScript1); is executed.

  2. prowl2.pl: same as above, but for message 2. Called from shellScript2 when system(shellScript2); is executed.

  3. prowl3.pl: same as above, but for message 3. Called from shellScript3 when system(shellScript3); is executed.

  4. prowlApiKey.txt: contains your Prowl API key generated from the website (see Home page). This is accessed by each of the prowl.pl scripts for specifying your Prowl account as the location to send the messages to. Copy and paste your own API key into this file.

Compiling and Running SmartMilk

The project file (SmartMilk.pro) is used to compile the git repository for running on your own computer. This file is required for telling your 'make' compiler how to compile the repository, and specifying what all of the main components central to the application are (e.g. libraries, classes, functions, header files, etc).

It works through completing the following steps:

  • Compile the code using 'qmake'. Type: qmake SmartMilk.pro

to generate Makefile, which instructs the 'make' compiler on how to compile and link the SmartMilk software.

  • Now type make to use this Makefile to generate SmartMilkApp, the executable file that can now be run from the command-line by typing: ./SmartMilkApp

The program will then start with a quick pop-up of the SmartMilk logo (expertly designed by Alex), and then fire straight into plotting the milk temperature data on the Qt5 interface.