Skip to content

Commit

Permalink
Merge pull request #269 from oss-slu/264-SpeedSensorDocumentation
Browse files Browse the repository at this point in the history
Added Speed Sensor Documentation
  • Loading branch information
yrlmanoharreddy authored Oct 21, 2024
2 parents 3e99403 + 80690a2 commit 26bccae
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pi4j:
provider: pigpio-digital-input
speed-sensor:
name: Speed Sensor # <1>
address: 22 # <2>
address: 17 # <2>
pulses-per-revolution: 20 # <3>
provider: pigpio-digital-input # <4>
debounce: 500 # <5>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
:imagesdir: img/

ifndef::rootpath[]
:rootpath: ../../
endif::rootpath[]

ifdef::rootpath[]
:imagesdir: {rootpath}{imagesdir}
endif::rootpath[]

==== Speed Sensor

[.text-right]
https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/speedSensor.adoc[Improve this doc]

===== Overview
This section provides the details of the Speed Sensor circuit, including its components, assembly instructions, and functionality.

===== Components
* Speed Sensor
* Bread Board
* T-Extension Board
* 7x Jumper Cables
* Green LED Light Bulb
* Red LED Light Bulb
* 2x 220Ω Resistors
* Power source

===== Assembly Instructions
. Ground (GND): Connect the GND pin on the speed sensor to the ground rail on the breadboard.
. VCC: Connect the VCC pin on the speed sensor to the 5V pin on the Raspberry Pi GPIO header via the breadboard power rail.
. Digital Output (D0): Connect the D0 pin on the speed sensor to GPIO 17 (Pin 11) on the Raspberry Pi GPIO header.
. Connect the longer leg (anode) of the red LED to a row on the breadboard.
. Place a 220-ohm resistor between the shorter leg (cathode) of the red LED and the ground rail on the breadboard.
. Use a jumper wire to connect the same row as the anode of the red LED to GPIO 27 (Pin 13) on the Raspberry Pi.
. Similarly, place the green LED on the breadboard.
. Connect the longer leg (anode) to a free row.
. Place another 220-ohm resistor between the cathode of the green LED and ground.
. Use a jumper wire to connect the anode of the green LED to GPIO 22 (Pin 15).
. Connect the ground rail on the breadboard to a ground pin (GND) on the Raspberry Pi GPIO header (e.g., Pin 6).
. Connect the power rail on the breadboard to a 5V pin on the Raspberry Pi GPIO header (e.g., Pin 2).

===== Circuit Diagram

image::SpeedSensor-Circuit.png[]

*Schematic Diagram:*

image::SpeedSensor-Schematic.png[]

===== Functionality

===== Testing the Circuit:

Use the below command to test the speed sensor.

[source, bash]
----
$curl http://localhost:8080/speedSensor/enable
----

* `/enable` - Initializes the Speed Sensor

[source, bash]
----
$curl http://localhost:8080/speedSensor/speed/rpm
----

* `/speed/rpm` - Returns the speed in RPM

[source, bash]
----
$curl http://localhost:8080/speedSensor/speed/disable
----

* `/disable` - Disables the Speed Sensor

===== Troubleshooting

Verify that all connections are correct and that the order of components in a row are correct.

===== YAML Configuration
The speed sensor as it appears in the application.yml:

[source, yaml]
----
digital-input:
speed-sensor:
name: Speed Sensor
address: 17
pulses-per-revolution: 20
provider: pigpio-digital-input
debounce: 500
----

===== Constructors and Methods
To see the constructor and methods of our SpeedSensorHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/SpeedSensorHelper.html[here]
for more details.

===== An Example Controller

====== This controller sets up Speed Sensor

[source, java]
----
include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/SpeedSensorController.java[tag=ex]
----
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.

0 comments on commit 26bccae

Please sign in to comment.