Hot answers tagged

20 votes

Do all GPIO pins have a internal pull-up/pull-down resistors?

Yes, all of the B+'s GPIO pins have internal pull-up or pull-down resistors that can be controlled from your code. Pull-up is 50K min – 65K max. Pull-down is 50K min – 60K max. More info on the GPIO ...
user avatar
4 votes

Output Accurate, Detailed PWM signal

The Pis with 40 pin expansion header (and the compute module) have two hardware PWM channels which you should be able to use with wiringPi. That would give you control of two ESCs. From the software ...
user avatar
  • 67.2k
3 votes

Enabling of I2C-0 via "dtparam=i2c_vc=on" on Pi 3B+ causes "I2C-10" & "I2C-11" to appear and disables GPIO 10 GPIO 11

The documentation states i2c_vc Set to "on" to enable the i2c interface usually reserved for the VideoCore processor ...
user avatar
  • 54k
3 votes

When to set internal pin resistance at software layer

That is not so good. So the 3.3V power pin from the RPi is connected to the breadboard's top-most rail via a red jumper (note this isn't actually used by the rest of the circuit but I don't believe ...
user avatar
  • 56k
3 votes

RejectedExecutionException in pi4j

Per the comments below the question, I can't really take the credit for this. jason.keisersmith had received a reply to a bug report posted to the Pi4J Github page here by user savageautomate on 18/03/...
user avatar
  • 10.6k
3 votes
Accepted

Java and DS18B20

Pi4J has released a 1-Wire API in version 1.1. It's no longer a SNAPSHOT version. W1Master master = new W1Master(); List<W1Device> w1Devices = master.getDevices(TmpDS18B20DeviceType.FAMILY_CODE)...
user avatar
  • 643
2 votes

Running a JAR file in Pi results in following error "can't find the main class"

Use java -cp myjar.jar javatest.Javatest first argument after '-cp' is the jar file, second is the classpath to class containing main(String[]) method If you dont have a MANIFEST in your jar file, ...
user avatar
2 votes

I created a GUI with gpio access in java and tested sucessfully in netbeans IDE. But when I runs in Raspberry pi it showing the following error

This depends on what you want to do. It seems that the java program does not get access to a running X11 server. Do you run X11 on your pi? If so, then physically connecting keyboard, mouse and screen ...
user avatar
  • 2,909
2 votes

Java Servlets and Raspberry Pi IO

I finally found out what the problem was! I forgot to add the Pi4J libraries (the jars) in the lib subfolder of my web application. That was stupid :D . Thanks anyway!
user avatar
  • 131
2 votes

Issues with Shift Registers and 8-Channel Relay on the Pi

I'm aware this was posted last Dec 2015. Just thought of sharing what I found to be the culprit of this problem. The CLEAR pin was not connected at all, so when I put it on HIGH, the problem went away ...
user avatar
2 votes
Accepted

Native C access to wiringPi from PI4J

This may seem like a slight aside, but perhaps may answer your question a little better. If this is all clear to you, I'll answer anyway in the hopes it is useful to someone else. All access to ...
user avatar
  • 567
2 votes

"Outside Function" issue with code when building a Reverse Park Sensor

In your code, the return command is placed outside the get_distance function. The return command can only be used when it is in a function, so it returns the output of the function you specify. When ...
user avatar
  • 302
2 votes

JavaFX on Raspberry PI 3 (Fullscreen/Black Bars)

Fortunately, You don't need to change operating system. You can use gtk2 platform, which works fine on my Raspberry Pi 3. Simply run you Jar application with this command: $JAVA_HOME/bin/java -...
user avatar
  • 21
1 vote

PCA9685GpioExample for pi4j 2

Adafruit has a very nice guide on this with some easy to follow instructions. You can find it at" https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi" There are ...
user avatar
  • 835
1 vote
Accepted

Pi4 GPIO Control with Java

Indeed as mentioned in the comments, Pi4J is using a different pin numbering scheme. "Under the hood", WiringPi is used to control the GPIOs. This library uses a different numbering scheme. ...
user avatar
  • 278
1 vote

Rpi4 - double HDMI functionality

The Raspberry Pi is used in a lot of digital signage applications. Double HDMI outputs differentiate the Pi in that market. Think of digital signs in airports, two screens mounted back-to-back. They ...
user avatar
  • 6,055
1 vote
Accepted

My Raspberry Pi B+ has the Ri 2 B pinmap

Looks to me you're mixing up pin numbering schemes. The B+ image above shows BCM (Broadcom) scheme. The second one is the wiringPi (and implicitly Pi4J) scheme (notice the text at the bottom of the ...
user avatar
  • 3,312
1 vote

provisionDigitalOutputPin sets mode to high low() and blink() don't work

I presume you want to get this working. I suggest you first find out if the software or the hardware is at fault. With that in mind I suggest the following steps. Remove the wire from wiringPi 7 (...
user avatar
  • 67.2k
1 vote

pi4j implementation for SPI communications with MCP3008 reading zeros

This isn't really an answer, but what I did to get SPI to work. I reformatted my uSD card with a clean installation of Ubuntu Mate 16.04.5, installed wiringPi, the pi4j libraries, and Oracle Java. I ...
user avatar
  • 111
1 vote

pi4j implementation for SPI communications with MCP3008 reading zeros

When using the SPI peripheral, rather than bitbanging it, you have to follow the documentation. On the Raspberry Pi 3, there is one SPI bus, with two (and only two) connections. The pins needed are: ...
user avatar
  • 1,523
1 vote

When to set internal pin resistance at software layer

When a GPIO set as an input has no definite voltage attached it is said to be floating and will randomly return 0 or 1. The purpose of the internal pull-ups and pull-downs is to stop a GPIO set as an ...
user avatar
  • 67.2k
1 vote
Accepted

GPIO works on PI Model B but does not work on PI 3 Model B

Problem solved. It was the Pi4J version. I migrated to the latest version (1.1) and it worked. Tks!
user avatar
1 vote

Software Flow Control in Serial communication

You do not need a library written especially for the Raspberry Pi. The major point of standardization and modularization of components, software and hardware, is interchangeability. A serial port is ...
user avatar
  • 56k
1 vote

Java and DS18B20

The API is open the file /sys/bus/w1/devices/28-00*/w1_slave, read the file, close the file, and then parse the results. Do that as often as needed but any faster than once every four seconds is ...
user avatar
  • 67.2k
1 vote

Running a JAR file in Pi results in following error "can't find the main class"

You didn't mention what parameters you were passing to Java but I suspect that you are not including PI4J on your classpath. You need to include the following: .:/opt/pi4j/lib/'*' for example java ...
user avatar
  • 1,744
1 vote

Gpio state can't be changed when connected to a DC motor or led

Do not attempt to drive heavy loads like a motor from the GPIOs. They can output a max of 18 mA (What is the maximum current the GPIO pins can output?) but the motor probably draws several hundred mA. ...
user avatar
  • 220
1 vote

How can I use Pi4J as a non-root user?

At the PI4J project page (the one written by the author of the package) which can be found here: http://pi4j.com/faq.html There is a definitive statement that PI4J must be run as root. Since this ...
user avatar
  • 1,744
1 vote
Accepted

pi4j provisionDigitalOutputPin without setting state low

Just for an update, I've tried looking through the source and it goes to a native call and I got lazy. The whole reason to use pi4j is my aversion to C. There's another problem in that you can ...
user avatar
  • 181
1 vote

Ultrasonic sensor get distance with java

I have written some java classes to use ultrasonic sensor with one of my project. Here it is. PiJavaUltrasonic.java import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible