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
Parameter | Value | Unit |
---|---|---|
Number of relays | 1 | |
Number of Digital Inputs | 4 | |
Number of Digital Outputs | 4 | |
Number of analog inputs (Multiplexed with Inputs) | 3 | |
Digital circuit power supply voltage (USB) | 5 | V |
Maximum current drawn by digital circuitry | 95 | mA |
IO Specifications | ||
Maximum IO source current | 50 | mA |
Maximum IO sink current | 50 | mA |
GPIO input low voltage | 0.8 | V |
GPIO input high voltage | 2 | V |
GPIO output low voltage | 0 | V |
GPIO output high voltage | 5 | V |
ADC Specifications | ||
Resolution | 10 | bits |
Full scale range | 0 – VDD | V |
Reference voltage | VDD | V |
Recommended Impedance of Analog Voltage Source | 2.5 | KΩ |
Relay Specifications | ||
Nominal relay coil voltage | 5 | V |
Nominal coil power consumption (per relay) | 360 | mW |
Relay contact material | Silver Alloy | |
Contact rating | 10A/ 277V AC 10A/ 28V DC | |
Maximum switching voltage | 277V AC/ 28V DC | |
Maximum switching current | 10 | A |
Maximum switching power | 270VA/ 240W | |
Contact resistance (initial) | 100 Max at 6VDC 1A | mΩ |
Life expectancy (Electrical) | 100,000 | Operations |
Life expectancy (Mechanical) | 10,000,000 | Operations |
Nominal insulation resistance | 100 Min at 500VDC | MΩ |
Maximum switching on response time | 10 | mS |
Other Information | ||
USB Vendor ID | 0x2A19 | |
USB Product ID | 0x0C0F |
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
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 State | Connection between NC and COM | Connection between NO and COM |
---|---|---|
OFF | Close | Open |
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.
Input | ADC |
---|---|
I0 | ADC0 |
I1 | ADC1 |
I2 | ADC2 |
I3 | - |
G | GND |
VDD | 5V |
The table below summarizes pin positions on the header P13.
Output | Functions |
---|---|
O0 | - |
O1 | - |
O2 | - |
O3 | - |
G | GND |
VDD | 5V |
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. | Command | Parameters | Example | Description |
---|---|---|---|---|
1 | ver | none | ver | Returns firmware Version. |
2 | id | get | id get | Reads Module ID |
set xxxxxxxx | id set 12345678 | Assign ID to the module | ||
3 | info | none | info | Information on Relay and GPIO power-on status |
4 | relay | on xxx | relay on 000 | Control the relays |
off xxx | relay off 000 | |||
read xxx | relay read 000 | Read relay status | ||
poweron xx | relay poweron 01 | Sets Relay power-on value | ||
5 | reset | none | reset | Reset all relays to default state |
6 | gpio | set xxx | gpio set 000 | Control GPOs |
clear xxx | gpio clear 000 | |||
read xxx | gpio read 004 | Read input status | ||
status xxx | gpio status 000 | Read GPO status | ||
poweron xx | gpio poweron 05 | Sets GPO power-on value | ||
7 | adc | read xxx | adc read 001 | Read Analog to Digital Converter input |
The table below has more detailed information about available commands.
No. | Command | Example | Description |
---|---|---|---|
1 | ver | ver | Returns firmware version |
2 | id | id get | Reads the module ID |
id set xxxxxxxx | Assign ID to the module, where ‘x’ can be any alphanumeric character ID should be 8 characters |
||
3 | info | info | Displays the information on Relay power-on status |
4 | relay | relay on xxx | Turn on the relay ‘xxx’. relay on 000 – Turn on Relay 0 xxx can only be 000 |
relay off xxx | Turn off the relay ‘’xxx’. relay off 000 – Turn off Relay 0 xxx can only be 000 |
||
relay read xxx | Read 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 xx | Sets 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 |
||
5 | reset | reset | Reset by turning OFF all relays |
6 | gpio | gpio set xxx | Set GPIO ‘xxx’ output status to high. gpio set 000 – Sets O0 to high state xxx can be 000 to 003 |
gpio clear xxx | Sets GPIO ‘xxx’ output status to low. gpio clear 000 – Sets O0 to low state xxx can be 000 to 003 |
||
gpio read xxx | Read 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 xxx | Read 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 |
||
7 | adc | adc read xxx | Reads 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
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.
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
It 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.
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.