Hot answers tagged

18

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 can be found here and here. Example usage frm the PI4J documentation: // provision gpio pin #02 as an input pin with its internal pull down resistor enabled /...


4

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 side there are several modules which provide DMA timed PWM on any or all GPIO (e.g. my pigpio, servoblaster etc.). These modules provide a pipe interface to ...


3

The documentation states i2c_vc Set to "on" to enable the i2c interface usually reserved for the VideoCore processor (default "off") The 2nd I²C interface is reserved for HATs (and also probably used for GPIO extension - although this is undocumented)...


3

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/16, which suggested: If the entire program/process is not terminating, then you probably should not use the this.gpio.shutdown(); call. You should be ...


3

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); for (W1Device device : w1Devices) { //this line is enought if you want to read the temperature System.out.println("Temperature: " + ((...


3

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 it harms anything, right? Correct, it is pointless that way. When my software (running on the RPi) fires a signal to the buzzer via GPIO output pin, the ...


2

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, you need to specify which class contains the main(String[] args) method. If you want to avoid it in the future, and be able to run a jar via doubleclick (non ...


2

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 to it would probably solve your problem. If you want the program running on the pi to use the X11-server of the machine you are running ssh from, then simply ...


2

PI4J is a Java software module to control some of the Pi's gpios. The Pi has 54 gpios of which some 17 are accessible via the Pi's P1 connector. PI4J refers to these accessible gpios as pin#0 to pin#16. See http://pi4j.com/example/control.html You can switch those gpios on and off using PI4J. You can connect one of the pins on P1 to a LED then resistor ...


2

I used a GpioPinDigitalMultipurpose. More info can be found here. One can then do: // Provisions the pin. GpioPinDigitalMultipurpose mypin = gpio.provisionDigitalMultipurposePin(RaspiPin.GPIO_04, PinMode.DIGITAL_INPUT); // Sets it as an Output pin. mypin.setMode(PinMode.DIGITAL_OUTPUT); // Sets the state to "high". mypin.high(); // Sets the state to "...


2

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 GPIOs in Linux is done through the kernel. And there's a specific GPIO subsystem to handle this. Your very best performance would be to write a kernel driver. ...


2

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!


2

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 and the relay was working as expected. Hope this helps.


2

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 -Djavafx.platform=gtk2 -jar MyJavafxApp.jar With this command it won't go on fullscreen, it opens regular frame, and You can see also the console while Your app is ...


2

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 you use return distance, you should keep it in the function or it won’t make any sense to Python. Right now, it ends with global start.


1

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 can now show diffrerent content.


1

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 image). The gpio utility, which is part of wiringPi, also uses this scheme by default. Use https://pinout.xyz/ for reference.


1

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 (which happens to be physical pin 7). In a terminal window enter the command sudo pigpiod. This starts the pigpio daemon in the background. Download and unzip ...


1

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 tested SPI using the spidevtest.c and the example programs supplied with pi4j and SPI work flawlessly.


1

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: MOSI - pin 19(Master Out Slave In) used to transfer data TO the Raspberry Pi MISO - pin 21 used to transfer data FROM the Raspberry Pi SCLK - pin 23 the SPI ...


1

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 pretty pointless. Here is some Python code you can adapt. #!/usr/bin/env python import glob import time # Typical reading # 73 01 4b 46 7f ff 0d 10 41 : crc=41 ...


1

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 input from floating by connecting to ground (pull-down) or 3V3 (pull-up). That means it will return a consistent result until overridden by such as a button ...


1

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


1

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 a serial port. Of course, accessing a serial port "natively" on Windows is probably going to be different than on Linux (I presume you are using the latter), ...


1

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. In other words, you have virtually shorted your GPIO to ground and it cannot output high. The way to drive motors is to use the GPIO to drive a transistor and ...


1

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 -cp .:/opt/pi4j/lib/'*' javatest/Javatest


1

I get the same problem but only when I shutdown and restart the program right away. I put a one second delay before getting the gpio instance. You can check for null and try again as needed, but it hasn't failed since. // create gpio controller log("trying to get gpio controller... "); Thread.sleep(1000); final GpioController gpio = ...


1

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 is found in the frequently asked questions section, I must assume that to be the definitive and final answer. I don't know the internals that cause it to be ...


1

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 really only have one pi4j program running as starting another one erases some .so file and breaks the running program. I've solved the problem for my specific ...


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