USB Relay Modules

1 Channel USB Powered Relay(SPDT) Module

0 views August 2, 2022 vidya 0

Introduction

Numato Lab’s 1 Channel USB Powered Relay(SPDT) Module is a great product for controlling electrical and electronic devices remotely from a PC or Mobile Device over USB link. Built in USB to serial conversion allows the module to be used without any USB specific knowledge. This simplicity allows the use of off-the-shelf Terminal Emulation programs such as Hyper Terminal and PUTTY for controlling the module with a simple set of human-readable commands. For power users, this module can be controlled by writing programs in various programming languages.

Features:

  • 1 onboard SPDT Relay.
  • 10A Maximum Switching Current.
  • 4 Digital Inputs supports Maximum Input Voltage of 5V
  • 4 Digital Outputs
  • 3 Analog Input Channels (Multiplexed with Inputs).
  • 10 bits Analog Input Resolution.
  • USB interface with CDC support. As easy as using a serial port, no USB knowledge required.
  • Relay contacts available on easy to plug terminals.
  • Can be controlled by using standard serial console applications or custom applications.
  • No vendor specific libraries or APIs required

Some of the possible uses of this module include

  • Home Automation
  • Lighting Control
  • Garden Equipment Control
  • Industrial Automation
  • Test Fixtures
  • DIY and Hobby

This product is compatible with the following operating systems:

  • Windows XP and later versions (Windows 7, 8/8.1, 10 and future versions)
  • Windows 7 Embedded and later
  • Linux
  • Mac OS X
  • Android
  • Or any other operating system that supports USB CDC devices.

And these are some of the languages that can be used for programming:

  • C/C++
  • Visual Basic (VB6, VB2008, VB2010 express and other editions)
  • Visual Basic for Applications (Microsoft Office VBA)
  • Perl
  • Python
  • JAVA
  • Android
  • Javascript (Node.js)
  • And many more…

This product has 1 on-board relay and associated drivers capable of controlling a variety of devices including lamps, motors, locks, etc…  (Please see recommendations for using this product with inductive loads elsewhere in this document). This module also includes 4 Digital Inputs, 4 Digital Output and 3 Analog Inputs (multiplexed with Inputs) that can be accessed over the USB interface for extended functionality. The module communicates with the host PC over the full-speed USB link. When connected to PC, the module will appear as a serial port in Windows Device Manager (or a serial tty device in Linux and Mac).

Technical Specifications

ParameterValueUnit
Number of relays 1
Number of Digital Inputs4
Number of Digital Outputs4
Number of analog inputs (Multiplexed with Inputs)3
Digital circuit power supply voltage (USB)5V
Maximum current drawn by digital circuitry95mA
IO Specifications
Maximum IO source current50mA
Maximum IO sink current50mA
GPIO input low voltage 0.8V
GPIO input high voltage 2V
GPIO output low voltage 0V
GPIO output high voltage 5V
ADC Specifications
Resolution10bits
Full scale range0 – VDDV
Reference voltageVDDV
Recommended Impedance of Analog Voltage Source2.5KΩ
Relay Specifications
Nominal relay coil voltage 5V
Nominal coil power consumption (per relay)360mW
Relay contact material Silver Alloy
Contact rating 10A/ 277V AC
10A/ 28V DC
Maximum switching voltage 277V AC/ 28V DC
Maximum switching current10A
Maximum switching power270VA/ 240W
Contact resistance (initial)100 Max at 6VDC 1A mΩ
Life expectancy (Electrical) 100,000 Operations
Life expectancy (Mechanical) 10,000,000Operations
Nominal insulation resistance 100 Min at 500VDCMΩ
Maximum switching on response time10mS
Other Information
USB Vendor ID0x2A19
USB Product ID0x0C0F

How to Use 1 Channel USB Powered Relay(SPDT) Module

Using this product is very easy,  thanks to the human-readable and easy to use command set and the USB CDC interface that allows the device to be used with most readily available serial terminal software such as Tera Term or HyperTerminal.  This document has more information about using this device with the following Serial terminal software. But in no way limited to this software though.

  • Windows
    • HyperTerminal
    • Tera Term
  • Linux
    • GNU Screen
    • PuTTY
  • Mac OS X
    • Screen Command
    • CoolTerm
    • goSerial

Components/Tools Required

Along with the module, you may need the items in the list below for easy and fast installation.

  • USB A to type B cable
  • Medium size Philips screwdriver

Connection Details

IMPORTANT! Please exercise the utmost caution while working with electrical mains or other high voltages. Failure to comply with safety regulations may result in injury and or death.

Using this product involves the following simple steps.

• Connect the device to a USB port on the host system.
• Install the Numato Lab CDC Driver (Only for windows, available on the product page)
• Open any of the Serial terminal Emulator Software and connect the module using the COM port number
• Control/ monitor the module using the commands available.
• Optionally write a script or application to automate your task

The module is connected to the PC through a USB Type B cable. The digital circuitry is powered from the USB.

Relay Contacts

This module has one SPDT mechanical relays that can switch up to 10A of current. All contacts on the relay are available externally on screw terminals for easy user access. The relays are rated for AC and DC supply voltages. Please see the electrical parameter table for more details. Each relay has 3 contacts(COM, NO, and NC). COM is the common terminal and is used in both normally open and normally closed positions. The contacts NC and COM will be connected when the relay is turned off and will be disconnected when the relay is turned on. And vice versa, the contacts COM and NO will be disconnected when the relay is turned off and will be connected when the relay is turned on. The table below summarizes possible relay contact positions.

Relay StateConnection between NC and COM Connection between NO and COM
OFFCloseOpen
ON Open
Close

GPIO/Analog Inputs

The module has 4 Digital Output and 4 Digital Input pins that can be used for various custom applications. Some of the input pins can be used as Analog to Digital Converter inputs as well. All IO pins support 5V TTL signals and the ADC input range is 0 to +5V. The ADC can acquire analog signal at the resolution of 10 bits per sample. It is recommended to use a series resistor with the GPIO/ADC pins when interfacing with other circuits. In output mode, each GPIO can source up to 25mA. So no additional circuitry is needed to drive regular LEDs. A 470 Ohms series resistor is recommended for current limiting when connecting LED to a GPIO.

In contrast to GPIOs Analog inputs can read voltages at any level between 0 to 5V volts. It is recommended to use a series resistor to protect the input from stray voltages and spikes. The internal Analog to Digital converter supports 10 bits resolution which is adequate for most applications.

The table below summarizes the Input and Analog to Digital Converter input positions on the header P12.

InputADC
I0ADC0
I1ADC1
I2ADC2
I3-
GGND
VDD5V

The table below summarizes pin positions on the header P13.

OutputFunctions
O0-
O1-
O2-
O3-
GGND
VDD5V

 

Sending Commands

This product supports a very simple command set that is designed to be less cryptic and easy to use manually or through a program written in many supported languages.

The Command Set

No.CommandParametersExampleDescription
1vernoneverReturns firmware Version.
2idgetid getReads Module ID
set xxxxxxxxid set 12345678Assign ID to the module
3infononeinfoInformation on Relay and GPIO power-on status
4relayon xxxrelay on 000Control the relays
off xxxrelay off 000
read xxxrelay read 000Read relay status
poweron xxrelay poweron 01Sets Relay power-on value
5resetnoneresetReset all relays to default state
6gpioset xxxgpio set 000Control GPOs
clear xxxgpio clear 000
read xxxgpio read 000Read input status
status xxxgpio status 000Read GPO status
poweron xxgpio poweron 05Sets GPO power-on value
7adcread xxxadc read 001Read Analog to Digital Converter input

The table below has more detailed information about available commands.

No.CommandExampleDescription
1ververReturns firmware version
2idid getReads the module ID
id set xxxxxxxxAssign ID to the module, where ‘x’ can be any alphanumeric character
ID should be 8 characters

3infoinfoDisplays the information on Relay power-on status
4relayrelay on xxxTurn on the relay ‘xxx’.
relay on 000 – Turn on Relay 0
xxx can only be 000
relay off xxxTurn off the relay ‘’xxx’.
relay off 000 – Turn off Relay 0
xxx can only be 000
relay read xxxRead status of the relay ‘xxx’.
relay read 000 – Read status of Relay 0 and print either ‘on’ or ‘off’ depending on the status
xxx can only be 000
relay poweron xxSets the relay status on power-on.
Turn OFF and ON relays on power-on the module according to the specified hexadecimal value.
0 – Turn OFF the relay , 1 – Turn ON the relay.
xx can be 00 or 01
5resetresetReset by turning OFF all relays
6gpiogpio set xxxSet GPIO ‘xxx’ output status to high.

gpio set 000 – Sets O0 to high state
xxx can be 000 to 003
gpio clear xxxSets GPIO ‘xxx’ output status to low.

gpio clear 000 – Sets O0 to low state
xxx can be 000 to 003
gpio read xxxRead status of the GPIO ‘xxx’.
gpio read 004 – Read status of I0 and print either ‘1’ or ‘0’ depending on the status.
xxx can be 004 to 007
gpio status xxxRead the GPIO status present at ‘xxx’ without changing the GPIO direction.

gpio status 003 – Read status of O3 and print either ‘1’ or ‘0’ depending on the status
xxx can be 000 to 003
7adcadc read xxxReads the analog voltage present at the ADC input ‘xxx’ mentioned.
adc read 002 – Reads value of adc input 2 and print the response. The response will be a number that ranges from 0 – 1023.
xxx can be 000 to 002

Additional Information

Using relay modules with inductive loads

Snubber Diode

Diode As Snubber

It is important to take additional care when using relays with inductive loads. An inductive load can be pretty much anything that has a coil and works based on magnetic principles like Motors, Solenoids, and transformers. But in practice, even a wire longer than a few feet can display substantial inductance. Inductive loads produce back emf when the magnitude of the load current changes. The back emf can be in the order of tens or even hundreds of voltage (See this Wikipedia article http://en.wikipedia.org/wiki/Counter-electromotive_force). This effect is most severe when power is disconnected from the inductive load because the rate of change of current is maximum at that point. Even though the back emf lives only for a very short time (a few milliseconds) it can cause sparks between the relay contacts and can deteriorate the contact quality over time and reduce the life span for the relays considerably.

So it is important to take countermeasures to suppress the back emf to acceptable levels to protect relay contacts. Usually, this requires connecting electronic devices in parallel with the load such that they absorb the high voltage components generated by the load. For solenoids, connecting a diode (fast switching diode is recommended) in parallel to the load (in reverse direction to the load current) is very effective. A diode used for this purpose is usually called a freewheeling diode. Please see the diagram on the right for connection details.

Capacitive Snubber

Capacitor As Snubber

A capacitor with a proper rating is recommended for protecting the relay contacts when a motor is used as a load. The capacitor should be rated enough to withstand the back emf that is generated by the motor. Please see the diagram below for connection details.

Please note that the relay modules are NOT shipped with back emf suppression devices pre-installed. The exact kind of suppression device and the parameters of the selected device can vary depending on the load itself. Some of the parameters that affect the suppression device selection are the inductance of the load, power supply voltage, load current, physical size/structure of the load, etc.. It is obvious that it is impossible for us to predict these parameters and design required back emf suppression device and incorporate that on the board. So we believe this is a task best left to the module user. There is an excellent article on designing back emf suppression on Wikipedia at http://en.wikipedia.org/wiki/Flyback_diode

Analog to Digital Converters (ADCs)

1 Channel USB Powered Relay(SPDT) Module does support Analog to Digital Conversion on some of the inputs A list of inputs that supports analog function in this product is listed in section GPIO/Analog Inputs in this document. There is no special command required to execute to switch between analog and digital mode. Executing the “adc” command will set the input to the analog mode and executing the “gpio” command will set the inputback to digital mode on the fly. The Resolution of the ADC is 10 bits unless otherwise noted. The input voltage range of the ADC is 0 – VDD (this product uses 5V power supply, so the range will be 0 – 5V). The result will be returned as a number starting at zero and ending at 1023. Zero indicates zero volts at the ADC input and 1023 indicates VDD (5V for this product) at ADC input.

GPIO with Switches

USBGpio Switch connection diagramIt is possible to read the position of a switch that is connected to an input. An SPST or SPDT switch is recommended to use with inputs. Push switches do maintain the contacts closed only for a very short time so using them is discouraged. The fundamental idea of using a switch with input is to have the switch cause a voltage level change at the input pin when pressed. Usually, this is achieved by using an external pull-up resistor along with the switch. The pull up resistor is connected between the input and VDD and the switch is connected between the input and ground. When the switch is not pressed, the pull-up resistor will cause the input to stay at the VDD voltage level. When the switch is pressed, the input is short-circuited to ground and stays at zero voltage. This change in voltage and thus the position of the switch can be read using “gpio read” command.

Mechanical Dimensions

NL-USBR-C-001 Physical Measurements

Frequently Asked Questions (FAQs)

Q. What are the serial parameters I need to use when communicating with this board?
A. Since this module uses USB as the underlying transport mechanism, most of the serial parameters do not affect the communication. You can leave all parameters to any legal value (Eg: 2400, 4800, 9600 etc… for baud rate) except Flow control. Flow control needs to be set to “None”.

Q. Where do I find driver for this product?
A. Visit http://numato.com and navigate to the product page. There will be a link to download windows driver. Linux does not require driver installation since in most cases they are shipped with the driver pre-installed.

Q. Why there is no .sys or .exe file in the Windows driver package I downloaded?
A. This product uses USB CDC driver binary which is already present on Windows. All Windows versions (with the exception of Embedded Editions) has this driver binary installed by default. The .inf and .cat files present in the zip file helps Windows identify the device properly and associate appropriate driver (.sys) to the device

Q. Does this product work with Linux?
A. Yes, this product works with Linux. Please see more details on how to use this product with Linux elsewhere in this document.

Q. Does this product work with Mac OSX?
A. Yes, this product works with Mac OSX. Please see more details on how to use this product with Mac elsewhere in this document.

Q. What are the serial terminal software that this product work with?
A. This product works with a lot of different Serial Terminal software. Some examples can be found elsewhere in this document. Different Serial Terminal software are written by different developers with different purposes in mind. So you may encounter some software that may not work with this product. But usually alternatives are available in most if not all cases.

Q. The GPIO looses its previously set value when trying to read the status. Why it is so?
A. When a gpio is to output a value (high/low), that particular GPIO is put to output mode. When you are trying to read the GPIO, it needs to be put in input mode. In input mode, the GPIO will go to high impedance state and thus looses the previously set value.

Q. I’m using x language for programming. How do I find out if this language can be used to program and control the GPIO module?
A. Find out if the language of interest supports some kind of APIs/Functions/Components for serial communication. If it does, most likely you should be able to use that language with this module.

Q. What is the connector marked as ICSP on this module?
A. This connector is used to program the on-board microcontroller. This connector is primarily intended for factory use.

Q. I need a customized version of this product, can Numato do the customization for me?
A. Yes, we can definitely do customization but there may be minimum order requirements depending on the level of customization required. Please write to [email protected] for a quote.

Q. Where can I buy this product?
A. All Numato products can be ordered directly from our web store http://www.numato.com. We accept major credit cards and Paypal and ship to almost all countries with a few exceptions. We do have distributors in many countries where you can place your order. Please find the current list of distributors at http://numato.com/distrib.

Suggest Edit