Skip to content

harlanhu/rpi-device-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpi-device-sdk

Based on pi4j-v2 Raspberry Pi equipment application SDK. You can use the SDK to create common equipment and control the equipment for base functions easily.

[Note] The current tests only pass on the Raspberry Pi 4B

Device List

  • Active Buzzer
  • Passive Buzzer
  • Button
  • LED Light
  • PCF8591
  • HCSR04
  • DHT11
  • DHT22

The equipment list will be updated continuously.

How to use

Maven

  • Add dependency to pom.xml
<dependency>
    <groupId>cn.tpkf.rpi</groupId>
    <artifactId>rpi-device-sdk</artifactId>
    <version>0.0.1</version>
</dependency>
  • A simple example
public static void main(String[] args) {
    // Create Pi4J context
    Context context = Pi4J.newAutoContext();
    // Create a new Device Manager
    DeviceManager deviceManager = new DeviceManager(context);
    // Create a new device example LED and blink
    Led led = new Led(deviceManager, "led-4", "LED", BCMEnums.BCM_4);
    led.blink(1, 5, TimeUnit.SECONDS);
    //shutdown led
    led.shutdown();
    //shutdown device manager
    deviceManager.shutdown();
}

Last

Thank PI4J very much for providing such a good raspberry pi I/O library.

SonarCloud