Libreria Virtualwire Arduino
VirtualWire
Copyright (C) 2008-2009
Mike McCauley
Documentation for the VirtualWire 1.3
communications library for Arduino.
1.0 Introduction
Arduino is a low cost microcontroller with Open Source hardware, see http://www.arduino.cc. VirtualWire is a communications library for Arduino that allows multiple Arduino’s to communicate using low-cost RF transmitters andreceivers.
The document describes the VirtualWire library and how to install and use it.
2.0 Overview
VirtualWire is an Arduino library that provides features to send short messages, without
addressing, retransmit or acknowledgment, a bit like UDP over wireless, using ASK
(amplitude shift keying). Supports a number of inexpensive radio transmitters and
receivers. All that is required is transmitdata, receive data and (for transmitters, optionally) a PTT transmitter enable.
It is intended to be compatible with the RF Monolithics (www.rfm.com) Virtual Wire
protocol, but this has not been tested.
Does not use the Arduino UART. Messages are sent with a training preamble, message
length and checksum. Messages are sent with 4-to-6 bit encoding for good DC balance,
and a CRC checksum formessage integrity.
Why not just use the Arduino UART connected directly to the transmitter/receiver? As
discussed in the RFM documentation, ASK receivers require a burst of training pulses
to synchronize the transmitter and receiver, and also requires good balance between 0s
and 1s in the message stream in order to maintain the DC balance of the message.
1 of 13
Overview
UARTs do notprovide these. They work a bit with ASK wireless, but not as well as this
code.
2.1 Supported hardware.
A range of communications hardware is supported. The ones listed blow are available in
common retail outlets in Australian and other countries for under $10 per unit. Many
other modules may also work with this software.
Runs on ATmega8/168 (Arduino Diecimila etc) and ATmega328 andpossibly others.
2.2
Receivers
• RX-B1 (433.92MHz) (also known as ST-RX04-ASK)
FIGURE 1.
RX-B1
Details at http://www.summitek.com.tw/ST_SPEC/ST-RX04-ASK.pdf
2.3
Transmitters:
• TX-C1 (433.92MHz)
2 of 13
VirtualWire
Overview
FIGURE 2.
TX-C1
Details at http://www.tato.ind.br/files/TX-C1.pdf
2.4
Transceivers:
• DR3100 (433.92MHz)
VirtualWire
3 of 13Downloading and installation
FIGURE 3.
DR3100
Details at http://www.rfmonolithics.com/products/data/dr3100.pdf
3.0 Downloading and installation
The latest version of this document is available from
http://www.open.com.au/mikem/arduino/VirtualWire.pdf
Download the VirtualWire distribution from
http://www.open.com.au/mikem/arduino/VirtualWire-1.3.zip
To install, unzip thelibrary to a sub-directory of the hardware/libraries subdirectory of your Arduino application directory. Then launch the Arduino environment;
you should see the library in the Sketch->Import Library menu, and example code in
File->Sketchbook->Examples->Library-VirtualWire menu.
4.0 Function calls
To use the VirtualWire library, you must have
#include
At the top of your sketch.
4 of 13VirtualWire
Function calls
4.1 vw_set_tx_pin
extern void vw_set_tx_pin(uint8_t pin);
Set the digital IO pin to use for transmit data. Defaults to 12.
4.2 vw_set_rx_pin
extern void vw_set_rx_pin(uint8_t pin);
Set the digital IO pin to use for receive data. Defaults to 11.
4.3 vw_set_ptt_pin
extern void vw_set_ptt_pin(uint8_t pin);
Set the digital IO pin to use to enable thetransmitter (press to talk). Defaults to 10. Not
all transmitters require PTT. The DR3100 does, but the TX-B1 does not.
4.4 vw_set_ptt_inverted
extern void vw_set_ptt_inverted(uint8_t inverted);
By default the PTT pin goes high when the transmitter is enabled. This flag forces it low
when the transmitter is enabled. Required for the DR3100.
4.5 vw_setup
extern void vw_setup(uint16_t speed);...
Regístrate para leer el documento completo.