Skip to content

Commit

Permalink
Fixes #224 | Started basis of photoresistorSensor documentation (#227)
Browse files Browse the repository at this point in the history
* Started basis of photoresistorSensor documentation

* Added the preliminary information for testing

* Added more information to the .adoc. Still need to add the Circuit Diagram

* Incorporated Circuit Diagram into .adoc, added .png file to img folder, and add ex tag to PhotoResistorController

* Updated .adoc with changes. Added index.adoc file with photoresistorSensor link.

* Provided accurate circuit diagram for photoresistor with help from Aswindle. Provided updated circuit diagram for LED also with help from Aswindle. Implemented further changes from comments within pull request.

---------

Co-authored-by: Alex Delgado <[email protected]>
Co-authored-by: Adrian Swindle <[email protected]>
  • Loading branch information
3 people authored Apr 23, 2024
1 parent 9951e24 commit 9502888
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.inject.Named;
import javax.validation.constraints.Positive;

//tag::ex[]
@Controller("/photoResistor")
public class PhotoResistorController {
private final LEDHelper ledHelper;
Expand Down Expand Up @@ -55,4 +56,5 @@ public String setThreshold(@Positive int i) {
return ("Darkness threshold set to "+ i + "\n");
}

}
}
//end::ex[]
Original file line number Diff line number Diff line change
@@ -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]
----
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pi4micronaut-utils/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ 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/outputComponents.adoc[]

include::components/outputComponents/led.adoc[]
Expand Down

0 comments on commit 9502888

Please sign in to comment.