Records and displays temperatures gathered from a Raspberry Pi.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
pom.xml

README.md

pi-temperature

Records and displays temperatures gathered from a Raspberry Pi through the use of Vktech DS18b20 temperature sensors.

Table of Contents

Requirements

  • JDK 7
  • Maven 3

Installation

  1. Wire up the temperature sensors to your Raspberry Pi and run the following commands:
sudo modprobe w1-gpio
sudo modprobe w1-therm
  1. Checkout the project: git clone https://github.com/DWiechert/pi-temperature.git
  2. Build the project: mvn clean install -Dmaven.test.skip
  3. SCP the built war <project-directory>/target/pi-temperature-<version>.war onto your Raspberry Pi.
  4. Start the war: sudo java -jar pi-temperature-<version>.war

To check the installation and setup were successful, there is a hello-world REST endpoint to test with: curl <raspberry-pi-ip>:8080/hello-world

Temperature Usage

Sensors

REST Endpoints Sensors
Endpoint Method Variables Example Description
/sensors/list GET None curl <raspberry-pi-ip>:8080/sensors/list Returns a list of all Sensors and their information - name, serialId, tempC, tempF.
/sensors/list/<name> GET None curl <raspberry-pi-ip>:8080/sensors/list/<name> Returns the specified Sensor and its information - name, serialId, tempC, tempF.
/sensors/name/<serialId> PUT <serialId> curl -X PUT -d "Some name" <raspberry-pi-ip>:8080/sensors/name/<name> Updates the provided sensor with a user-friendly name.
Overrides
  • By default, sensors are read every minute and update the alerts that are currently set on. The time between sensor reads can be overridden by providing the sensorScanSchedule property in the application.properties file. The sensor scan schedules use the Quartz Cron Expressions. Example of overridding the schedule to read every 10 seconds:
sensorScanSchedule=0/10 * * * * ?
  • By default, sensors are read from the directory /sys/bus/w1/devices/w1_bus_master1/. The sensors directory can be overridden by providing the sensorsMasterDirectory property in the application.properties file. Example of overridding the sensors directory:
sensorsMasterDirectory=S:\\sensors\\

Alerts

REST Endpoints Alerts
Endpoint Method Variables Example Description
/alerts/list GET None curl <raspberry-pi-ip>:8080/alerts/list Returns a list of all Alerts and their status (on or off).
/alerts/list/<name> GET None curl <raspberry-pi-ip>:8080/alerts/list/<name> Returnsthe specific Alert and its status (on or off).
/alerts/setOn/<name> PUT <name> - The name of the alert. curl -X PUT <raspberry-pi-ip>:8080/alerts/setOn/<name> Turns the specified alert on.
/alerts/setOff/<name> PUT <name> - The name of the alert. curl -X PUT <raspberry-pi-ip>:8080/alerts/setOff/<name> Turns the specified alert off.
/alerts/update/<name> PUT <name> - The name of the alert. curl -X PUT -d "Some message" <raspberry-pi-ip>:8080/alerts/update/<name> Updates the specified alert with the provided message.
CsvAlert

This alert writes the sensor data to a csv file. The alert name is CsvAlert and the supported update information is:

Variable Type Default
filename String sensor-data.csv
delimiter char ,

An example of updating this alert to write to a file called something.csv with a delimiter of @ is:

curl -X PUT -d {\"filename\":\"something.csv\",\"delimiter\":\"@\"} <raspberry-pi-ip>:8080/alerts/update/CsvAlert