{"id":20427100,"url":"https://github.com/pi4j/pi4j-example-crowpi","last_synced_at":"2025-07-30T14:38:47.718Z","repository":{"id":44909576,"uuid":"340146900","full_name":"Pi4J/pi4j-example-crowpi","owner":"Pi4J","description":"Pi4J V2 example which introduces you to electronics programming with Java on the Raspberry Pi and CrowPi","archived":false,"fork":false,"pushed_at":"2023-08-06T14:21:55.000Z","size":3048,"stargazers_count":10,"open_issues_count":7,"forks_count":10,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-19T21:01:07.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pi4J.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-02-18T18:51:28.000Z","updated_at":"2025-02-23T18:33:20.000Z","dependencies_parsed_at":"2025-04-12T19:10:19.792Z","dependency_job_id":"9afba2fd-32cb-4172-b9fe-67d727c0ea63","html_url":"https://github.com/Pi4J/pi4j-example-crowpi","commit_stats":null,"previous_names":[],"tags_count":3,"template":true,"template_full_name":null,"purl":"pkg:github/Pi4J/pi4j-example-crowpi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-crowpi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-crowpi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-crowpi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-crowpi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pi4J","download_url":"https://codeload.github.com/Pi4J/pi4j-example-crowpi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-crowpi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267883579,"owners_count":24160234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T07:18:55.013Z","updated_at":"2025-07-30T14:38:47.709Z","avatar_url":"https://github.com/Pi4J.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pi4J V2 :: CrowPi Examples\n\n[![Code Build Status](https://img.shields.io/github/workflow/status/Pi4J/pi4j-example-crowpi/CrowPi%20CI?label=code)](https://github.com/Pi4J/pi4j-example-crowpi/actions/workflows/crowpi.yml)\n[![Docs Build Status](https://img.shields.io/github/checks-status/Pi4J/pi4j-example-crowpi/gh-pages?label=docs)](https://pi4j.com/pi4j-example-crowpi/)\n[![Contributors](https://img.shields.io/github/contributors/Pi4J/pi4j-example-crowpi)](https://github.com/ppmathis/fhnw-crowpi/graphs/contributors)\n[![License](https://img.shields.io/github/license/Pi4J/pi4j-example-crowpi)](https://github.com/Pi4J/pi4j-example-crowpi/blob/main/LICENSE)\n\nThis project contains both example applications and ready-made component classes for interacting with the\n[CrowPi](https://www.elecrow.com/crowpi-compact-raspberry-pi-educational-kit.html) using the Pi4J (V2) library. You can easily get started with electronics programming by testing and modifying the bundled examples or even write your own application.\n\n## COMPONENTS\n\nThe provided component classes as part of this library provide an implementation for every available component of the CrowPi. The following\ntable provides an overview of all supported components with a link to their implementation and example app:\n\n\n| **Component**               | **Example App**                                                                                                 | **Implementation**                                                                                                        |\n|-----------------------------|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| Button                      | [ButtonApp.java](src/main/java/com/pi4j/crowpi/applications/ButtonApp.java)                                     | [ButtonComponent.java](src/main/java/com/pi4j/crowpi/components/ButtonComponent.java)                                     |\n| ButtonMatrix                | [ButtonMatrixApp.java](src/main/java/com/pi4j/crowpi/applications/ButtonMatrixApp.java)                         | [ButtonMatrixComponent.java](src/main/java/com/pi4j/crowpi/components/ButtonMatrixComponent.java)                         |\n| Buzzer                      | [BuzzerApp.java](src/main/java/com/pi4j/crowpi/applications/BuzzerApp.java)                                     | [BuzzerComponent.java](src/main/java/com/pi4j/crowpi/components/BuzzerComponent.java)                                     |\n| Humidity/Temperature Sensor | [HumiTempApp.java](src/main/java/com/pi4j/crowpi/applications/HumiTempApp.java)                                 | [HumiTempComponent.java](src/main/java/com/pi4j/crowpi/components/HumiTempComponent.java)                                 |\n| IR Receiver                 | [IrReceiverApp.java](src/main/java/com/pi4j/crowpi/applications/IrReceiverApp.java)                             | [IrReceiverComponent.java](src/main/java/com/pi4j/crowpi/components/IrReceiverComponent.java)                             |\n| LCD Display                 | [LcdDisplayApp.java](src/main/java/com/pi4j/crowpi/applications/LcdDisplayApp.java)                             | [LCDDisplayComponent.java](src/main/java/com/pi4j/crowpi/components/LcdDisplayComponent.java)                             |\n| LED Matrix                  | [LedMatrixApp.java](src/main/java/com/pi4j/crowpi/applications/LedMatrixApp.java)                               | [LedMatrixComponent.java](src/main/java/com/pi4j/crowpi/components/LedMatrixComponent.java)                               |\n| Light Sensor                | [LightSensorApp.java](src/main/java/com/pi4j/crowpi/applications/LightSensorApp.java)                           | [LightSensorComponent.java](src/main/java/com/pi4j/crowpi/components/LightSensorComponent.java)                           |\n| PIR Motion Sensor           | [PirMotionSensorApp.java](src/main/java/com/pi4j/crowpi/applications/PirMotionSensorApp.java)                   | [PirMotionSensorComponent.java](src/main/java/com/pi4j/crowpi/components/PirMotionSensorComponent.java)                   |\n| Relay                       | [RelayApp.java](src/main/java/com/pi4j/crowpi/applications/RelayApp.java)                                       | [RelayComponent.java](src/main/java/com/pi4j/crowpi/components/RelayComponent.java)                                       |\n| RFID                        | [RfidApp.java](src/main/java/com/pi4j/crowpi/applications/RfidApp.java)                                         | [RfidComponent.java](src/main/java/com/pi4j/crowpi/components/RfidComponent.java)                                         |\n| Servo Motor                 | [ServoMotorApp.java](src/main/java/com/pi4j/crowpi/applications/ServoMotorApp.java)                             | [ServoMotorComponent.java](src/main/java/com/pi4j/crowpi/components/ServoMotorComponent.java)                             |\n| Seven Segment Display       | [SevenSegmentApp.java](src/main/java/com/pi4j/crowpi/applications/SevenSegmentApp.java)                         | [SevenSegmentComponent.java](src/main/java/com/pi4j/crowpi/components/SevenSegmentComponent.java)                         |\n| Step Motor                  | [StepMotorApp.java](src/main/java/com/pi4j/crowpi/applications/StepMotorApp.java)                               | [StepMotorComponent.java](src/main/java/com/pi4j/crowpi/components/StepMotorComponent.java)                               |\n| Tilt Sensor                 | [TiltSensorApp.java](src/main/java/com/pi4j/crowpi/applications/TiltSensorApp.java)                             | [TiltSensorComponent.java](src/main/java/com/pi4j/crowpi/components/TiltSensorComponent.java)                             |\n| Touch Sensor                | [TouchSensorApp.java](src/main/java/com/pi4j/crowpi/applications/TouchSensorApp.java)                           | [TouchSensorComponent.java](src/main/java/com/pi4j/crowpi/components/TouchSensorComponent.java)                           |\n| Ultrasonic Distance Sensor  | [UltrasonicDistanceSensorApp.java](src/main/java/com/pi4j/crowpi/applications/UltrasonicDistanceSensorApp.java) | [UltrasonicDistanceSensorComponent.java](src/main/java/com/pi4j/crowpi/components/UltrasonicDistanceSensorComponent.java) |\n| Vibration Motor             | [VibrationMotorApp.java](src/main/java/com/pi4j/crowpi/applications/VibrationMotorApp.java)                     | [VibrationMotorComponent.java](src/main/java/com/pi4j/crowpi/components/VibrationMotorComponent.java)                     |\n\nDue to very tight timing constraints, two of the components had to use an alternative implementation without relying on Java. This could be\nimproved in the future by moving this logic into native code using JNI or putting these components behind a dedicated microcontroller:\n\n- **IR Receiver:** This component relies on the `mode2` binary for retrieving the signal pulses, provided as part of the LIRC software\n  bundle. While all parsing and logic has been implemented in Java, measuring the pulses accurately enough was not possible.\n- **Humidity/Temperature Sensor:** Due to being based on a DHT11 sensor, this component requires an extreme amount of precision in terms of\n  timing, resulting in measurement failures even when running as native code on a Raspberry Pi. To still provide some support for this\n  component, it requires setting up the `dht11` [kernel module](https://github.com/torvalds/linux/blob/master/drivers/iio/humidity/dht11.c)\n  which is part of Linux Industrial I/O.\n\nThe CrowPi OS image mentioned further down below supports both workarounds out of the box without further configuration.\n\n## CUSTOM OS IMAGE\n\nThe Pi4J-team provides several pre-built [custom OS images](https://github.com/Pi4J/pi4j-os). It's highly recommended to use the so called [Pi4J CrowPi OS](https://pi4j-download.com/latest.php?flavor=crowpi) for your CrowPi experiments to get the following set of benefits:\n\n- Preconfigured locale (en_US), keyboard (US) and timezone (Europe/Zurich)\n- Preconfigured wireless country (Switzerland) by default\n- Remote management via SSH and VNC possible without configuration\n- Preinstalled OpenJDK 17 and JavaFX to get quickly started\n- Preconfigured `/boot/config.txt` which supports all components out of the box\n- Dynamic wallpaper which shows Ethernet/WLAN address and hostname\n- Comes with `lirc` preinstalled to run the IR receiver component\n\n## Prepare CrowPi\n- download the latest [ Pi4J-CrowPi-OS](https://pi4j-download.com/latest.php?flavor=crowpi) image\n- extract the ZIP File\n- Use  [Raspberry Pi Imager](https://www.raspberrypi.org/blog/raspberry-pi-imager-imaging-utility/) \n  - Specify a new user `pi` with password `pi4j` in preferences of  `Imager`.\n  - Write the image to an SD-Card.\n- Start the CrowPi with this SD-Card.\n\n## FRAMEWORK\n\nTo simplify adding and launching new applications, a custom launcher has been built using PicoCLI.\nThe [Launcher.java](src/main/java/com/pi4j/crowpi/Launcher.java)\nclass contains a static list of available targets called `APPLICATIONS` which has to be adjusted when adding new applications to the project.\n\nBy default, an interactive menu gets shown which allows selecting a single target to launch. After executing this target, the application will automatically end. You may optionally specify the name of an application as the first argument, i.e. `BuzzerApp`, to directly launch this specific application.\n\nIf you want to comfortably test all supported components at once, you may specify the flag `--demo` which will return to the interactive\nlauncher menu once a target has been executed.\n\nCreating your own applications is as simple as implementing the provided [Application.java](src/main/java/com/pi4j/crowpi/Application.java) interface, which only requires a single `void execute(Context pi4j)` method.\n\n## BUILD SYSTEM\n\nThis project uses Maven for building, testing and running the various applications. While it can be used directly on a Raspberry Pi /\nCrowPi, it's recommended to use a separate developer machine and deploy the artifacts to the CrowPi and running them remotely. The following set of Maven properties can be set for remote deployments:\n\n- **`crowpi.hostname` :** Hostname of the CrowPi, defaults to `crowpi` is displayed as part of the wallpaper if you use Pi4J-CrowPi-OS Image\n- **`crowpi.ipnumber` :** Current IP address of the CrowPi, e.g. `192.168.1.2`, used for SCP/SSH, also shown as part of the wallpaper\n- **`crowpi.port`:** Port to use for SCP/SSH communication, defaults to `22`\n- **`crowpi.username` :** Username to use for SCP/SSH, defaults to `pi`\n- **`crowpi.password` :** Password to use for SCP/SSH, defaults to `pi4j`\n- **`crowpi.deploydirectory` :** Default directory to temporarily store built artifacts, defaults to `/home/pi/deploy`\n- **`crowpi.jvmOptions` :** Additional JVM options, defaults to an empty string\n\nIn case of a remote deployment, the artifacts get pushed via SCP and will be automatically executed using SSH. Please note that any existing files in the deployment folder are being automatically overwritten.\n\nRegardless of which deployment mode you have chosen, the property `launcher.args` can be set to specify which arguments should be passed as-is when running the launcher. This can be used for launching demo mode or directly executing a single application.\n\n## SYSTEM REQUIREMENTS\n\nYou may skip this section when using the pre-built Pi4J-CrowPi-OS image. \n\nShould you choose to run your own image instead, you will need to ensure\nthat the following lines are present in your `/boot/config.txt`:\n\n```ini\n[all]\n# Enable X with 128MB GPU memory and support the custom resolution of the CrowPi LCD panel\nstart_x = 1\ngpu_mem = 128\nhdmi_cvt 1024 600 60 6 0 0 0\n\n# Enable I2C and SPI\ndtparam = i2c_arm=on\ndtparam = spi=on\n\n# Enable audio\ndtparam = audio=on\n\n# Enable GPIO-IR\ndtoverlay = gpio-ir,gpio_pin=20\n\n# Enable DHT11\ndtoverlay = dht11,gpiopin=4\n\n# Enable DRM VC4 V3D with up to 2 frame buffers\ndtoverlay = vc4-fkms-v3d\nmax_framebuffers = 2\n```\n\nIf you want to use the IR receiver and/or humidity/temperature sensor component, you will have to ensure that the required dependencies mentioned in the \"COMPONENTS\" section of this README have also been fulfilled.\n\n## RUNTIME DEPENDENCIES\n\nThis project has the following runtime dependency requirements:\n\n- [**Pi4J V2**](https://pi4j.com/)\n- [**SLF4J (API)**](https://www.slf4j.org/)\n- [**SLF4J-SIMPLE**](https://www.slf4j.org/)\n- [**PIGPIO Library**](http://abyz.me.uk/rpi/pigpio) (for the Raspberry Pi)\n\n## BUILD AND RUN ON RASPBERRY PI\nAlthough not recommended, you can build and run this project on your CrowPi without using a separate developer machine. \n\n```shell\n$ git clone https://github.com/Pi4J/pi4j-example-crowpi.git\n$ cd pi4j-example-crowpi\n$ mvn package\n$ cd target/distribution/\n$ sudo java --module-path . --module com.pi4j.crowpi/com.pi4j.crowpi.Launcher $@\n\n\u003e No application has been specified, defaulting to interactive selection\n\u003e Run this launcher with --help for further information\n[main] INFO com.pi4j.Pi4J - New context builder\n[main] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.crowpi.helpers.CrowPiPlatform]\n\u003e The following launch targets are available:\n1) Exit launcher without running application\n2) ButtonApp (com.pi4j.crowpi.applications.ButtonApp)\n3) ButtonMatrixApp (com.pi4j.crowpi.applications.ButtonMatrixApp)\n4) BuzzerApp (com.pi4j.crowpi.applications.BuzzerApp)\n5) ExampleApp (com.pi4j.crowpi.applications.ExampleApp)\n6) HumiTempApp (com.pi4j.crowpi.applications.HumiTempApp)\n7) IrReceiverApp (com.pi4j.crowpi.applications.IrReceiverApp)\n8) LcdDisplayApp (com.pi4j.crowpi.applications.LcdDisplayApp)\n9) LedMatrixApp (com.pi4j.crowpi.applications.LedMatrixApp)\n10) LightSensorApp (com.pi4j.crowpi.applications.LightSensorApp)\n11) RfidApp (com.pi4j.crowpi.applications.RfidApp)\n12) PirMotionSensorApp (com.pi4j.crowpi.applications.PirMotionSensorApp)\n13) RelayApp (com.pi4j.crowpi.applications.RelayApp)\n14) ServoMotorApp (com.pi4j.crowpi.applications.ServoMotorApp)\n15) SevenSegmentApp (com.pi4j.crowpi.applications.SevenSegmentApp)\n16) SoundSensorApp (com.pi4j.crowpi.applications.SoundSensorApp)\n17) StepMotorApp (com.pi4j.crowpi.applications.StepMotorApp)\n18) TiltSensorApp (com.pi4j.crowpi.applications.TiltSensorApp)\n19) TouchSensorApp (com.pi4j.crowpi.applications.TouchSensorApp)\n20) UltrasonicDistanceSensorApp (com.pi4j.crowpi.applications.UltrasonicDistanceSensorApp)\n21) VibrationMotorApp (com.pi4j.crowpi.applications.VibrationMotorApp)\n\u003e Please choose your desired launch target by typing its number:\n```\n\n## LICENSE\n\nThis repository is licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the\nLicense. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpi4j%2Fpi4j-example-crowpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpi4j%2Fpi4j-example-crowpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpi4j%2Fpi4j-example-crowpi/lists"}