It's easy to use the STEMMA Non-Latching Mini Relay to control power. This page will show you how to wire up the breakout board and use simple code to turn the relay on and off.
Wiring
Use a STEMMA cable to connect the relay board to you project. The following is an example of the relay board connected to a Circuit Playground Bluefruit using the STEMMA-to-alligator-clip cable.
- Plug the 3-pin JST to alligator clip cable into the 3-pin JST connector on the STEMMA Relay
- Connect the white alligator clip to A1
- Connect the black alligator clip to GND
- Connect the red alligator clip to 3.3v
Circuit Playground Bluefruit Example
This example uses CircuitPython. If you're not already using CircuitPython, check out the Circuit Playground Bluefruit guide for information on how to install and use CircuitPython on your device.
This example switches the relay once every second.
Save the following example as code.py on your CIRCUITPY drive:
# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries # # SPDX-License-Identifier: MIT import time import board import digitalio relay = digitalio.DigitalInOut(board.A1) relay.direction = digitalio.Direction.OUTPUT while True: relay.value = True time.sleep(1) relay.value = False time.sleep(1)
This board has a single Signal pin (the white wire). Normally, the relay's COM pin is connected mechanically to the NC pin and the NO pin is disconnected.
When the Signal pin is pulled high, the relay switches and the internal switch changes so that the COM pin is mechanically connected to the NO pin and NC is then disconnected.
When the relay is active, a red LED is lit, and about 50mA of current from the red power wire is used to keep the coil switched on. Note, if power is lost, the relay will go back 'open'.
The connects for the relay are the white tubular thing at the far end of the PCB. You can poke wire into the holes, they will automatically grip onto wire that is 24AWG to 18AWG. Once you poke the wire in, give it a light pull to verify its clamped. To release the wire, use a thin screwdriver or pen to press on the button on the top while pulling the wire out.
That's all there is to using the STEMMA non-latching mini relay with the Circuit Playground Bluefruit!
Text editor powered by tinymce.