========================================================================== Pi4J: Java library for Raspberry Pi
Project website: http://www.pi4j.com/
Project discussion group: https://groups.google.com/forum/#!forum/pi4j
Project issues list: https://github.com/Pi4J/pi4j/issues
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Prepare your Raspberry Pi (Running Arch linux):
> sudo pacman -S git-core make gcc libtool jdk7-openjdk
-
Install WiringPi on your Raspberry Pi:
> git clone git://git.drogon.net/wiringPi > cd wiringPi > ./build
-
Test the WiringPi install:
> gpio -v > gpio readall
-
Set JAVA_HOME on your default profile:
> sudo vim /etc/profile export JAVA_HOME=/usr/lib/jvm/java-7-openjdk
-
Set JAVA_HOME for your default environment. This is needed when Maven will connect with the Raspberry Pi over SSH.
> sudo vim /etc/environment export JAVA_HOME=/usr/lib/jvm/java-7-openjdk
-
Clone this repository:
> git clone https://github.com/glnds/pi4j-arch
-
Adjust the pom.xml
> cd pi4j-arch > vim pox.xml ... <!-- DEFAULT RASPBERRY PI PROPERTIES --> <pi.host>192.168.1.1</pi.host> <pi.port>22</pi.port> <pi.user>root</pi.user> <pi.password>root</pi.password> ...
-
Install Maven: http://maven.apache.org/
-
Build Pi4J:
mvn clean install -P native -P hard-float
Important note: currently, the script only works when executed by the root user. If you want to run it under a different user, you will have to grant the user root privileges and suppress its need to provide a password. I've not tested it but probable you have to setup your user like this:
> sudo visudo
...
user ALL=(ALL) NOPASSWD: ALL
...
You will also have to do some minor adjustments to the build.xml file.
This build procedure is based on the original build instruction of Pi4J.
-
If not yet downloaded, download the Arch build here (or use your own build).
-
Copy the Pi4J library to your Raspberry pi:
> scp pi4j-0.0.5.tar.gz pi@rpi.local:~/
-
Extract the archive:
> tar -xvzf pi4j-0.0.5.tar.gz
-
Intall the libraries:
> sudo mkdir /opt/pi4j > sudo mv ~/pi4j-0.0.5/lib/ /opt/pi4j/ > sudo mv ~/pi4j-0.0.5/examples/ /opt/pi4j/
Done! You can now use Pi4J on your Raspberry Pi running Arch Linux. Here's an example:
sudo java -cp SomeJar.jar:.:classes:/opt/pi4j/lib/'*' be.pixxis.Example