Pi4J intended to provide a friendly object-oriented I/O API and implementation libraries for Java Programmers to access the full I/O capabilities of the Raspberry Pi platform. This project abstracts the low-level native integration and interrupt monitoring to enable Java programmers to focus on implementing their application business logic.
Questions tagged [pi4j]
59 questions
1
vote
0 answers
javax.sql.DataSource-Spring boot
I'm a beginner and creating simple spring boot application with pi4j library, but i think have a problem with module-info.java. I don't know what's wrong. Is there a dependencies missing? I've tried different dependencies, changes in…

Dadzio008
- 11
- 3
1
vote
2 answers
Raspberry Pi4 with Pi4j Java
I am trying to run a simple test on my Raspberry Pi4 using the pi4j java library v1.2. Somehow it's not doing anything. I also don't see any errors on console. It just finishes after 2 seconds.
I'm expecting the LED light to turn on and turn off…

gtiwari333
- 24,554
- 15
- 75
- 102
1
vote
0 answers
Struts2 and PI4J
I tryied to use a Struts2 web framework with PI4J to change relays status on Rapsberry 3B+ device on Tomcat 9 web container.
My Action class.
package com.action;
import org.apache.log4j.Logger;
import…

slaw77
- 11
- 3
1
vote
1 answer
Pi4j Event Listener not triggered by GPIO status change
I have a simple Java program which should listen for changes of GPIO status.
I'm using a button to change the status of a GPIO and from terminal I can see it works:
Despite this, the event listener is never triggered.
Here is the code:
public…

CrystalSpider
- 377
- 7
- 16
1
vote
2 answers
Controlling a servo at Raspberry Pi with Springboot and ServoBlaster
I am trying to control a servo motor from a web interface. I am using SpringBoot 2.0, ServoBlaster and pi4j.
In order to start the application I am running as root ./gradlew bootrun --no-daemon. It has to be root in order to handle the GPIOs and I…

LiTTle
- 1,811
- 1
- 20
- 37
1
vote
0 answers
Java: how to access a Class' methods which also handles gpio initializations, without creating multiple instances
In summary, my project is a JavaFX application which controls a stepper motor, controlled by the RaspberryPi using the Pi4j library. The first version of my program was a simpler Java implementation run through the terminal. In v1, I had 2 classes:…

StefKat
- 11
- 1
1
vote
0 answers
Microsecond pulses with Raspberry Pi
Trying to output 10 mhz pulses with Raspberry Pi/pi4j, wiringPi...
No problem with millisecond pulses
This works on Mac...doesn't work on Raspberry Pi with pi4j and wiringpi installed:
final long INTERVAL = 100;
long start =…

sdvic
- 11
- 2
1
vote
1 answer
Is there a way to define the pin with an input?
I'm trying to program a kind of dmx controller, therefore I got a RaspberryPi and now I want to write a program to controlle a GPIO with pi4j. The idea is to ask for the GPIO that should be the output, save it in a int and reuse this to tell pi4j…

Ramadorrn
- 21
- 1
- 4
1
vote
0 answers
Pi4J : Detect all plugged devices
Is there a way to detect GPIO plugged devices using Pi4J ? Indeed, using GpioController object, you can get and change the state of the pin but not the presence/absence of device on it.
I may use it mainly for relays and DS18B20 devices.
If not…

Biologeek
- 541
- 2
- 6
- 18
1
vote
0 answers
PWM on raspberry pi frequency always low
I wrote a program in java using the pi4j library, i tried setting the frequency divisor as low as possible as you can see, but i'm getting an output frequency of about 1Hz and i can't seem to get it any higher. Any thoughts?
public class…

Simon Cools
- 69
- 5
1
vote
1 answer
How can read more bytes via I2c
I'm looking for an example on how to read more then 1 byte on Raspberry Pi via I2C. I see only this, but works only for the first byte sent:
package i2crpiarduino;
import com.pi4j.io.i2c.I2CBus;
import com.pi4j.io.i2c.I2CDevice;
import…

Francesco Valla
- 214
- 3
- 11
1
vote
0 answers
Pi4j compute GPIO Pin Status Raspberry
im trying to change a boolean value state with the corresponding state GPIO pin, but im doing this with not the attended result.
public class PlayWithGPIO {
public static boolean pinCarica = false;
public static void main(String[] args)…

Francesco Valla
- 214
- 3
- 11
1
vote
2 answers
DHT22 Sensor + pi4j + java
read temperature from DHT11, using pi4j
I the tried the code in the following link with prerequisites :
Java 1.8.0_65
pi4j 1.1
Raspberry Pi 3 Model B
DHT22 Temperature sensor.
Here when I am trying to execute the following both codes available in…

Arch
- 73
- 1
- 8
1
vote
1 answer
schedule a pi4j / Java task using crontab
I want to run a Java / pi4j Task (Script ControlGpioExample) periodically using crontab on my Raspberry PI.
This code works well on the Terminal:
sudo java -classpath .:classes:/opt/pi4j/lib/'*' ControlGpioExample
In Crontab I added the following…

tm011036
- 21
- 5
1
vote
1 answer
Pi4j Anemometer - counter per interval
I'm trying to use a digital anemometer to work with my raspberry PI with pi4j.
My idea was to add GpioPinListenerDigital to monitor when a pin goes high (means 1 complete anemometer rotation), but I cannot have it works... I would like to set an…

MarioC
- 2,934
- 15
- 59
- 111