Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

103 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pi4J Demo

This is a Spring-based demo project to show how a Vaadin User Interface (website) can interact with the GPIOs of a Raspberry Pi by using the Pi4J library.

Supported Development Boards

The application supports multiple development boards with automatic feature detection:

CrowPi (1, 2, and 3)

The CrowPi is an all-in-one Raspberry Pi learning kit with various components. Different CrowPi versions contain different components, so the application adapts based on the configured version.

Features: LED, Touch sensor, LCD display, 7-segment display, Buzzer, LED matrix (Red or RGB depending on version), DHT11 sensor

Pioneer600

The Pioneer600 is a Raspberry Pi expansion board with a different set of components.

Features: LED (GPIO 26), Key/Button (GPIO 20), OLED display (SSD1306 via SPI), BMP280 barometric sensor (I2C), Joystick and Buzzer (PCF8574 I/O expander), IR Receiver (GPIO 18)

Configuration

The board type is configured in application.properties or via command line:

# Options: crowpi-1, crowpi-2, crowpi-3, pioneer600
board.type=crowpi-2

You can also use any other Raspberry Pi with a GPIO header and connect electronic components directly to the GPIO pins. Change the pin numbers as needed in a custom configuration class.

Branch Information

Following versions of this code are available in branches:

Vaadin UI

The base code with different Vaadin layouts, was generated on start.vaadin.com/app.

Vaadin UI

Components

The application can interact with various components in the CrowPi1.

Demo content on CrowPi

Upload to Raspberry Pi

If you are developing on a PC, you can build the application with the following command

  • Windows: mvnw clean package
  • Mac & Linux: ./mvnw clean package

and upload to your Raspberry Pi with (replace login pi and the IP address with the one of your board)

$ scp target/pi4jdemo-1.0-SNAPSHOT.jar pi@192.168.0.222://home/pi/

Build and upload in one command:

./mvnw clean package && scp target/pi4jdemo-1.0-SNAPSHOT.jar frank@crowpi3.local://home/frank/

Run on Raspberry Pi

CrowPi Setup

PWM and DHT11 need to be enabled on the Raspberry Pi. For example, on a Raspberry Pi 5:

$ sudo nano /boot/firmware/config.txt
# Add at the end of the file:
dtoverlay=pwm-2chan,pin=18,func=2,pin2=12,func2=4
dtoverlay=dht11,gpiopin=4

Pioneer600 Setup

The Pioneer600 requires SPI and I2C interfaces to be enabled for its components:

Component Interface Configuration
OLED Display (SSD1306) SPI Bus 0, RST=GPIO19, DC=GPIO16
BMP280 Sensor I2C Address 0x76
Joystick/Buzzer (PCF8574) I2C I/O Expander
LED GPIO BCM 26
KEY/Button GPIO BCM 20
IR Receiver GPIO BCM 18

Enable the required interfaces using raspi-config:

sudo raspi-config
# Interface Options -> SPI -> Enable
# Interface Options -> I2C -> Enable

Or add to /boot/firmware/config.txt:

dtparam=spi=on
dtparam=i2c_arm=on

Reboot after making changes.

Starting the Application

Specify the board type you are using:

# For CrowPi
$ java -jar /home/pi/pi4jdemo-1.0-SNAPSHOT.jar --board.type=crowpi-3

# For Pioneer600
$ java -jar /home/pi/pi4jdemo-1.0-SNAPSHOT.jar --board.type=pioneer600

About

Examples of a Vaadin UI interacting with the GPIOs of the Raspberry Pi using the Pi4J library

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages