mangOH Red Digital Inputs

This topic describes how to physically connect a digital input to a mangOH Red.

Now that you've decided to connect to your mangOH Red via GPIO, you'll need to:

  1. Plug the antennas into the mangOH Red.
  2. Plug the LCD screen onto the mangOH Red's Raspberry Pi connector, ensuring that the connector is aligned to the left.
  3. Ensure that dip switches 1, 3, 8 are configured to ON.
  4. Take a look at the GPIO pin map and decide which GPIO pin you'll use.
  5. Configure the pin for digital input for via the GPIO Service screen in Octave.

You can then perform the steps in the following tutorials to verify that the pin is working correctly as a digital input and to control it via Octave:

Tutorial 1: Using a Simple Jumper to Assert Voltage on an Input Pin from an Output Pin

This tutorial describes how to configure an input pin, and verify that it's working correctly by driving its value from an output pin on a mangOH Red.

Before continuing, first complete the tutorial: Tutorial 1: Verifying the Pin Voltage with a Multimeter, as that (output) pin will bridged and used to drive an input pin for this tutorial.

📘

Note

For this tutorial you will need a spare jumper or jumper wire.

Adding a GPIO Input

Follow the steps below to configure a digital input pin:

  1. Navigate to Device > Services, locate the GPIO section, and click Configure.
  2. Locate the Add pin section.
  3. Click the Pin drop down and select a GPIO pin (e.g. WP_GPIO_1).
  4. Note the expected voltage indicated for the pin which will be either 1800mV or 3300mV.
  5. (Optional) Change the name in Resource to a more descriptive name.
  6. Ensure the Direction is set to Input.
  7. Set Edge detection as None and Pull to Up.
  8. Click Add. The configured pin appears in the list of GPIO Services.

Setting the Input Value

Follow the steps below to set the value for the digital input pin by bridging it to the digital output pin configured above:

  1. Ensure that the digital output configured in configuring an output GPIO pin is still producing a voltage of 1800mV or 3300mV.
  2. Using a jumper or jumper wire, bridge the output pin with the input pin configured above.
  3. Navigate to Device > Resources and locate the input pin resource configured in the previous section. The name will be prefixed with io/config. The Value column for the value property should be true. This indicates that the input pin is working correctly.

Tutorial 2: Using one External Device to Control Another Through Octave

In this tutorial you will wire up a circuit consisting of a push button connected to a GPIO input pin on the mangOH Red, and an LED connected to a GPIO output pin on the mangOH Red. This tutorial will then walk through how to configure both pins, and set up an Observation in Octave so that an input resource can be used to drive an output resource.

After you have wired up the circuit and completed the configuration steps in Octave, pushing the button will assert voltage on the input pin causing its value in Octave to become true. This in turn will drive the output resource connected to the LED causing the light to turn on.

This tutorial demonstrates how one external device can be used to control another external device through Octave.

📘

Note

For this tutorial you will need the following electronic components:

  • Four jumper wires
  • 220 ohm resistor
  • LED
  • Push button
  • Breadboard

Wiring the Circuit

  1. Wire up the following circuit:
402
  1. Power on the mangOH Red.

Configuring a Digit Input

Follow the steps below to configure a digital input pin that will be controlled by the push button:

  1. Navigate to Device > Services, locate the GPIO section, and click Configure.
  2. Locate the Add pin section.
  3. Click the Pin drop down and select GPIO pin: WP_GPIO_1.
  4. (Optional) Change the name in the Resource Path to a more descriptive name (e.g. /io/button)
  5. Set the Direction to Input.
  6. Set Edge detection to both.
  7. Set Pull to down.
  8. Click Add. The configured output pin appears in the list of GPIO Services.
  9. Navigate to Device > Resources
  10. Locate and expand io > button
  11. Click the edit button to the right of the period property.
  12. Set the polling period to a relatively small value (e.g. 4) and click Set to save the change. This sets the number of seconds to wait before polling the value.

Configuring a Digit Output

Follow the steps below to configure a digital output pin that will control the LED:

  1. Navigate to Device > Services, locate the GPIO section, and click Configure.
  2. Locate the Add pin section.
  3. Click the Pin drop down and select GPIO pin: WP_GPIO_3.
  4. (Optional) Change the name in the Resource Path to a more descriptive name (e.g. /io/LED)
  5. Set the Direction to Output.
  6. Ensure Output Drives is set to Push-pull.
  7. Click Add. The configured output pin appears in the list of GPIO Services.

Configuring an Observation to Drive the Output Resource from the Input Resource

Follow the steps below to configure an Observation that will be used to drive the GPIO output resource from the GPIO input resource configured above:

  1. Navigate to Device > Observations and click Add Observation.
  2. Set Observed resource to the value for the input resource configured above in Configuring a Digit Input (e.g. /io/button/value).
  3. Set Send events to Resource.
  4. Set Destination resource to the value of the output resource configured above in Configuring a Digit Output (e.g. /io/LED/value). This enables the Observation to control the destination resource with the value from the observed resource (i.e. to control the output resource with the value of the input resource).
  5. Set the Observation name to PushButton.
  6. Click Save to save the Observation and wait a few seconds for the device to update.

Configuring an Additional resource to Verify the PushButton Value

Although not required, it can be helpful to create an additional Observation on the input resource that sends events to the Cloud stream, so that you can verify that the state/value of the input device (i.e. the push button) is coming through to Octave correctly.

Follow the steps below to add this Observation:

  1. Navigate to Device > Observations and click Add Observation.
  2. Set Observed resource to the value for the input resource configured above in Configuring a Digit Input (e.g. /io/button/value).
  3. Set Send events to Cloud Stream.
  4. Set the Observation name to PushButton_to_Cloud.
  5. Click Save to save the Observation and wait a few seconds for the device to update.

Testing the Configuration

At this point the circuit has been wired, everything has been configured in Octave, and you can now try out the configuration:

  1. Navigate to Device > Stream and click on the stream named PushButton_to_Cloud.
  2. Verify that the value is updating periodically (e.g. every 4 seconds, as configured for the input resource above in Configuring a Digit Input and that the value is false.
  3. Push the button on the push button component. The LED should light up while the button is pressed and the PushButton_to_Cloud stream should indicate a value of true.

This verifies that everything is working correctly and that one external device can control another external device via Octave.