knutejohnson.com/pi

Java Programs for the Raspberry Pi

Here are a few programs I have written in Java for the Raspberry Pi. They include a thermometer program to view remotely sensed temperatures and display them on a local touch screen, an intercom program and a program to detect motion and capture images with a Raspberry Pi camera.

Javadocs for the complete library are located here and the complete library may be downloaded here. Extract the library file in your ~/bin directory and you can use the included build scripts.

All of these programs require Java 8 but that is already installed on your Raspbian running Pi.

Please direct all questions, comments, suggestions or requests to: pi at knutejohnson dot com.

Thermometer

Thermometer Program - TempPanel Thermometer - SelectPanel Thermometer is a Java program to run on a Pi with a touch screen attached (ie UCTRONICS 3.5 inch touch screen) to display the temperature collected from up to six remote Pis running the TemperatureSender program.

The TemperatureSender?? programs read the temperature from a DHTxx or DS18B20 device attached to a Pi and sends the temperature via multicast packet to the Thermometer program.

Since the TemperatureSender?? programs use the dht11 or 1 wire device tree overlay to collect the temperature data from the sensor you need to enable it in /boot/config.txt with the line:

dtoverlay=dht11

or

dtoverlay=w1-gpio

Run the TemperatureSender?? program every minute using the following entry in your crontab:

java -jar TemperatureSenderDHT11.jar "Project Room" 0

or

java -jar TemperatureSenderDS18B20.jar 6774267 "Project Room" 0

I have tested the Thermometer program on a 1B+, a 3B and a 3B+. The program runs fine on all models however I did have some problems with using WiFi on the 1B+. With an ethernet connection to the local network it ran flawlessly on the 1B+. The TemperatureSender?? programs will run on any Pi, I'm currently testing with two 1Bs, an A+ and a B+ all connected to the network with WiFi.

Intercom

Intercom Program The Intercom program is a simple voice over IP intercom that will send voice data to another copy of the Intercom program.

MotionDetection

MotionDetection Program The MotionDetection program continuously takes images with the Raspberry Pi camera and displays them on the program window. If motion is detected a green dot indicator is displayed in the upper right corner of the screen. The images where motion is detected may be captured to storage or emailed. Also, as in the photo, a composite image may be displayed consisting of the previous image and a set of blue boxes showing where motion was detected in the image.