diff --git a/.gitignore b/.gitignore index 969b3915..b2010b72 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,5 @@ out/ .classpath .factorypath *@* -Workflow.png +Workflow_Diagram.png Pi4Micronaut_logo.png diff --git a/README.md b/README.md index 8bb161a0..45759072 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Pi4Micronaut is an innovative Java library crafted for developers who aim to bui The existence of Pi4Micronaut is justified by the need for a robust, scalable, and efficient way to bridge the gap between enterprise-grade software and the physical world of hardware. It is particularly valuable for projects that demand both the high-performance, microservices-oriented capabilities of the Micronaut framework and the versatile hardware interaction that the Raspberry Pi offers. Whether it's for home automation, industrial monitoring, or educational purposes, Pi4Micronaut empowers developers to deliver reliable and sophisticated IoT applications that can run headless on a Raspberry Pi or be managed remotely, providing convenience, control, and customization to the end-users. +**Note:** Pi4Micronaut doesn't work with the latest Raspberry Pi 5 because of its whole new architecture. Pi4J and pigpio libraries doesn't provide support for Pi 5 yet. Look out for the latest version of Pi4J to work with Pi5's in the future. + ### Information - **Source Code:** @@ -25,7 +27,7 @@ The existence of Pi4Micronaut is justified by the need for a robust, scalable, a - **Adoption Date:** August 2022 - **Technologies Used:** - Java - - Micronaut Framework + - Micronaut Framework with Gradle - Pi4J Library - **Type:** IOT (Raspberry Pi) - **License:** [Apache License 2.0](https://opensource.org/license/apache-2-0/) @@ -34,9 +36,16 @@ The existence of Pi4Micronaut is justified by the need for a robust, scalable, a ## Pi4Micronaut - [Link to Pi4Micronaut Documentation](https://oss-slu.github.io/Pi4Micronaut/) - [API Reference](https://oss-slu.github.io/Pi4Micronaut/javadoc/index.html) +- [Maven Central Repository](https://central.sonatype.com/artifact/io.github.oss-slu/pi4micronaut-utils) +- [Maven Artifacts](https://repo1.maven.org/maven2/io/github/oss-slu/pi4micronaut-utils/) ### Architecture Diagram -![Pi4Micronaut.png](Workflow.png) +![Pi4Micronaut.png](Workflow_Diagram.png) + +## Example Projects using Pi4Micronaut Library +- [Home Automation](https://github.com/oss-slu/Pi4Micronaut/tree/Home_Automation) +- [Lab Automation](https://github.com/oss-slu/Pi4Micronaut/tree/Lab_Automation) +- [OSS SLU Checkin](https://github.com/oss-slu/SLU_OSS_CheckIn) ## Micronaut 3.7.3 - [Micronaut 3.7.3 User Guide](https://micronaut-projects.github.io/micronaut-docs-mn3/3.7.3/guide/index.html) diff --git a/Workflow.png b/Workflow.png deleted file mode 100644 index 92e056a2..00000000 Binary files a/Workflow.png and /dev/null differ diff --git a/Workflow_Diagram.png b/Workflow_Diagram.png new file mode 100644 index 00000000..0ab4f90a Binary files /dev/null and b/Workflow_Diagram.png differ diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/ActiveBuzzerController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/ActiveBuzzerController.java index d25c60de..8fbaaeba 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/ActiveBuzzerController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/ActiveBuzzerController.java @@ -6,6 +6,7 @@ import io.micronaut.http.annotation.Get; import jakarta.inject.Named; +//tag::ex[] @Controller("/active-buzzer") public class ActiveBuzzerController { @@ -37,7 +38,7 @@ public void disableActiveBuzzer(){ } /** - * Emits an beep sound from the active buzzer. + * Emits a beep sound from the active buzzer. */ @Get("/beepTone") public void playBeepTone(){ @@ -65,4 +66,5 @@ public void morseCodeTest(){ activeBuzzerHelper.morseCodeTone(); } -} \ No newline at end of file +} +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java index eda4a6bd..5c037b5c 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java @@ -6,6 +6,7 @@ import io.micronaut.http.annotation.Get; import jakarta.inject.Named; +//tag::ex[] @Controller("/led") public class LEDController { private final LEDHelper ledHelper; @@ -28,4 +29,10 @@ public void ledOff(){ public void switchState(){ ledHelper.switchState(); } + + @Get("/blink/{duration}/") + public void blink(int duration){ + ledHelper.blink(duration); + } } +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/MicroSwitchController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/MicroSwitchController.java new file mode 100644 index 00000000..4f7791ea --- /dev/null +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/MicroSwitchController.java @@ -0,0 +1,49 @@ +package com.opensourcewithslu.components.controllers; + +import com.opensourcewithslu.inputdevices.MicroSwitchHelper; +import com.opensourcewithslu.outputdevices.LEDHelper; +import com.pi4j.io.gpio.digital.DigitalInput; +import com.pi4j.io.gpio.digital.DigitalOutput; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Get; +import jakarta.inject.Named; + +//tag::ex[] +@Controller("/microSwitch") +public class MicroSwitchController { + + private final MicroSwitchHelper microSwitchHelper; + + private final LEDHelper ledHelper1; + private final LEDHelper ledHelper2; + + + public MicroSwitchController(@Named("micro-switch") DigitalInput microSwitch, + @Named("led") DigitalOutput led1, + @Named("led2") DigitalOutput led2) { + this.microSwitchHelper = new MicroSwitchHelper(microSwitch); + this.ledHelper1 = new LEDHelper(led1); + this.ledHelper2 = new LEDHelper(led2); + } +//enables the micro switch. The LEDs will switch states as the switch is pressed + @Get("/enable") + public void enableMicroSwitch() { + microSwitchHelper.addEventListener(e -> { + if (microSwitchHelper.isPressed) { + ledHelper1.ledOff(); + ledHelper2.ledOn(); + + } + else { + ledHelper1.ledOn(); + ledHelper2.ledOff(); + } + }); + } + //disable the micro switch + @Get("/disable") + public void disableMicroSwitch() { + microSwitchHelper.removeEventListener(); + } +} +//end::ex[] diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/PIRSensorController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/PIRSensorController.java index defb9557..4e0ded9a 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/PIRSensorController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/PIRSensorController.java @@ -2,7 +2,7 @@ import com.opensourcewithslu.inputdevices.PIRSensorHelper; import com.opensourcewithslu.outputdevices.RGBLEDHelper; -import com.opensourcewithslu.utilities.MultipinConfiguration; +import com.opensourcewithslu.utilities.MultiPinConfiguration; import com.pi4j.io.gpio.digital.DigitalInput; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; @@ -11,33 +11,28 @@ /** * The PIRSensorController class is used with the PIRSensorHelper class and RGBHelper class to implement a PIR motion sensor with an RGB LED light. */ + +//tag::ex[] @Controller("/pirSensor") public class PIRSensorController { - private final PIRSensorHelper pirSensorHelper; - private final RGBLEDHelper rgbledHelper; - /** * The PirSensorController constructor. * @param pirSensor A Pi4J DigitalInput object. * @param rgbLed A MultiPinConfiguration object. */ - public PIRSensorController(@Named("pir-sensor")DigitalInput pirSensor, - @Named("rgb-led-2")MultipinConfiguration rgbLed) { + public PIRSensorController(@Named("pir-sensor") DigitalInput pirSensor, @Named("rgb-led-2") MultiPinConfiguration rgbLed) { this.pirSensorHelper = new PIRSensorHelper(pirSensor); this.rgbledHelper = new RGBLEDHelper(rgbLed); } - /** * Enables the PIR sensor by adding an event listener which sets the RGB LED to red when movement is detected and green otherwise. */ @Get("/enable") public void enablePIRSensor() { - int[] red = {255,0,0}; int[] green = {0,255,0}; - pirSensorHelper.addEventListener(e -> { if (pirSensorHelper.isMoving) { rgbledHelper.setColor(red); @@ -47,7 +42,6 @@ public void enablePIRSensor() { } }); } - /** * Disables the controller by removing the event listener and turning off the RGB LED. */ @@ -56,5 +50,5 @@ public void disablePIRSensor() { pirSensorHelper.removeEventListener(); rgbledHelper.ledOff(); } - -} \ No newline at end of file +} +//end::ex[] diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/PassiveBuzzerController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/PassiveBuzzerController.java index 66ffb612..eb695fdc 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/PassiveBuzzerController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/PassiveBuzzerController.java @@ -6,6 +6,7 @@ import jakarta.inject.Named; import java.io.File; +//tag::ex[] @Controller("/passive-buzzer") public class PassiveBuzzerController { @@ -94,4 +95,5 @@ public void playPiTone(){ passiveBuzzerHelper.piToneSequence(); } -} \ No newline at end of file +} +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/PhotoResistorController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/PhotoResistorController.java index e783ec0c..c81dfcea 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/PhotoResistorController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/PhotoResistorController.java @@ -10,6 +10,7 @@ import jakarta.inject.Named; import javax.validation.constraints.Positive; +//tag::ex[] @Controller("/photoResistor") public class PhotoResistorController { private final LEDHelper ledHelper; @@ -55,4 +56,5 @@ public String setThreshold(@Positive int i) { return ("Darkness threshold set to "+ i + "\n"); } -} \ No newline at end of file +} +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/RotaryEncoderController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/RotaryEncoderController.java index e083d769..b9d857e9 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/RotaryEncoderController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/RotaryEncoderController.java @@ -1,7 +1,7 @@ package com.opensourcewithslu.components.controllers; import com.opensourcewithslu.inputdevices.RotaryEncoderHelper; -import com.opensourcewithslu.utilities.MultipinConfiguration; +import com.opensourcewithslu.utilities.MultiPinConfiguration; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; import jakarta.inject.Named; @@ -11,7 +11,7 @@ public class RotaryEncoderController { private final RotaryEncoderHelper encoderHelper; - public RotaryEncoderController(@Named("rotary-encoder")MultipinConfiguration rotaryEncoder){ + public RotaryEncoderController(@Named("rotary-encoder") MultiPinConfiguration rotaryEncoder){ this.encoderHelper = new RotaryEncoderHelper(rotaryEncoder); } diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/ServoMotorController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/ServoMotorController.java new file mode 100644 index 00000000..2d433690 --- /dev/null +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/ServoMotorController.java @@ -0,0 +1,34 @@ +package com.opensourcewithslu.components.controllers; + +import com.opensourcewithslu.outputdevices.ServoMotorHelper; +import com.pi4j.io.pwm.Pwm; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Get; +import jakarta.inject.Named; + +//tag::ex[] +@Controller("/servoMotor") +public class ServoMotorController { + + private final ServoMotorHelper servoMotorHelper; + + public ServoMotorController(@Named("servo-motor")Pwm servoMotor) { + this.servoMotorHelper = new ServoMotorHelper(servoMotor); + } + + @Get("/enable") + public void enableServoMotor() { + servoMotorHelper.enable(); + } + + @Get("/disable") + public void disableServoMotor() { + servoMotorHelper.disable(); + } + + @Get("/setAngle/{angle}") + public void setAngle(int angle) { + servoMotorHelper.setAngle(angle); + } +} +//end::ex[] diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/TiltSwitchController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/TiltSwitchController.java new file mode 100644 index 00000000..4a1847c8 --- /dev/null +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/TiltSwitchController.java @@ -0,0 +1,44 @@ +package com.opensourcewithslu.components.controllers; + +import com.opensourcewithslu.inputdevices.TiltSwitchHelper; +import com.opensourcewithslu.outputdevices.LEDHelper; +import com.pi4j.io.gpio.digital.DigitalInput; +import com.pi4j.io.gpio.digital.DigitalOutput; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Get; +import jakarta.inject.Named; + +//tag::ex[] +@Controller("/tiltSwitch") +public class TiltSwitchController { + + private final TiltSwitchHelper tiltSwitchHelper; // controls the tilt switch + private final LEDHelper ledHelper; // controls the LED + + public TiltSwitchController(@Named("tilt-switch-input")DigitalInput tiltSwitch, + @Named("led2")DigitalOutput led) { + this.tiltSwitchHelper = new TiltSwitchHelper(tiltSwitch); + this.ledHelper = new LEDHelper(led); + } + + // The 'enable' method adds an event listener that listens for changes in the tilt switch + // If it is tilted, the LED turns on and off otherwise + @Get("/enable") + public void enableTiltSwitch() { + tiltSwitchHelper.addEventListener(e -> { + if (tiltSwitchHelper.isTilted) { + ledHelper.ledOn(); + } + else { + ledHelper.ledOff(); + } + }); + } + + // The disable method removes the event listener + @Get("/disable") + public void disableTiltSwitch() { + tiltSwitchHelper.removeEventListener(); + } +} +//end::ex[] diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java index fe8b12ee..fa1b8d29 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java @@ -8,6 +8,7 @@ import io.micronaut.http.annotation.Get; import jakarta.inject.Named; +//tag::ex[] @Controller("/touchSwitch") public class TouchSwitchController { @@ -37,4 +38,5 @@ public void enableTouchSwitch() { public void disableTouchSwitch() { touchSwitchHelper.removeEventListener(); } -} \ No newline at end of file +} +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/UltraSonicSensorController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/UltraSonicSensorController.java index f0023096..664eed53 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/UltraSonicSensorController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/UltraSonicSensorController.java @@ -9,6 +9,7 @@ import jakarta.inject.Named; +//tag::ex[] @Controller("/ultraSound") public class UltraSonicSensorController { @@ -55,3 +56,4 @@ public String disableUltrasoundSensor() { return "Ultra Sonic Sensor Disabled"; } } +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java index 343f884f..4f27e147 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java @@ -11,6 +11,7 @@ /** * Controller for managing LCD1602 display operations via HTTP requests. */ +//tag::ex[] @Controller("/lcd") public class lcdController { private final LCD1602Helper lcdHelper; @@ -37,10 +38,10 @@ public String writeDataAtPos(@PathVariable String text, @PathVariable int line, return "Text written at line " + line + ", position " + pos + ": " + text + "\n"; } - @Get("/write/character/{charvalue}") - public String writeCharacter(@PathVariable char charvalue) { - lcdHelper.writeCharacter(charvalue); - return "Character '" + charvalue + "' written to LCD\n"; + @Get("/write/character/{charValue}") + public String writeCharacter(@PathVariable char charValue) { + lcdHelper.writeCharacter(charValue); + return "Character '" + charValue + "' written to LCD\n"; } @Get("/backlight/{state}") @@ -68,3 +69,4 @@ public String turnOff() { return "Display turned off\n"; } } +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java index 0e9e5e68..b8a912b3 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java @@ -1,7 +1,7 @@ package com.opensourcewithslu.components.controllers; import com.opensourcewithslu.outputdevices.RGBLEDHelper; -import com.opensourcewithslu.utilities.MultipinConfiguration; +import com.opensourcewithslu.utilities.MultiPinConfiguration; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; import jakarta.inject.Named; @@ -11,7 +11,7 @@ public class rgbController { private final RGBLEDHelper rgbledHelper; - public rgbController(@Named("rgb-led") MultipinConfiguration rgbLed){ + public rgbController(@Named("rgb-led") MultiPinConfiguration rgbLed){ this.rgbledHelper = new RGBLEDHelper(rgbLed); } diff --git a/components/src/main/resources/application.yml b/components/src/main/resources/application.yml index 59b97e31..4599e380 100644 --- a/components/src/main/resources/application.yml +++ b/components/src/main/resources/application.yml @@ -14,37 +14,23 @@ pi4j: # tag::pwm[] pwm: - red-pwm: # <1> - name: red # <2> - address: 17 # <3> - pwmType: SOFTWARE # <4> - provider: pigpio-pwm # <5> - initial: 0 # <6> - shutdown: 0 # <7> - blue-pwm: - name: blue - address: 18 - pwmType: SOFTWARE - provider: pigpio-pwm - initial: 0 - shutdown: 0 - green-pwm: - name: green - address: 27 - pwmType: SOFTWARE - provider: pigpio-pwm - initial: 0 - shutdown: 0 - active-buzzer: - name: active-buzzer + active-buzzer: # <1> + name: active-buzzer # <2> + address: 17 # <3> + pwmType: SOFTWARE # <4> + provider: pigpio-pwm # <5> + initial: 0 # <6> + shutdown: 0 # <7> + passive-buzzer: + name: passive-buzzer address: 17 pwmType: SOFTWARE provider: pigpio-pwm initial: 0 shutdown: 0 - passive-buzzer: - name: passive-buzzer - address: 17 + servo-motor: + name: Servo Motor + address: 18 pwmType: SOFTWARE provider: pigpio-pwm initial: 0 @@ -103,6 +89,12 @@ pi4j: pull: PULL_DOWN debounce: 200000 provider: pigpio-digital-input + micro-switch: + name: Micro Switch + address: 19 + pull: PULL_DOWN + debounce: 200000 + provider: pigpio-digital-input pir-sensor: name: PIR Sensor address: 13 @@ -115,6 +107,12 @@ pi4j: pull: PULL_DOWN debounce: 3000 provider: pigpio-digital-input + tilt-switch-input: + name: Tilt Switch Input + address: 17 + pull: PULL_DOWN + debounce: 5000 + provider: pigpio-digital-input # end::digitalInput[] # tag::digitalOutput[] @@ -165,7 +163,7 @@ pi4j: provider: pigpio-digital-input # end::multiInput[] - # tag::multipwm[] + # tag::multiPWM[] multi-pwm: rgb-led: # <.> name: RGB LED # <.> @@ -181,22 +179,5 @@ pi4j: provider: pigpio-pwm initials: 0, 0, 0 shutdowns: 0, 0, 0 - # end::multipwm[] - + # end::multiPWM[] -# clk: -# name: CLK Output -# address: 23 -# debounce: 500 -# pull: PULL_UP -# shutdown: LOW -# initial: HIGH -# provider: pigpio-digital-input -# dt: -# name: DT Output -# address: 24 -# debounce: 500 -# pull: PULL_UP -# shutdown: LOW -# initial: HIGH -# provider: pigpio-digital-input \ No newline at end of file diff --git a/pi4micronaut-utils/build.gradle b/pi4micronaut-utils/build.gradle index b2949049..47b6b259 100644 --- a/pi4micronaut-utils/build.gradle +++ b/pi4micronaut-utils/build.gradle @@ -7,7 +7,7 @@ plugins { } group = 'io.github.oss-slu' -version = 'v1.0' +version = 'v1.1' apply plugin: 'maven-publish' apply plugin: 'signing' @@ -35,7 +35,6 @@ java { targetCompatibility = JavaVersion.toVersion("17") } - tasks.named('build').configure { dependsOn 'javadoc' copy { @@ -94,7 +93,7 @@ publishing { mavenJava(MavenPublication) { groupId = 'io.github.oss-slu' artifactId = 'pi4micronaut-utils' - version = 'v1.0' + version = 'v1.1' from components.java artifact sourcesJar diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc index 6ec99014..7f456381 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc @@ -74,6 +74,25 @@ Finally, install pigpio sudo apt-get install pigpio ---- +==== Enabling Different Communication Protocols +. In the Pi4Micronaut library, we have used different communication protocols, such as I2C, SPI, etc. +. To enable any of these protocols when needed, enter the following command: ++ +[source, bash] +---- +sudo raspi-config +---- ++ +. Navigate to "*Interfacing Options*" ++ +image::commProtocol1.png[] ++ +. Choose your desired protocol. ++ +image::commProtocol2.png[] ++ +. Reboot when prompted. + ==== Build and Copy Over Jar File . Open your terminal of choice . Navigate to the project root directory @@ -104,7 +123,7 @@ scp Demo_Pi4Micronaut-0.1-all.jar test@raspberrypi-test:~ + image:Copying_Jar_File_To_Pi.png[] -==== Almost Done! +==== Run Jar file on Pi and Test the Application . To test if you've set up everything correctly on your raspberry pi, we have some sample commands for you to run. . Open a new terminal and ssh into your raspberry pi. . Enter the following command to run the jar file: @@ -133,21 +152,3 @@ curl http://localhost:8080/led/ledOn . If this command works and the LED has lit up, congratulations! You have successfully built and ran one of our components! -==== Enabling Different Communication Protocols -. In the Pi4Micronaut library, we have used different communication protocols, such as I2C, SPI, etc. -. To enable any of these protocols when needed, enter the following command: -+ -[source, bash] ----- -sudo raspi-config ----- -+ -. Navigate to "*Interfacing Options*" -+ -image::commProtocol1.png[] -+ -. Choose your desired protocol -+ -image::commProtocol2.png[] -+ -. Reboot when prompted to diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc index 5e8dcefa..66714664 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc @@ -1,9 +1,15 @@ === Example Applications [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc[Improve this doc] If you're curious about what Pi4Micronaut is capable of, check out some of the working applications created using our library. -==== Remote Mointoring Check-In System +==== Remote Monitoring Check-In System https://github.com/oss-slu/SLU_OSS_CheckIn + +==== Home Automation +https://github.com/oss-slu/Pi4Micronaut/tree/Home_Automation + +==== Lab Automation +https://github.com/oss-slu/Pi4Micronaut/tree/Lab_Automation diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/howToUsePi4Micronaut.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/howToUsePi4Micronaut.adoc index 0b5c61cf..cf38cff2 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/howToUsePi4Micronaut.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/howToUsePi4Micronaut.adoc @@ -30,7 +30,7 @@ image:Using_Micronaut.png[] + [source, gradle] ---- -implementation("io.github.oss-slu:pi4micronaut-utils:v1.0:all") +implementation("io.github.oss-slu:pi4micronaut-utils:v1.1:all") ---- + It should look like: diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc index e2f51f88..188171f6 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc @@ -1,6 +1,6 @@ == Currently Supported Hardware [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc[Improve this doc] If you plan on creating an application using any of the hardware components listed below, then our library is perfect for you! @@ -13,9 +13,12 @@ We plan on offering support for many more hardware components in the future. If * LED * RGB LED * LCD Screen -* Photosensor +* Photo Sensor * Touch Switch Sensor * Active Buzzer * Passive Buzzer * PIR Motion Sensor -* Ultrasonic Sensor \ No newline at end of file +* Ultrasonic Sensor +* Servo Motor +* Tilt Switch +* Micro Switch \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/adding_creating_App.adoc b/pi4micronaut-utils/src/docs/asciidoc/adding_creating_App.adoc deleted file mode 100644 index 75f3e049..00000000 --- a/pi4micronaut-utils/src/docs/asciidoc/adding_creating_App.adoc +++ /dev/null @@ -1,7 +0,0 @@ - -== Adding to/Creating an Application -[.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/adding_creating_App.adoc[Improve this doc] - -TODO: outline how to create a basic applicaton like we did for the start of the check-in system + -TODO: outline how someone should add our jar to their exsisting application \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components.adoc b/pi4micronaut-utils/src/docs/asciidoc/components.adoc deleted file mode 100644 index d0eb206f..00000000 --- a/pi4micronaut-utils/src/docs/asciidoc/components.adoc +++ /dev/null @@ -1,4 +0,0 @@ -== Components -[.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components.adoc[Improve this doc] - diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware.adoc index a59223e6..9a91128d 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware.adoc @@ -1,6 +1,34 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + === Communicating with a Hardware Component [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware.adoc[Improve this doc] + +Interacting with a hardware component is done through its communication type which determines +its circuit setup and configuration. + +For example, the LCD1602 component uses an I2C communication type +which determines how the circuit is created by utilizing the I2C pins of the GPIO. + +Based on the pins and communication type, you have to define the configuration in the yml file accordingly. +If a user wants to implement multiple hardware components then the configuration should be defined in the snake yml structure. + +==== YAML Configuration Workflow + +- The specifications in the yml file are given to the component in the controller through the use of the @Named() annotation. +- The controller passes on the configuration to the helper through the object. +- The communication types are initialized in the Pi4JFactory and Pi4JMultiPinFactory as beans with specifications as listed in the yml file. +- The communication type configuration classes are in our utilities folder which define the methods and attributes which are used in the factory classes + to apply the specifics listed in the yml file. +- The factory classes create a context with all the beans which can be used by the different hardware components. +- When the JAR file is ran on the RaspberryPi, the beans interact with the pigpio library to communicate with the GPIO pins. -TODO: outline the use and access of application.yaml for an app + -TODO: Consolidate the format and include examples of how each comm type is used \ No newline at end of file +image:Config_Workflow.png[] \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc index 9d405ca8..1f46b6f6 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc @@ -1,17 +1,21 @@ ==== Digital Input [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc[Improve this doc] + +"Digital Input" refers to a type of electronic signal or data that can be read by the Raspberry Pi's GPIO pins. These signals are binary, meaning they can only be in one of two states: HIGH (1) or LOW (0). + +To define in application.yaml add digital-input as a field under Pi4J, then add each component under digital-input. -To define in application.yaml add digital-input as a field under pi4j, then add each component under digital-input Each component will need * name: Name of the component * address: GPIO pin associated with component -* debounce: +* debounce: value that determines the threshold for noise from the component * pull: Either PULL_UP or PULL_DOWN depending on component * provider: pigpio-digital-input +.Example Digital Input declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=digitalInput] diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc index fb9bc074..baa15cb2 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc @@ -1,8 +1,13 @@ ==== Digital Output [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc[Improve this doc] + +"Digital Output" refers to a signal sent from the Raspberry Pi's GPIO pins to another device or circuit. Unlike digital input, which the Raspberry Pi reads, digital output is a signal that the Raspberry Pi sends out. + +Digital outputs are also binary, meaning they can only have two states: HIGH (1) or LOW (0). These states correspond to different voltage levels, typically 3.3V for high and 0V (ground) for low on a Raspberry Pi. + +To define in application.yaml, add digital-output as a field under Pi4J, then add each component under digital-output. -To define in application.yaml add digital-output as a field under pi4j, then add each component under digital-input Each component will need * name: Name of the component @@ -11,6 +16,7 @@ Each component will need * shutdown: State to take when program successfully shuts down properly, either LOW or HIGH * provider: pigpio-digital-output +.Example Digital Output declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=digitalOutput] diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc index 04e89968..0cee2b51 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc @@ -1,7 +1,26 @@ ==== I2C [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc[Improve this doc] +I2C stands for **Inter-Integrated Circuit**. It is a bus interface connection protocol incorporated into devices for serial communication. (https://geeksforgeeks.org/i2c-communication-protocol/[Source: geeksforgeeks.com]) +The I2C protocol uses two wires: SDA (serial data) and SCL (serial clock). This protocol allows for communication between +multiple devices using only two wires and unique addresses. + +The I2C LCD1602 consists of a normal LCD1602 and an I2C module that is attached to the back of the LCD. +The I2C module is a chip that can expand the I/O ports of the LCD1602 using the I2C protocol. +It converts the signals from the Raspberry Pi into commands for the LCD. + +(https://docs.sunfounder.com/projects/umsk/en/latest/01_components_basic/26-component_i2c_lcd1602.html[Source: docs.sunfounder.com]) + +To define in application.yaml add i2c as a field under pi4j, then add each component under i2c. + +Each component will need: + +* name: Name of the component +* bus: Bus address of device +* device: Address of device + +.Example I2C declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=i2c] @@ -11,4 +30,3 @@ include::../../../../../../components/src/main/resources/application.yml[tags=i2 <3> Device bus (0 or 1) <4> Device address -TODO: add I2C information \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc index d85367eb..ef7cd1b9 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc @@ -1,32 +1,32 @@ -==== Multipin Configurations +==== MultiPin Configurations [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc[Improve this doc] -Multipin components are unique in that they require several of the same type of pin in order to function properly. -Each class of multipin component (Digital Input, PWM), is declared slightly differently in the application.yaml file +MultiPin components are unique in that they require several of the same type of pin in order to function properly. +Each class of multi-pin component (Digital Input, PWM), is declared slightly differently in the application.yaml file -.Example Multipin Digital Input declaration +.Example MultiPin Digital Input declaration [source, yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=multiInput] ---- -<.> Top level field for multipin digital inputs (equivlent of digital-output declaration) +<.> Top level field for multi-pin digital inputs (equivalent of digital-output declaration) <.> Component Identifier (Used in @Named annotations) <.> Component Name <.> Addresses for each pin (Each component has a specific order outlined in the component description) <.> Debounce values for each pin (same order as above) <.> Pull values for each pin (same order as above) <.> Shutdown value (All pins have the same shut down) -<.> Startup value (All pins have the same start up) +<.> Startup value (All pins have the same start-up) <.> Provider (All pins have the same provider) -.Example Multipin PWM declaration +.Example MultiPin PWM declaration [source, yaml] ---- -include::../../../../../../components/src/main/resources/application.yml[tags=multipwm] +include::../../../../../../components/src/main/resources/application.yml[tags=multiPWM] ---- -<.> Top level field for multipin PWMs (equivlent of digital-output declaration) +<.> Top level field for multi-pin PWMs <.> Component Identifier (Used in @Named annotations) <.> Component Name <.> Addresses for each pin (Each component has a specific order outlined in the component description) diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc index a2652930..910c00a3 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc @@ -1,15 +1,24 @@ ==== PWM [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc[Improve this doc] -To define in application.yaml add digital-input as a field under pi4j, then add each component under digital-input -Each component will need +Pulse width modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. +This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. +The duration of “on time” is called the pulse width. To get varying analog values, you change, or modulate, that pulse width (https://learn.sunfounder.com/lesson-2-controlling-led-by-pwm-3/[Source: sunfounder.com]). +In our library, our Active Buzzer component uses PWM. Once fully activated at 5 Volts, the buzzer will go off, creating a tone. + +To define in application.yaml add pwm as a field under pi4j, then add each component under pwm. + +Each component will need: * name: Name of the component * address: GPIO pin associated with component * pwmType: Either SOFTWARE or HARDWARE based upon which type of PWM you wish to use * provider: pigpio-pwm +* initial: Initial value on startup +* shutdown: Final value at shut down +.Example PWM declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=pwm] diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc index 41fb4d14..25cebf75 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc @@ -1,9 +1,43 @@ ==== SPI - [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc[Improve this doc] + +The Serial Peripheral Interface (SPI) is a communication protocol used to transfer data between the Raspberry Pi and peripheral devices. These peripheral devices may be either sensors or actuators. + +(https://raspberrypi-aa.github.io/session3/spi.html[Source: raspberrypi-aa.github.io]) + +Many different devices use the SPI protocol, such as SD card reader modules, RFID card reader modules, and 2.4 GHz wireless transmitter/receivers all use SPI to communicate with the Raspberry Pi. + +(https://www.circuitbasics.com/basics-of-the-spi-communication-protocol/[Source: circuitbasics.com]) + + +SPI uses 4 separate connections to communicate with the target device: + +- COPI (Controller Output/Peripheral Input) – Line for the Controller to send data to the Peripherals. + +- CIPO (Controller Input/Peripheral Output) – Line for the Peripherals to send data to the Controller. + +- SCLK (Clock) – Line for the clock signal. + +- PS/CS (Peripheral Select/Chip Select) – Line for the Controller to select which Peripheral to send data to. + + +==== +*Note:* Controller/Peripheral is formerly referred to as Master/Slave. In order to move away from the use of such terminology, we have opted to use the term Controller in place of Master, and Peripheral in place of Slave. +==== + + +To define in application.yaml add spi as a field under pi4j, then add each component under spi. + +Each component will need: + +* name: Name of the component +* address: Address for Controller/Peripheral +* baud: Baud rate/data rate +* reset-pin: Address of GPIO reset pin +.Example SPI declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=spi] @@ -14,4 +48,3 @@ include::../../../../../../components/src/main/resources/application.yml[tags=sp <4> Baud rate <5> Address of GPIO Reset pin -TODO: add SPI information \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc index 4d54242b..016b6a9c 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc @@ -1,3 +1,5 @@ === Input Components [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc[Improve this doc] + +The Components that provide input signal or data to the application from Raspberry Pi GPIO pins. \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/microSwitch.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/microSwitch.adoc new file mode 100644 index 00000000..55aa1321 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/microSwitch.adoc @@ -0,0 +1,131 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + +==== Micro Switch + +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/microSwitch.adoc[Improve this doc] + +===== Overview + +This section provides details of a Micro Switch implementation, including its circuit diagram, schematic diagram, +required hardware components, assembly instructions, and functionality. + +===== Components + +. 1 x Micro switch +. 2 x LEDs of different colors +. 2 x 220Ω resistor +. 1 x 10kΩ resistor +. 1 x 104 Capacitor +. Breadboard +. Jumper wires + +===== Assembly Instructions + +. Place the micro switch on the breadboard. Connect the common terminal 'C' to GPIO17. +. Connect the common terminal 'C' terminal of the micro switch to the ground via a 10KΩ resistor. +. Place the 0.1 µF capacitor (104) across the switch terminals directly on the breadboard. Connect one side to the GPIO17 where the switch connects and the other side to the ground via the other end of 10KΩ resistor which was connected to micro switch's 'C' terminal. This capacitor serves as a debouncing element, smoothing out any electrical noise caused by the physical action of the switch. +. Connect the Normally Open 'NO' terminal of the micro switch to the ground (GND). This resistor acts as a pull-down, ensuring the switch input reads LOW when not pressed. +. Connect the Normally Closed 'NC' terminal directly to the +3.3V power supply. This means when the switch is not pressed, the GPIO pin will be held HIGH through this connection. +. Insert the two LEDs onto the breadboard, ensuring the longer leg (anode) is towards the positive supply and the shorter leg (cathode) towards the ground. +. Connect a 220Ω resistor to the anode of each LED and the other end of these resistors to a positive voltage supply (+3.3V). +. Connect the cathodes of the LEDs. GPIO22 for LED1 and GPIO27 for LED2. +. Connect the positive voltage supply (+3.3V) to the positive rail of the breadboard and link the ground (GND) to the negative rail. Ensure all ground connections of the components are tied to this rail. + +See the circuit diagram below for more detail. + +===== Circuit Diagram + +image:microSwitch_CD.png[] + +*Schematic Diagram:* + +image:microSwitch_SD.png[] + +===== Functionality + +A Micro Switch is a small, very sensitive switch that requires minimum compression to activate. Because they are reliable and sensitive, micro switches are often used as a safety device. When the micro switch in your circuit is pressed, it breaks the connection between the Common 'C' terminal and the Normally Closed 'NC' terminal, which is linked to +3.3V, and instead makes a connection between the Common terminal and the Normally Open 'NO' terminal, connected to ground through a 10KΩ pull-down resistor. This change pulls the GPIO17 pin to a LOW state. Assuming your microcontroller is programmed accordingly, this action can be used to trigger specific behaviors, such as turning on an LED connected to another GPIO pin. This setup utilizes the micro switch to easily control electronic components through simple physical interaction. + +===== Testing the Circuit + +Use the below commands to test the micro switch. + +* `/enable` - turns on micro switch +[source, bash] +---- +$ curl http://localhost:8080/microSwitch/enable +---- + +* `/disable` - turns off micro switch +[source, bash] +---- +$ curl http://localhost:8080/microSwitch/disable +---- + +===== Troubleshooting + +- LEDs do not light up once it has been enabled and the micro switch is pressed: +. Make sure that the correct GPIO pins are being used for the LEDs and Micro Switch as specified in the yml. +. Confirm that everything is properly secured to the breadboard and is receiving power. +. Ensure that the micro switch and all resistors are correctly placed according to the schematic. +. Look for any unintended short circuits on the breadboard, particularly around the areas where the switch and LEDs are connected. +. Ensure that the capacitor (0.1 µF) is properly placed across the correct terminals of the micro switch +. Ensure a 220Ω is being used for the LEDs and 10kΩ resistor for the Micro Switch. + +===== YAML Configuration + +The YAML configuration for the LEDs is as follows: + +[source, yaml] +---- +digital-output: + led1: + name: LED Output + address: 22 + shutdown: HIGH + initial: HIGH + provider: pigpio-digital-output + + led2: + name: LED Output + address: 27 + shutdown: HIGH + initial: HIGH + provider: pigpio-digital-output +---- +So, the output of the LEDs is connected to GPIO 22 and GPIO 27 respectively. + +The YAML configuration for the micro switch is as follows: + +[source, yaml] +---- + micro-switch: + name: Micro Switch + address: 17 + pull: PULL_DOWN + debounce: 200000 + provider: pigpio-digital-input +---- +So, the input of the micro switch is connected to GPIO 17. + +===== Constructor and Methods + +To see the constructor and methods of our MicroSwitchHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/MicroSwitchHelper.html[here] +for more details. + +===== An Example Controller + +====== This controller uses the micro switch to light up LED2 once it is pressed and LED1 if it is not pressed. + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/MicroSwitchController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photoresistorSensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photoresistorSensor.adoc new file mode 100644 index 00000000..cc1640e6 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photoresistorSensor.adoc @@ -0,0 +1,132 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + + + +==== PhotoResistor Sensor +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photoresistorSensor.adoc[Improve this doc] + + +===== Overview +This section provides the details of the PhotoResistor Sensor including its components, assembly instructions, and functionality. + +===== Components +* 1 x RaspberryPi +* 1 x Breadboard +* 1 x LED +* 1 x PhotoResistor Sensor +* 1 x 220Ω Resistor +* 1 x Capacitor (10µf) +* 2 x 10KΩ Resistor +* 4 Jumper Wires +* Power source + + +===== Assembly Instructions +* Place the PhotoResistor onto the breadboard. +* Place the LED onto the breadboard with the Cathode pin in the negative side of the breadboard. The Anode pin will be placed onto the main section of the breadboard. +* Place a 220Ω resistor next to the anode pin of the LED, then place the other pin in line on the main section of the breadboard. +* Place one side of the Capacitor onto the negative side of the breadboard. +* Place the other side of the Capacitor into the breadboard inline with a jumper wire and a 10KΩ Resistor. +* Place the PhotoResistor Sensor onto the breadboard inline with the Capacitor, 10KΩ Resistor. The PhotoResistor should have a 10KΩ pin on either side of its' pins. +* The 10KΩ resistor pin should then be placed in line away from the PhotoResistor pins. +* Place a jumper wire from GND pin to the negative side of the board. +* Place a jumper wire from GPIO4 next to the positive pin of the Capacitor and the 10KΩ Resistor. +* Place a jumper wire from GPIO17 and place it next to the 220Ω Resistor +* Place a jumper wire from GPIO27 to the pin of the 10KΩ. + +===== Circuit Diagram + +image::photoResistor-CD.png[] + +===== Functionality +PhotoResistor is a DigitalInput and DigitalOutput type that controls the LED's behavior based on changes in light intensity. + + +===== Testing +Use the below command to test the component. + +[source, bash] +---- +$curl http://localhost:8080/photoResistor/enable +---- + +* `/enable` - Initializes the PhotoResistor + +[source, bash] +---- +$curl http://localhost:8080/photoResistor/getDarkness +---- + +* `/getDarkness` - returns the darkness level + +[source, bash] +---- +$curl http://localhost:8080/photoResistor/disable +---- + +* `/disable` - Disables the photoresistor + +[source, bash] +---- +$curl http://localhost:8080/photoResistor/threshold/i +---- + +* `/threshold/{i}` - Sets the threshold for the darkness. + +===== Troubleshooting +LED not lighting: + +* Verify that the appropriate resistors are being used (220Ω) +* Double check the power source + +PhotoResistor not working: + +* Ensure that the darkness level is appropriately set +* Verify the PhotoResistor is correctly placed into the breadboard +* Verify the correct resistor is used (10KΩ) + +===== YAML Configuration +The PhotoResistor as it appears in the YAML file: + +[source, yaml] +---- + digital-input: + photo-resistor-input: # <.> + name: Photo Resistor Input # <.> + address: 4 # <.> + debounce: 100000 # <.> + pull: PULL_DOWN # <.> + provider: pigpio-digital-input # <.> + + digital-output: + photo-resistor-output: + name: Photo Resistor Output + address: 27 + shutdown: LOW + initial: HIGH + provider: pigpio-digital-output + +---- + + +===== Constructor and Methods +To see the constructor and methods of the PhotoResistorHelper class see our java doc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/PhotoResistorHelper.html[here] for more details. + + +===== Example Controller + +====== This controller sets up the photoresistor sensor + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/PhotoResistorController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc index 6772abe5..3ee51ea5 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc @@ -1,5 +1,5 @@ ==== Photosensor [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc[Improve this doc] TODO: add in photosensor support docs \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc new file mode 100644 index 00000000..0973e162 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc @@ -0,0 +1,87 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + +==== PIR Sensor +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc[Improve this doc] + + +===== Overview + +This section provides details of the PIR Sensor, including the components and assembly instructions. A Passive Infrared Sensor measures infrared light radiating from objects to detect motion. + +===== Components + +* PIR Sensor +* Breadboard +* T-Extension Board +* Jumper wires x 3 +* Power source (5V) +* 3 x 220Ω resistors +* RGB LED + +===== Assembly Instructions +When looking at the bottom of PIR, the pins from left to right are: + +. Power: connect the left pin on the PIR to 5V0 on the breadboard +. I/O: connect the middle pin on the PIR to GPIO 13 on the breadboard +. Ground: connect right pin on the PIR to GND on the breadboard +. Set up the RGB LED + +===== Circuit Diagram + +image::PIR_Sensor_Circuit.png[] + + +===== Functionality + +A PIR - Passive Infrared sensor detects motion by sensing changes in the infrared light emitted by objects in its environment. It works passively, meaning it does not emit any infrared light itself, but rather detects the infrared radiation coming from warm objects, such as humans or animals. The sensor has two sensitive slots that detect infrared radiation. + +As a warm object moves across its field of view, the amount of infrared radiation reaching each slot changes, creating a detectable change in the radiation pattern. This change triggers the sensor to send an electrical signal, which can then be used to activate alarms, lights, or other devices, making PIR sensors widely used in security systems and automated lighting controls due to their efficiency and effectiveness in detecting motion. + +===== Testing +Use the below command to enable the sensor. +[source, bash] +---- +$ curl http://localhost:8080/pirSensor/enable +---- +Once the sensor is enabled, anytime the sensor detects motion, the RGB LED will turn red. If no motion is detected, the RGB LED will be green. + +Use the below command to disable the sensor. +[source, bash] +---- +$ curl http://localhost:8080/pirSensor/disable +---- + +===== Troubleshooting +- Sensor not detecting something: + * Make sure the object is moving. The sensor only detects movement. Once an object stops moving, it is no longer detected. + + +===== YAML Configuration +[source, yaml] +---- +digital-input: + pir-sensor: + name: PIR Sensor + address: 13 + pull: PULL_DOWN + debounce: 30000 + provider: pigpio-digital-input +---- + +===== Constructor and Methods +The constructor and the methods within the PIRSensorHelper class can be seen in our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/PIRSensorHelper.html[here]. + +===== Example Controller + +====== This controller uses the PIR Sensor to turn an RGB LED red if motion is detected, green otherwise +[source, java] +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/PIRSensorController.java[tag=ex] \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc index 9b3fde2f..5c0ad5c4 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc @@ -1,6 +1,6 @@ ==== Push Button [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc[Improve this doc] ===== Overview This document provides details of the Push Button circuit, @@ -16,20 +16,26 @@ including its components, assembly instructions, and functionality. . Power source ===== Circuit Diagram -Model: - -* Note the 220Ω resistor is for the LED and the 10Ω for the button. image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image152.png[] +.*Note:* The 220Ω resistor is for the LED and the 10Ω for the button. - -Circuit Diagram: +*Schematic Diagram:* image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image303.png[] ===== Functionality -A push of the button turns the LED light on and another push turns it off. +On click of a button can either open or close the circuit based on its current state. + +===== Testing +Use below command to test the component. + +[source, bash] +---- +$ curl http://localhost:8080/pushButton/init +---- +* `/init` - Initializes the Push Button for use. ===== Troubleshooting . LED not lighting up: Check all connections, ensure the LED is placed correctly, @@ -37,14 +43,18 @@ and check the power source. . LED is too dim: The resistor value might be too high. Ensure you're using the correct resistors or adjust according to your power source and LED specifications -===== YAML Pin Order +===== YAML Configuration The order for declaring the pin for the LED is as follows: [source, yaml] ---- digital-output: led: + name: LED Output address: 17 + shutdown: LOW + initial: LOW + provider: pigpio-digital-output ---- So the LED would be connected to GPIO 17. @@ -53,24 +63,20 @@ The order for declaring the pin for the push button is as follows: [source, yaml] ---- digital-input: - button-input-3: - address: 18 + button-input-3: + name: Push Button Input + address: 18 + pull: PULL_DOWN + debounce: 30 + provider: pigpio-digital-input ---- So the push button would be connected to GPIO 18. -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/PushButtonHelper.java[tag=const] ----- +===== Constructor and Methods -===== Methods +To see the constructor and methods of our PushButtonHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/PushButtonHelper.html[here] +for more details. -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/PushButtonHelper.java[tags=method] ----- ===== An Example Controller @@ -79,4 +85,4 @@ include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithsl [source, java] ---- include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/PushButtonController.java[tag=ex] ----- \ No newline at end of file +---- diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc index 41788a47..3bda659c 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc @@ -10,12 +10,11 @@ endif::rootpath[] ==== RFID Scanner [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc[Improve this doc] ===== Overview This section provides information regarding the RFID scanner component and its circuit, including assembly instructions. - ===== Components * RFID-RC522 @@ -24,9 +23,6 @@ This section provides information regarding the RFID scanner component and its c * Breadboard * Power source (3.3V) - - - ===== Assembly Instructions * Put RFID scanner on breadboard as shown in the diagram below. @@ -35,31 +31,25 @@ This section provides information regarding the RFID scanner component and its c ===== Circuit Diagram -Model: image::rfid_circuit.png[] ===== Functionality -The two main functions of the RFID scanner are to read RFIDs and to write to them. What is written to the RFID will vary depending on the intended use for the scanner. - -===== Troubleshooting +RFID Scanner requires RFID tags to work with. We can read/write the data on to the tags using the scanner. -Make sure everything is connected to the correct pins. +* `/write/{value}` - Writes {value} to the RFID key fob +* `/read` - Scanner will be ready to read the key fob ===== Testing the Circuit: -To write to the RFID fob: `curl -X POST http://localhost:8080/rfid/write/{message}` - -Example: +To write to the RFID fob: [source] ---- $ curl -X POST http://localhost:8080/rfid/write/HelloThere ---- Scan the key fob to write the message to the fob. -To read from the RFID fob: `curl http://localhost:8080/rfid/read` - -Example: +To read from the RFID fob: [source] ---- $ curl http://localhost:8080/rfid/read @@ -70,25 +60,25 @@ Scan the key fob and the message on the fob will be printed. HelloThere ---- -===== YAML -The RFID scanner as it appears in the application.yml: - -include::../../../../../../components/src/main/resources/application.yml[tag=spi] - - -===== Constructors +===== Troubleshooting -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RFidHelper.java[tag=const] ----- +Make sure everything is connected to the correct pins. -===== Methods +===== YAML Configuration +The RFID scanner configuration as it appears in the application.yml: -[source, java] +[source] ---- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RFidHelper.java[tag=method] +spi: + rfid: + name: MFRC522 + address: 8 + baud: 500000 + reset-pin: 25 ---- +===== Constructors and Methods +To see the constructor and methods of our RFidHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/RFidHelper.html[here] +for more details. ===== An Example Controller @@ -96,5 +86,5 @@ include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithsl [source, java] ---- -include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/RFidController.java[tag=ex] ----- \ No newline at end of file +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/RfidController.java[tag=ex] +---- diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc index f1a7a446..3b441b1d 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc @@ -10,7 +10,7 @@ endif::rootpath[] ==== Rotary Encoder [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc[Improve this doc] ===== Overview This section provides details of the Rotary Encoder circuit, @@ -38,15 +38,12 @@ stated below and in the diagram. ===== Circuit Diagram -- Note the resistor location at GPIO 27 - image::rotary_encoder_circuit.png[] +*Note:* The resistor location at GPIO 27. + ===== Functionality -- The initial value returned is 0. -- Turning the shaft one unit clockwise will increase the value returned by 1, whereas, turning the - knob counterclockwise by one unit will decrease the value returned by 1. -- The value returned is an integer with a max value of 2147483647 and min of -2147483647. +The rotary encoder returns the value as you rotate the knob. ===== Testing the Circuit To return the value of the rotary encoder: @@ -56,12 +53,14 @@ To return the value of the rotary encoder: $ curl http://localhost:8080/rotaryEncoder/value ---- +* `/value` - returns the current value of the rotary encoder + ===== Troubleshooting - Value not being returned: Make sure all pins on the encoder match up to the correct GPIO pins according to the YAML pin order below. - Make sure that a 10k resistor is being used -===== YAML Pin Order +===== YAML Configuration The order for declaring pins for a Rotary Encoder component in the application.yaml file is as follows *SW-PIN-INFO, CLK-PIN-INFO, DT-PIN-INFO* @@ -71,31 +70,27 @@ So in the case of [source, yaml] ---- multi-digital-input: - rot-encoder: - addresses: 17, 18, 27 + rotary-encoder: + name: Rotary Encoder + addresses: 27,18,17 + debounces: 6000,500,500 + pulls: PULL_DOWN,PULL_UP,PULL_UP + shutdown: LOW + initial: HIGH + provider: pigpio-digital-input ---- the sw pin would be the one connected to GPIO 27, the clk pin would be connected to GPIO 18, and the dt pin would connect to GPIO 17. All lists of values for Rotary Encoder components will follow the same order. -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RotaryEncoderHelper.java[tag=const] ----- - -===== Methods - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RotaryEncoderHelper.java[tags=method] ----- +===== Constructors and Methods +To see the constructor and methods of our RotaryEncoderHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/RotaryEncoderHelper.html[here] +for more details. ===== An Example Controller -====== This controller sets up two rotary encoders +====== This controller uses a rotary encoder [source, java] ---- include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/RotaryEncoderController.java[tag=ex] ----- +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc index f8455900..c936b648 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc @@ -13,7 +13,7 @@ endif::rootpath[] ==== Slide Switch [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc[Improve this doc] ===== Overview @@ -36,7 +36,6 @@ This section provides the details of the Slide Switch circuit, including its com 6. Connect the GPIO18 pin of the Pi to the middle pin of the slide switch so that the resistor and the connection to the capacitor are between. ===== Circuit Diagram -Model: image::slideSwitch_circuit.jpg[] @@ -45,17 +44,23 @@ Making a request to the switch will return whether the switch is on or off, flip ===== Testing the Circuit: -Use: `curl http://localhost:8080/slideSwitch/switch1` to test the switch. This will either return true,if the switch is on, and false if the switch is off. Flip the switch and run the command again to see the opposite result of the first call. +Use the below command to test the switch. +[source, bash] +---- +$ curl http://localhost:8080/slideSwitch/switch1 +---- +This will either return true,if the switch is on, and false if the switch is off. Flip the switch and run the command again to see the opposite result of the first call. ===== Troubleshooting Verify that all connections are correct and that the order of components in a row are correct. -===== YAML +===== YAML Configuration The slide switch as it appears in the application.yml: [source, yaml] ---- +digital-input: slide-switch-input: name: Slide Switch Input address: 18 @@ -71,21 +76,12 @@ The slide switch as it appears in the application.yml: provider: pigpio-digital-input ---- -Note that there are two slide switches, one that uses GPIO 18 and the other uses GPIO 22. - -===== Constructors - -[source, java] ----- -include::../../../../main/java/com/opensourcewithslu/inputDevices/SlideSwitchHelper.java[tag=const] ----- +*Note:* There are two slide switches, one that uses GPIO 18 and the other uses GPIO 22. -===== Methods +===== Constructors and Methods +To see the constructor and methods of our SlideSwitchHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/SlideSwitchHelper.html[here] +for more details. -[source, java] ----- -include::../../../../main/java/com/opensourcewithslu/inputDevices/SlideSwitchHelper.java[tags=method] ----- ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/tiltSwitch.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/tiltSwitch.adoc new file mode 100644 index 00000000..5c6278b0 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/tiltSwitch.adoc @@ -0,0 +1,121 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + +==== Tilt Switch + +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/tiltSwitch.adoc[Improve this doc] + +===== Overview + +This section provides details of a tilt switch implementation, including its circuit diagram, +required hardware components, assembly instructions, and functionality. + +===== Components + +. Tilt switch module +. LED light +. 1 x 220Ω resistor +. 1 x 1kΩ resistor +. Breadboard +. Jumper wires +. Power source + +===== Assembly Instructions + +. Ground: Place the ground so that it is connected to the tilt switch and the LED +. Power: Place the power (3.3V) so that power is given to both the LED and tilt switch +. Resistor (220Ω): Place the 220Ω resistor vertically so that it can connect the LED light to power +. Resistor (1kΩ): Place the 1kΩ resistor vertically so that it can provide power to the tilt switch +. Connect a wire from GPIO26 to the LED which is its digital output +. Attach a wire from GPIO17 to the tilt switch which is its digital input + +See the circuit diagram below for more detail. + +===== Circuit Diagram + +image:tiltSwitch_CD.png[] + +*Schematic Diagram:* + +image:tiltSwitch_SD.png[] + +===== Functionality + +When the tilt switch is tilted or its orientation is changed, a metal ball moves inside the capsule +and opens or closes an electrical circuit, altering the state of the switch. +Our example showcases a tilt switch and LED which lights up when the tilt switch is enabled and detects a change in orientation. + +===== Testing the Circuit + +Use the below commands to test the tilt switch. + +* `/enable` - turns on tilt switch +[source, bash] +---- +$ curl http://localhost:8080/tiltSwitch/enable +---- + +* `/disable` - turns off tilt switch +[source, bash] +---- +$ curl http://localhost:8080/tiltSwitch/disable +---- + +===== Troubleshooting + +- LED not lighting up once it has been enabled and is being tilted: +. Make sure that the correct GPIO pins are being used for the LED and Tilt Switch as specified in the yml. +. Confirm that everything is properly secured to the breadboard and is receiving power. +. Ensure a 220Ω is being used for the LED and 1kΩ resistor for the Tilt Switch. + +===== YAML Configuration + +The YAML configuration for the LED is as follows: + +[source, yaml] +---- +digital-output: + led2: + name: LED Output + address: 26 + shutdown: HIGH + initial: HIGH + provider: pigpio-digital-output +---- +So, the output of the LED is connected to GPIO 26. + +The YAML configuration for the tilt switch is as follows: + +[source, yaml] +---- +digital-input: + tilt-switch-input: + name: Tilt Switch Input + address: 17 + pull: PULL_DOWN + debounce: 5000 + provider: pigpio-digital-input +---- +So, the input of the tilt switch is connected to GPIO 17. + +===== Constructor and Methods + +To see the constructor and methods of our TiltSwitchHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/TiltSwitchHelper.html[here] +for more details. + +===== An Example Controller + +====== This controller uses the tilt switch to light up a LED light once it is tilted + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/TiltSwitchController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc new file mode 100644 index 00000000..873ce721 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc @@ -0,0 +1,122 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + +==== Touch Switch + +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc[Improve this doc] + +===== Overview + +This section provides details of a touch switch sensor implementation, +including its circuit diagram, required hardware components, +assembly instructions, and functionality. + +===== Components + +. Touch switch module +. LED light +. 1 x 220Ω resistor +. Breadboard +. Jumper wires +. Power source + +===== Assembly Instructions + +Connect the 3 pins on the touch switch to the breadboard as well as the LED and resistor +making sure the LED has power. + +. Ground: connect the ground on the touch switch to the ground on the breadboard +. Power: Connect the VCC on the touch switch to the 3.3V on the breadboard +.. You will want to have a wire connecting 3.3V and ground to the bottom of the board +so that power can be supplied to the LED and touch switch as shown in the diagram below +. IO: Connect the IO on the touch switch to GPIO 17 on the breadboard which is the digital input +. Resistor: Place the resistor vertically so that it can connect the LED light to power +. Connect a wire from GPIO26 to the LED which is its digital output + +===== Circuit Diagram + + +image:touchSwitchDiagram.png[] + +*Schematic Diagram:* + +image:touchSwitch.png[] + +===== Functionality + +We can either open or close a circuit using touch switch when you touch it. + +===== Testing the Circuit + +Use the below commands to test the touch switch. + +* `/enable` - turns on touch switch +[source, bash] +---- +$ curl http://localhost:8080/touchSwitch/enable +---- + +* `/disable` - turns off touch switch +[source, bash] +---- +$ curl http://localhost:8080/touchSwitch/disable +---- + +===== Troubleshooting + +- LED not lighting up once it has been enabled and is being touched: +Make sure that all the pins on the touch switch are in the right spot and that everything is receiving power. +Also make sure that everything is properly secured to the breadboard. +- Ensure a 220Ω resistor is being used + +===== YAML Configuration + +The YAML configuration for the LED is as follows: + +[source, yaml] +---- +digital-output: + led2: + name: LED Output + address: 26 + shutdown: HIGH + initial: HIGH + provider: pigpio-digital-output +---- +So, the output of the LED is connected to GPIO 26. + +The YAML configuration for the touch switch is as follows: + +[source, yaml] +---- +digital-input: + touch-switch-input: + name: Touch Switch Input + address: 17 + pull: PULL_DOWN + debounce: 200000 + provider: pigpio-digital-input +---- +So, the input of the touch switch is connected to GPIO 17. + +===== Constructor and Methods + +To see the constructor and methods of our TouchSwitchHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/TouchSwitchHelper.html[here] +for more details. + +===== An Example Controller + +====== This controller uses the touch switch to light up a LED light once touched + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc new file mode 100644 index 00000000..7f483a68 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc @@ -0,0 +1,96 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + + +==== Ultrasonic Sensor +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc[Improve this doc] + +===== Overview +This document provides details of the Ultrasonic Sensor circuit, +including its components, assembly instructions, and functionality. + +===== Components +. HC SR04 +. T-Extension Board +. Breadboard +. Jumper wires +. Power source + +===== Circuit Diagram + +image::ultrasonic_sensor_model.png[] + +*Schematic Diagram:* + +image::ultrasonic_sensor_circuit.png[] + +===== Functionality +The Ultrasonic Sensor uses sound waves to calculate the distance from itself to the surface it is pointed at. +The resulting measurement is accurate within a range of 3mm of the true measurement. +The Ultrasonic Sensor's signal is stable within 5m of the sensor, gradually weakening until the signal fully disappears at 7m. + +===== Testing + +Use the below commands to test the component. + +[source, bash] +---- +$curl http://localhost:8080/ultraSound/enable +---- + +* `/enable` - turns on ultrasonic sensor, starts measuring distance +* `/distance/cm` - returns distance to nearest object in centimeters +* `/distance/m` - returns distance to nearest object in meters +* `/disable` - turns off ultrasonic sensor + + + +===== Troubleshooting +. Distance measurements not showing: Check all connections, ensure the sensor is placed correctly, +and check the power source. + +===== YAML Configuration +The order for declaring the Trigger and Echo Pins of the Ultrasonic Sensor is as follows: + +So the Trigger Pin would be connected to GPIO 23 and the Echo Pin would be connected to GPIO 24. + +[source, yaml] +---- +digital-input: + ultra-sonic-echo: + name: UltraSonic Sensor Input + address: 24 + pull: PULL_DOWN + debounce: 3000 + provider: pigpio-digital-input + +digital-output: + ultra-sonic-trig: + name: UltraSonic Sensor Output + address: 23 + shutdown: LOW + initial: LOW + provider: pigpio-digital-output +---- + +===== Constructor and Methods + +To see the constructor and methods of our UltraSonicSensor class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/UltraSonicSensorHelper.html[here] +for more details. + +===== An Example Controller + +====== This controller uses the Ultrasonic Sensor to calculate distance from the sensor to a surface + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/UltraSonicSensorController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc index 1f7233be..2aa6278c 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc @@ -1,4 +1,6 @@ === Output Components [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc[Improve this doc] + +The Components that provide output signal either by emitting, displaying, lighting, etc. through Raspberry Pi GPIO pins. \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc new file mode 100644 index 00000000..a6993fae --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc @@ -0,0 +1,119 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + + +==== Active Buzzer + +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc[Improve this doc] + +===== Overview +This section provides details of the Active Buzzer, including the components and assembly instructions. The Active Buzzer only emits one frequency, as described in the code, to play various sounds. + +===== Components +* 1 x RaspberryPi +* 1 x Breadboard +* 1 x T-extension Board +* 1 x Active Buzzer +* 6 x Jumper wires +* 1 x Resistor (1KΩ) +* 1 x S8550 PNP Transistor +* Power source (appropriate voltage, typically 3.3V) + +===== Assembly Instructions +* Place the Active Buzzer onto the Breadboard. +* Place the 1KΩ resistor onto the Breadboard, must be inline with base pin of S8550 PNP Transistor. +* Place the S8550 PNP Transistor onto the BreadBoard. +* The Active Buzzer will have two pins. The longer pin is the anode (+) while the shorter is the cathode(-). +* Connect a jumper wire from GND to (-) negative side +* Connect a jumper wire from 3.3V to (+) positive side. +* Connect a jumper wire from GPIO 17 to the 1KΩ resistor +* Connect jumper wire from positive side to positive end of Active Buzzer. +* Connect jumper wire from negative end of Active Buzzer to emitter pin of S8550 PNP Transistor. +* Connect jumper wire from negative side to collector pin of S8550 PNP Transistor. + +===== Circuit Diagram + +image::active_buzzer-CD.png[] + +*Schematic Diagram* + +image::buzzer-SD.png[] + +===== Functionality +Active Buzzer is PWM type and emits a beep tone, intermittent tone and a morseCode tone based on the frequency and the time interval. + +*Note:* If you use transistor in the circuit, it swaps the functionalities of the buzzer i.e., if you enable the buzzer, it actually disables it and vice versa. + +===== Testing the circuit +Use the below command to test the component. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/enable +---- + +* `/enable` - Turns the Active Buzzer on. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/disable +---- +* `/disable` - Turns the Active Buzzer off. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/beepTone +---- +* `/beepTone` - Emits a beep sound from the Active Buzzer. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/intermittentTone +---- +* `/intermittentTone` - Emits an intermittent tone from the Active Buzzer. The total duration is twenty seconds: ten seconds of sound and ten seconds of silence. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/morseCode +---- +* `/morseCode` - Emits the word "pi" in morse code. + + +===== Troubleshooting +- Active Buzzer not creating sound: + * Double check power source + * Verify that 1K resistor is used + * Verify all wires are in appropriate slots. + +===== YAML Configuration +[source, yaml] +---- +pwm: + active-buzzer: + name: active-buzzer + address: 17 + pwmType: SOFTWARE + provider: pigpio-pwm + initial: 0 + shutdown: 0 +---- + +===== Constructor and Methods +The constructor and the methods within the ActiveBuzzerHelper class can be seen in our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/ActiveBuzzerHelper.html[here]. + +===== Example Controller + +====== This controller uses the Active Buzzer to emit sound once prompted by the commands + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/ActiveBuzzerController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc index 693ba2dc..f8417628 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc @@ -11,10 +11,13 @@ endif::rootpath[] ==== LCD1602 [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents/lcdScreen.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcdScreen.adoc[Improve this doc] ===== Overview -This section provides details of the LCD1602 (Liquid Crystal Display) circuit, including its components, assembly instructions, and functionality. The LCD1602 is a kind of dot matrix module that can show letters, numbers, and other characters. The number 1602 describes the display: 2 rows with 16 characters per row. NOTE: The LCD display only works on the 32 bit version of Raspberry Pi OS. +This section provides details of the LCD1602 (Liquid Crystal Display) circuit, +including its components, assembly instructions, and functionality. + +.Note: The LCD1602 only works on the 32-bit version of Raspberry Pi OS. ===== Components . LCD1602 @@ -36,7 +39,22 @@ Connect the 4 pins on the LCD1602 screen to the breadboard as described below an image::lcd1602-circuit.png[] ===== Functionality -The LCD1602 screen will light up once connected to a power source. + +The LCD1602 is a kind of dot matrix module that can show letters, numbers, and other characters. +The number 1602 describes the display: 2 rows with 16 characters per row. + +Use: `curl http://localhost:8080/lcd` to test the component. These following commands will test the component: + +* `/write/{text}` - writes *{text}* to lcd screen +* `/write/{text}/{line}` - writes *{text}* to lcd screen on line number *{line}* +* `/write/{text}/{line}/{pos}` - writes *{text}* to lcd screen on line number *{line}* at pos *{pos}* +* `/write/character/{charValue}` - writes character *{charValue}* to lcd screen +* `/backlight/{state}` - sets backlight to *{state}* (state must be set to *"on"* or *"off"*) +* `/clear/all` - clears lcd screen +* `/clear/{line}` - clears line number {line} of lcd screen +* `/turnOff` - turns off lcd screen + + ===== Testing the Circuit Write Hello to the LCD1602 screen @@ -105,7 +123,7 @@ $ sudo reboot $ uname -m ................. -===== YAML +===== YAML Configuration LCD1602 uses I2C communication for this circuit and configuration in the application.yml file is as follows [source, yaml] ---- @@ -116,19 +134,10 @@ i2c: device: 0x27 ---- -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LCD1602Helper.java[tag=const] ----- - -===== Methods +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LCD1602Helper.java[tags=method] ----- +To see the constructor and methods of our LCD1602Helper class, see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/LCD1602Helper.html[here] +for more details. ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc index 6eac757b..db18bf03 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc @@ -11,7 +11,7 @@ endif::rootpath[] ==== LED [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents/led.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc[Improve this doc] ===== Overview This section provides details of the LED, including its components and assembly instructions. @@ -25,7 +25,7 @@ This section provides details of the LED, including its components and assembly * 1 x Resistor (220Ω) * Power source (appropriate voltage, typically 3.3V) -===== Assembly +===== Assembly Instructions * Place a single LED onto the Breadboard. * The LED will have two pins, a cathode and an anode. @@ -39,52 +39,55 @@ This section provides details of the LED, including its components and assembly ===== Circuit Diagram -image::LED_circuit.png[] +image::LED-CD.png[] + +===== Functionality +LED can be turned on or off, switch state and set to blink for the provided duration in milliseconds. ===== Testing -Use: `curl http://localhost:8080/LED/LEDOn` to test the component. This will cause the LED to light. +Use the below commands to test the component. This will cause the LED to light. +[source, bash] +---- +$ curl http://localhost:8080/led/ledOn +---- +* `/ledOn` - Turns the led on. +* `/ledOff` - Turns the led off. +* `/switchState` - Switches the state of the led. +* `/blink/{duration}/` - Causes the led to blink for the desired duration(milliseconds). ===== Troubleshooting - LED not lighting: Check the connections, and ensure the LED is placed correctly. Double-check the power source. - LED is too dim: Resistor value may be too high. Verify you're using 220Ω or adjust according to the power source your using as well as the LED specifications. -===== YAML +===== YAML Configuration [source, yaml] ---- -led: # <1> - name: LED Output # <2> - address: 17 # <3> - shutdown: HIGH # <4> - initial: HIGH # <5> - provider: pigpio-digital-output # <6> - -led2: - name: LED Output - address: 26 - shutdown: HIGH - initial: HIGH - provider: pigpio-digital-output +digital-output: + led: + name: LED Output + address: 17 + shutdown: LOW + initial: LOW + provider: pigpio-digital-output + led2: + name: LED Output + address: 26 + shutdown: HIGH + initial: HIGH + provider: pigpio-digital-output ---- -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LEDHelper.java[tag=const] ----- -===== Methods +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LEDHelper.java[tags=method] ----- +To see the constructor and methods of our LEDHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/LEDHelper.html[here] +for more details. ===== An Example Controller [source, java] ---- -include:: ../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java[tags=method] +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java[tag=ex] ---- diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc new file mode 100644 index 00000000..735d7ef5 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc @@ -0,0 +1,113 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + + + +==== Passive Buzzer + +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc[Improve this doc] + + + +===== Overview +This section provides details of the Passive Buzzer, including the components and assembly instructions. The Passive Buzzer emits various frequencies, as described by the code, to play music or many other frequencies. + +===== Components +* 1 x RaspberryPi +* 1 x Breadboard +* 1 x T-extension Board +* 1 x Passive Buzzer +* 6 x Jumper wires +* 1 x Resistor (1KΩ) +* 1 x S8550 PNP Transistor +* Power source (appropriate voltage, typically 3.3V) + +===== Assembly Instructions + +* Place the Passive Buzzer onto the Breadboard. +* Place the 1KΩ resistor onto the Breadboard, must be inline with base pin of S8550 PNP Transistor. +* Place the S8550 PNP Transistor onto the BreadBoard. +* The Passive Buzzer will have two pins of the same length. The anode is (+) while the cathode is (-). +* Connect a jumper wire from GND to (-) negative side +* Connect a jumper wire from 3.3V to (+) positive side. +* Connect a jumper wire from GPIO 17 to the 1KΩ resistor +* Connect jumper wire from positive side to positive end of Passive Buzzer. +* Connect jumper wire from negative end of Passive Buzzer to emitter pin of S8550 PNP Transistor. +* Connect jumper wire from negative side to collector pin of S8550 PNP Transistor. + + +===== Circuit Diagram + +image::passive_buzzer-CD.png[] + +*Schematic Diagram* + +image::buzzer-SD.png[] + +===== Functionality + +A passive buzzer is an electronic component that produces sound by using an external oscillation source. +To produce sound, a passive buzzer needs an external PWM signal supplied by Raspberry Pi. This signal controls the frequency of the sound produced, allowing for different tones or beeps. You can program specific melodies or sequences of beeps by changing the frequency of the PWM signal over time. + +*Note:* If you use transistor in the circuit, it swaps the functionalities of the buzzer i.e., if you enable the buzzer, it actually disables it and vice versa. + +===== Testing +Use the below commands to test the component. + +[source, bash] +---- +$ curl http://localhost:8080/passive-buzzer/enable +---- + +* `/enable` - Turns the Passive Buzzer on. +* `/disable` - Turns the Passive Buzzer off. +* `/showFreq` - Displays the current frequency of the Passive Buzzer. +* `/setFreq/{frequenciesFile}` - Plays a series of frequencies from a file specified by the user. +* `/passBuzz` - Plays a 1 - second buzz. +* `/freqIter` - Cycles through different frequencies. +* `/playPiSeq` - Plays an array containing the first ten digits of pi. + + + +===== Troubleshooting +- Passive Buzzer not creating sound: + * Double check power source + * Verify that 1K resistor is used + * Verify all wires are in appropriate slots. + * When using a file, verify that the file itself is scp'd to the raspberrypi (see PassiveBuzzerController for full information). + +===== YAML Configuration +[source, yaml] + +---- +pwm: + passive-buzzer: + name: passive-buzzer + address: 17 + pwmType: SOFTWARE + provider: pigpio-pwm + initial: 0 + shutdown: 0 +---- + +===== Constructors and Methods +The constructor and the methods within the PassiveBuzzerHelper class can be seen in our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/PassiveBuzzerHelper.html[here]. + + +===== Example Controller + +====== This controller uses the Passive Buzzer to emit sound once prompted by the commands + +[source, java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/PassiveBuzzerController.java[tag=ex] + +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc index 0f52215b..e7fc9aa7 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc @@ -1,6 +1,6 @@ ==== RGB LED [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc[Improve this doc] ===== Overview This document provides details of the RGB (Red-Green-Blue) LED circuit, @@ -14,7 +14,7 @@ including its components, assembly instructions, and functionality. . Power source (appropriate voltage, typically 3.3V or 5V) ===== Assembly Instructions -. Place the RGB LED on the Breadboard. The LED has four pins - one for each of the +. Place the RGB LED on the Breadboard. The LED has four pins—one for each of the colors (Red, Green, and Blue) and one common pin (either cathode or anode). . Connect the Resistors. Attach a 220Ω resistor to each of the RGB pins of the LED. This is to limit the current and protect the LED. @@ -27,11 +27,10 @@ positive voltage source (VCC) and the other ends of the resistors to the respect negative terminals (like GPIO pins set to OUTPUT and LOW on a microcontroller). ===== Circuit Diagram -Model: image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image61.png[] -Circuit Diagram: +*Schematic Diagram:* image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/rgb_led_schematic.png[] @@ -48,17 +47,45 @@ produced. For instance: * Magenta: Power both Red and Blue pins while keeping Green off. * White: Power all three pins +===== Testing +Use the below commands to test the component. + +[source, bash] +---- +$ curl http://localhost:8080/rgb/ledOn +---- + +* `/ledOn` - turns on RGB LED +* `/ledOff` - turns off RGB LED +* `/setRed/{val}` - sets value of red to *{val}* +* `/setRed/{val},{frequency}` - sets value of red to *{val}* and frequency to *{frequency}* +* `/setGreen/{val}` - sets value of green to *{val}* +* `/setGreen/{val},{frequency}` - sets value of green to *{val}* and frequency to *{frequency}* +* `/setBlue/{val}` - sets value of blue to *{val}* +* `/setBlue/{val},{frequency}` - sets value of blue to *{val}* and frequency to *{frequency}* +* `/setColor/{redVal},{greenVal},{blueVal}` + - sets values of red *{redVal}*, green *{greenVal}*, and blue *{blueVal}* + +* `/setColor/{redVal},{greenVal},{blueVal},{frequency1},{frequency2},{frequency3}` + - sets values of red *{redVal}*, green *{greenVal}*, and blue *{blueVal}*, + and frequencies of red *{frequency1}*, green *{frequency2}*, and *{frequency3}* + +* `/setColorHex/{hexValue}` - sets color value using its hex value *{hexValue}* +* `/setColorHex/{hexValue},{frequency1},{frequency2},{frequency3}` + - sets color value using its hex value *{hexValue}* + and frequencies of red *{frequency1}*, green *{frequency2}*, and *{frequency3}* + + ===== Troubleshooting . LED not lighting up: Check all connections, ensure the LED is placed correctly, and check the power source. . Only one color is working: One of the pins might have a loose connection. Verify each color pin's connection. -. LED is too dim: The resistor value might be too high. Ensure you're using 220Ω or -adjust according to your power source and LED specifications +. LED is too dim: The resistor value might be too high. Ensure you're using 220Ω or adjust according to your power source and LED specifications -===== Note: The Hex value format must start with "0x" not "#" while passing it as a parameter of "setColorHex()" method. For example, use "0x0000ff" for blue. +*Note:* The Hex value format must start with "0x" not "#" while passing it as a parameter of "setColorHex()" method. For example, use "0x0000ff" for blue. -===== YAML Pin Order +===== YAML Configuration The order for declaring pins for a RGB LED component in the application.yaml file is as follows *RED-PIN-INFO, GREEN-PIN-INFO, BLUE-PIN-INFO* @@ -69,24 +96,27 @@ So in the case of ---- multi-pwm: rgb-led: + name: RGB LED addresses: 17, 18, 27 + pwmTypes: SOFTWARE, SOFTWARE, SOFTWARE + provider: pigpio-pwm + initials: 0, 0, 0 + shutdowns: 0, 0, 0 + rgb-led-2: + name: RGB LED 2 + addresses: 18, 27, 22 + pwmTypes: SOFTWARE, SOFTWARE, SOFTWARE + provider: pigpio-pwm + initials: 0, 0, 0 + shutdowns: 0, 0, 0 ---- the red pin would be the one connected to GPIO 17, green to GPIO 18, and blue to GPIO 27. All lists of values for RGB LED components will follow the same order. -===== Constructors +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/RGBLEDHelper.java[tag=const] ----- - -===== Methods - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/RGBLEDHelper.java[tags=method] ----- +To see the constructor and methods of our RGBLEDHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/RGBLEDHelper.html[here] +for more details. ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/servomotor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/servomotor.adoc new file mode 100644 index 00000000..8e49d1e9 --- /dev/null +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/servomotor.adoc @@ -0,0 +1,104 @@ +:imagesdir: img/ + +ifndef::rootpath[] +:rootpath: ../../ +endif::rootpath[] + +ifdef::rootpath[] +:imagesdir: {rootpath}{imagesdir} +endif::rootpath[] + + +==== Servo Motor + +[.text-right] + +https://github.com/oss-slu-Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/componets/outputComponents/servomotor.adoc[Improve this doc] + +===== Overview +This section provides details of the Servo Motor. Specifically, the Micro Servo 9G - SG90, which is a positional servo with a range from 0 to 180 degrees. These details include the components and assembly instructions. + + +===== Components +* 1 x RaspberryPi +* 1 x Breadboard +* 1 x T-extension Board +* 1 x Servo-Motor +* 3 x Jumper Wires +* Power source (appropriate voltage, typically 3.3V) + +===== Assembly Instructions +* Connect a jumper wire to 3.3V +* Connect a jumper wire to GPIO 18 +* Connect a jumper wire to GND +* Connect the 3.3V jumper wire to the SIG pin (Color: Red) +* Connect the GND jumper wire to the GND pin (Color: Brown or Black) +* Connect the GPIO 18 jumper wire to the VCC pin (Color: Orange) + + +===== Circuit Diagram + +image::servo-motor_CD.png[] + +*Schematic Diagram* + +image::servo-motor_SD.png[] + +===== Functionality +Servo motor is a PWM type and will rotate the arm between the angles of 0 to 180 degrees. + +===== Testing the Circuit +Use the below commands to test the component. + +[source, bash] +---- +$curl http://localhost:8080/servoMotor/enable +---- + +* `/enable` - Turns the Servo Motor on. + +[source, bash] +---- +$curl http://localhost:8080/servoMotor/disable +---- + +* `/disable` - Turns the Servo Motor off. + +[source, bash] +---- +$curl http://localhost:8080/servoMotor/setAngle/{angle} +---- + +* `/setAngle/{angle}` - Sets the indicated angle for the Servo Motor. + +===== Troubleshooting +- Servo Motor not rotating: + * Verify that all wires are placed into the correct locations on the Breadboard + * Verify that the wires are placed correctly into the wire receiver for the Servo Motor + * Verify that the Servo Motor is enabled + + +===== YAML Configuration +[source, yaml] +---- +pwm: + servo-motor: + name: Servo Motor + address: 18 + pwmType: SOFTWARE + provider: pigpio-pwm + initial: 0 + shutdown: 0 +---- + +===== Constructor and Methods +The constructor and the methods within the ServoMotorHelper class can be seen in our javadoc link:https://oss-slu-github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/ServoMotorHelper.html[here]. + +===== Example Controller + +====== This controller uses the Servo Motor to move the arm once prompted by the commands + +[source,java] +---- +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/ServoMotorController.java[tag=ex] +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc b/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc index a2073c77..17e4effd 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc @@ -1,4 +1,6 @@ == Contribute to the Pi4Micronaut Library +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc[Improve this doc] 1. Get Familiar with the Library diff --git a/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc b/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc index 69042bbe..aae5fc50 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc @@ -1,37 +1,40 @@ === How to Create a New Component [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/contribute/newComponent.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc[Improve this doc] -If its compatible with a Raspberry Pi then it should work well with the Pi4Micronaut framework. The following steps should encompass how most components are added to the framework, but should more or different steps be needed, use the -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/contribute/newComponent.adoc[Improve this doc] link to suggest changes. +If its compatible with a Raspberry Pi then it should work well with the Pi4Micronaut. The following steps should encompass how most components are added to the library. Start by creating a new +https://github.com/oss-slu/Pi4Micronaut/issues/new/choose[Issue] to suggest changes. -1. Determine if the device is Input or Output +1. Determine the communication type for the component which you want to use. For example, Buzzer works with PWM and LCD1602 works with I2C. -2. Create a Controller: -** Controllers define and handle interactions with a given component. The Controller of a component will have a `@Controller("/example")` right above the class declaration that acts as the endpoint for requests to the component. Instead of "example", you should name the endpoint something that is identifiable to the component. Each method of the Controller should have a `@Get("/examppleendpoint")` above the method declaration. The endpoint for the method should have the same name as the method and any parameters should be included in the endpoint `/examppleendpoint/{parameter1},{parameter2}`. -** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java[RGB Controller] for an example of a Controller. -** Consult the https://micronaut-projects.github.io/micronaut-docs-mn3/3.8.1/guide/#creatingClient[Micronaut Documentation] for more explanation on Controllers. -** All Controllers should be kept here: -`components\src\main\java\com\opensourcewithslu\components\controllers` +2. Setup the circuit. + +3. Add Component to the Application yml -3. Create a Helper: -** A Helper is what the Controller calls to do a action. For example, to change the color of an RGB LED the controller will take the request to change it. The Controller will then call the change color method in the helper. The helper then takes all the actions needed to change the color of the LED. -** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/micronautpi4j-utils/src/main/java/com/opensourcewithslu/outputdevices/RGBLEDHelper.java[RBG Helper] for an example of a Helper. +** The new component will need to be added to the application yml found at `components/src/main/resources/application.yml`. +** More information on the `application.yml` found in <> -** All Helpers should be kept here: `micronautpi4j-utils\src\main\java\com\opensourcewithslu\(inputdevices or outputdevices)` +4. Create a Helper: +** A Helper is what the Controller calls to do an action. For example, to change the color of an RGB LED the controller will take the request to change it. The Controller will then call the change color method in the helper. The helper then takes all the actions needed to change the color of the LED. +** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputdevices/RGBLEDHelper.java[RBG Helper] for an example of a Helper. -4. Add Component to the Application yml +** All Helpers should be kept here: `pi4micronaut-utils\src\main\java\com\opensourcewithslu\(inputdevices or outputdevices)` - ** The new component will need to be added to the application yml found at `components/src/main/resources/application.yml`. - ** More infomation on the `application.yml` found in <> +5. Create a Controller: +** Controllers define and handle interactions with a given component. The Controller of a component will have a `@Controller("/example")` right above the class declaration that acts as the endpoint for requests to the component. Instead of "example", you should name the endpoint something that is identifiable to the component. Each method of the Controller should have a `@Get("/exampleEndPoint")` above the method declaration. The endpoint for the method should have the same name as the method and any parameters should be included in the endpoint `/exampleEndPoint/{parameter1},{parameter2}`. +** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java[RGB Controller] for an example of a Controller. +** Consult the https://micronaut-projects.github.io/micronaut-docs-mn3/3.8.1/guide/#creatingClient[Micronaut Documentation] for more explanation on Controllers. +** All Controllers should be kept here: +`components\src\main\java\com\opensourcewithslu\components\controllers` -5. Thoroughly test: +6. Thoroughly test: ** Contributors should thoroughly test their integrations ** When submitting a pull request, make sure to include how you tested the component, any circuits that you may have used, and how to run any examples you may have created. ** It is important that reviewers are able to replicated your work in order to properly test the implementation. -6. Create documentation for the component: + +7. Create documentation for the component: ** Create an .adoc file with the component name as the file name. ** Make sure to include all the information that the other components. Simply copy/paste an existing components documentation and edit as needed. - ** Add the file here: `micronautpi4j-utils/src/docs/asciidoc/components` under either input or output components. \ No newline at end of file + ** Add the file here: `pi4micronaut-utils/src/docs/asciidoc/components` under either input or output components. \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/Adding_Dependency.png b/pi4micronaut-utils/src/docs/asciidoc/img/Adding_Dependency.png index 77911810..639dc893 100644 Binary files a/pi4micronaut-utils/src/docs/asciidoc/img/Adding_Dependency.png and b/pi4micronaut-utils/src/docs/asciidoc/img/Adding_Dependency.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/Config_Workflow.png b/pi4micronaut-utils/src/docs/asciidoc/img/Config_Workflow.png new file mode 100644 index 00000000..fdf85bdc Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/Config_Workflow.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/LED-CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/LED-CD.png new file mode 100644 index 00000000..7b6ce3f4 Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/LED-CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/PIR_Sensor_Circuit.png b/pi4micronaut-utils/src/docs/asciidoc/img/PIR_Sensor_Circuit.png new file mode 100644 index 00000000..c6620b9c Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/PIR_Sensor_Circuit.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/active_buzzer-CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/active_buzzer-CD.png new file mode 100644 index 00000000..d32978ba Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/active_buzzer-CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/buzzer-SD.png b/pi4micronaut-utils/src/docs/asciidoc/img/buzzer-SD.png new file mode 100644 index 00000000..12d8b233 Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/buzzer-SD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/microSwitch_CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/microSwitch_CD.png new file mode 100644 index 00000000..ebd9852c Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/microSwitch_CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/microSwitch_SD.png b/pi4micronaut-utils/src/docs/asciidoc/img/microSwitch_SD.png new file mode 100644 index 00000000..59b7d63c Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/microSwitch_SD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/passive_buzzer-CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/passive_buzzer-CD.png new file mode 100644 index 00000000..1f0c882f Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/passive_buzzer-CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/photoresistor-CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/photoresistor-CD.png new file mode 100644 index 00000000..cbe0c2ce Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/photoresistor-CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/servo-motor_CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/servo-motor_CD.png new file mode 100644 index 00000000..0b7d196a Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/servo-motor_CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/servo-motor_SD.png b/pi4micronaut-utils/src/docs/asciidoc/img/servo-motor_SD.png new file mode 100644 index 00000000..eb40ceab Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/servo-motor_SD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/tiltSwitch_CD.png b/pi4micronaut-utils/src/docs/asciidoc/img/tiltSwitch_CD.png new file mode 100644 index 00000000..62407d40 Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/tiltSwitch_CD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/tiltSwitch_SD.png b/pi4micronaut-utils/src/docs/asciidoc/img/tiltSwitch_SD.png new file mode 100644 index 00000000..e60e16aa Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/tiltSwitch_SD.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/touchSwitch.png b/pi4micronaut-utils/src/docs/asciidoc/img/touchSwitch.png new file mode 100644 index 00000000..6a214fc0 Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/touchSwitch.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/touchSwitchDiagram.png b/pi4micronaut-utils/src/docs/asciidoc/img/touchSwitchDiagram.png new file mode 100644 index 00000000..6f4e1bdb Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/touchSwitchDiagram.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_circuit.png b/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_circuit.png new file mode 100644 index 00000000..7f6e35c6 Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_circuit.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_model.png b/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_model.png new file mode 100644 index 00000000..68ccd76e Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_model.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_timing_diagram.png b/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_timing_diagram.png new file mode 100644 index 00000000..c8c84cfd Binary files /dev/null and b/pi4micronaut-utils/src/docs/asciidoc/img/ultrasonic_sensor_timing_diagram.png differ diff --git a/pi4micronaut-utils/src/docs/asciidoc/index.adoc b/pi4micronaut-utils/src/docs/asciidoc/index.adoc index ec4c45d9..8d7aa04f 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/index.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/index.adoc @@ -32,12 +32,8 @@ include::contribute/contributingToLibrary.adoc[] include::contribute/newComponent.adoc[] -include::adding_creating_App.adoc[] - -include::usingLibrary.adoc[] - -include::components.adoc[] +== Components include::components/commun_WithHardware.adoc[] @@ -64,8 +60,17 @@ include::components/inputComponents/rotaryEncoder.adoc[] include::components/inputComponents/rfidScanner.adoc[] -include::components/inputComponents/photosensor.adoc[] +include::components/inputComponents/ultraSonicSensor.adoc[] + +include::components/inputComponents/touchSwitch.adoc[] + +include::components/inputComponents/pirSensor.adoc[] +include::components/inputComponents/photoresistorSensor.adoc[] + +include::components/inputComponents/tiltSwitch.adoc[] + +include::components/inputComponents/microSwitch.adoc[] include::components/outputComponents.adoc[] @@ -75,4 +80,8 @@ include::components/outputComponents/rgbLed.adoc[] include::components/outputComponents/lcd1602.adoc[] +include::components/outputComponents/passivebuzzer.adoc[] + +include::components/outputComponents/activebuzzer.adoc[] +include::components/outputComponents/servomotor.adoc[] diff --git a/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc b/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc index c5fbf5b8..12f5ce3c 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc @@ -1,7 +1,7 @@ == Introduction [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/introduction.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc[Improve this doc] @@ -11,6 +11,8 @@ Welcome to the **Pi4Micronaut Documentation**! Pi4Micronaut is an Open Source Java library which utilizes the Micronaut Framework and Pi4J to streamline the process of creating custom IoT applications that require hardware connectivity to Raspberry Pi's. +**Note:** Pi4Micronaut doesn't work with the latest Raspberry Pi 5 because of its whole new architecture. Pi4J and pigpio libraries doesn't provide support for Pi 5 yet. Look out for the latest version of Pi4J to work with Pi5's in the future. + By reading through our documentation, you will learn how to implement our library into your application. diff --git a/pi4micronaut-utils/src/docs/asciidoc/style.css b/pi4micronaut-utils/src/docs/asciidoc/style.css index 67574cc9..1c9f7522 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/style.css +++ b/pi4micronaut-utils/src/docs/asciidoc/style.css @@ -68,10 +68,11 @@ a { position: fixed; box-sizing: border-box; background-color: gainsboro; - max-width: 15.5%; - width: 100%; + max-width: 20%; + width: 20%; } + #toc a { color: royalblue; } @@ -126,19 +127,20 @@ h2 { overflow-y: auto; grid-area: content; padding: 1em; - max-width: 84%; + max-width: 80%; width: 100%; position: fixed; z-index: 1; max-height: 80%; height: 100%; - margin-left: 15.5%; + margin-left: 20%; margin-right: 0; margin-bottom: 1%; margin-top: 8%; padding-bottom: 100px; } + .hljs{ background: #cacbca !important; } diff --git a/pi4micronaut-utils/src/docs/asciidoc/usingLibrary.adoc b/pi4micronaut-utils/src/docs/asciidoc/usingLibrary.adoc deleted file mode 100644 index ebf04b9f..00000000 --- a/pi4micronaut-utils/src/docs/asciidoc/usingLibrary.adoc +++ /dev/null @@ -1,5 +0,0 @@ -== Using the library -[.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/usingLibrary.adoc[Improve this doc] - -TODO: outline the most basic use cases of the library, tbh now sure how this differs from the section above \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/javadoc/allclasses-index.html b/pi4micronaut-utils/src/docs/javadoc/allclasses-index.html index fef0cb67..ed25118a 100644 --- a/pi4micronaut-utils/src/docs/javadoc/allclasses-index.html +++ b/pi4micronaut-utils/src/docs/javadoc/allclasses-index.html @@ -1,14 +1,15 @@ - -All Classes and Interfaces (pi4micronaut-utils v1.0 API) + +All Classes and Interfaces (pi4micronaut-utils v1.1 API) + @@ -23,7 +24,7 @@