I have this 433MHz RF Tx and Rx pair. I tried to transmit using following simple Arduino sketch, given in the VirtualWire manual.

#include <VirtualWire.h>
void setup()
  vw_setup(2000); // Bits per sec
void loop()
  const char *msg = "hello";
  vw_send((uint8_t *)msg, strlen(msg));

I've installed VirtualWire Library properly (it's there in Sketch -> import Library). But Arduino IDE gives following errors when trying to verify. It says 'vw_setup' was not declared in this scope

In file included from sketch_sep08a.cpp:1:
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:59: error: variable or field 'vw_set_tx_pin' declared void
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:59: error: 'uint8_t' was not declared in this scope
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:63: error: variable or field 'vw_set_rx_pin' declared void
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:63: error: 'uint8_t' was not declared in this scope
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:67: error: variable or field 'vw_set_ptt_pin' declared void
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:67: error: 'uint8_t' was not declared in this scope
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:71: error: variable or field 'vw_set_ptt_inverted' declared void
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:71: error: 'uint8_t' was not declared in this scope
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:76: error: variable or field 'vw_setup' declared void
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:76: error: 'uint16_t' was not declared in this scope
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:90: error: 'uint8_t' does not name a type
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:98: error: 'uint8_t' does not name a type
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:104: error: 'uint8_t' does not name a type
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:107: error: 'uint8_t' does not name a type
C:\Users\LordXaX\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:112: error: 'uint8_t' does not name a type
sketch_sep08a.cpp: In function 'void setup()':
sketch_sep08a:3: error: 'vw_setup' was not declared in this scope
sketch_sep08a.cpp: In function 'void loop()':
sketch_sep08a:9: error: 'vw_send' was not declared in this scope

Why is that. How to fix this?

This is the content of imported VirtualWire.h

// VirtualWire.h
// Virtual Wire implementation for Arduino
// See the README file in this directory fdor documentation
// Author: Mike McCauley ([email protected])
// Copyright (C) 2008 Mike McCauley
// $Id: VirtualWire.h,v 1.3 2009/03/30 00:07:24 mikem Exp $

#ifndef VirtualWire_h
#define VirtualWire_h

#include <stdlib.h>
#include <wiring.h>

// These defs cause trouble on some versions of Arduino
#undef abs
#undef double
#undef round

// Maximum number of bytes in a message, counting the byte count and FCS

// The maximum payload length

// The size of the receiver ramp. Ramp wraps modulu this number
#define VW_RX_RAMP_LEN 160

// Number of samples per bit

// Ramp adjustment parameters
// Standard is if a transition occurs before VW_RAMP_TRANSITION (80) in the ramp,
// the ramp is retarded by adding VW_RAMP_INC_RETARD (11)
// else by adding VW_RAMP_INC_ADVANCE (29)
// If there is no transition it is adjusted by VW_RAMP_INC (20)
#define VW_RAMP_ADJUST 9

// Outgoing message bits grouped as 6-bit words
// 36 alternating 1/0 bits, followed by 12 bits of start symbol
// Followed immediately by the 4-6 bit encoded byte count, 
// message buffer and 2 byte FCS
// Each byte from the byte count on is translated into 2x6-bit words
// Caution, each symbol is transmitted LSBit first, 
// but each byte is transmitted high nybble first
#define VW_HEADER_LEN 8

// Cant really do this as a real C++ class, since we need to have 
// an ISR
extern "C"
    // Set the digital IO pin to be for transmit data
    // Defaults to 12
    extern void vw_set_tx_pin(uint8_t pin);

    // Set the digital IO pin to be for receive data
    // Defaults to 11
    extern void vw_set_rx_pin(uint8_t pin);

    // Set the digital IO pin to enable the transmitter (press to talk)
    // Defaults to 10
    extern void vw_set_ptt_pin(uint8_t pin);

    // By default the PTT pin goes high when the transmitter is enabled.
    // This flag forces it low when the transmitter is enabled.
    extern void vw_set_ptt_inverted(uint8_t inverted);

    // Initialise the VirtualWire software, to operate at speed bits per second
    // Call this one in your setup() after any vw_set_* calls
    // Must call vw_rx_start() before you will get any messages
    extern void vw_setup(uint16_t speed);

    // Start the Phase Locked Loop listening to the receiver
    // Must do this before you can receive any messages
    // When a message is available (good checksum or not), vw_have_message();
    // will return true.
    extern void vw_rx_start();

    // Stop the Phase Locked Loop listening to the receiver
    // No messages will be received until vw_rx_start() is called again
    // Saves interrupt processing cycles
    extern void vw_rx_stop();

    // Return true if the transmitter is active
    extern uint8_t vx_tx_active();

    // Block until the transmitter is idle
    extern void vw_wait_tx();

    // Block until a message is available
    extern void vw_wait_rx();
    // or for a max time
    extern uint8_t vw_wait_rx_max(unsigned long milliseconds);

    // Send a message with the given length. Returns almost immediately,
    // and message will be sent at the right timing by interrupts
    // Returns true if the message was accepted for transmissions
    // Returns false if the message is too long (>VW_MAX_MESSAGE_LEN - 3)
    extern uint8_t vw_send(uint8_t* buf, uint8_t len);

    // Returns true if an unread message is available
    extern uint8_t vw_have_message();

    // If a message is available (good checksum or not), copies
    // up to *len octets to buf.
    // Returns true if there was a message and the checksum was good
    extern uint8_t vw_get_message(uint8_t* buf, uint8_t* len);

  • 1
    \$\begingroup\$ This is very likely due to incompatibility of the library for Arduino 1.0 vs older version, so you'll need to include the version-specific header files that the library uses. Try this: Open VirtualWire.h and look at the top few lines: You probably see stdlib.h, wiring.h, etc... Reply here with a list of which *.h (header files) you see are included. \$\endgroup\$
    – boardbite
    Sep 8, 2012 at 12:10
  • \$\begingroup\$ @boardbite please see the edited post. I've added whole VirtualWire.h content. Thanks! \$\endgroup\$
    – Anubis
    Sep 8, 2012 at 12:15
  • \$\begingroup\$ Thanks a lot @boardbite You were right!!! I downloaded v1.5. But after what you said I searched and installed latest version, 1.9. It works!!! many thanks!!! \$\endgroup\$
    – Anubis
    Sep 8, 2012 at 12:19
  • 1
    \$\begingroup\$ For your future reference, if there is a library that uses Wiring.h, WProgram.h, etc., you can also use the method outlined in my Answer below. \$\endgroup\$
    – boardbite
    Sep 8, 2012 at 12:21

1 Answer 1


You need to ensure the Arduino VERSION-specific header files that the library needs to use are in fact included. So you can either download the latest version of the library -- perhaps they've already adapted it for the new Arduino version -- or alternatively, you can try this:

At the top of VirtualWire.h, replace:

#include <stdlib.h>
#include <wiring.h>

with this:

#include <stdlib.h>
#if ARDUINO < 100
#include <wiring.h>
#include <Arduino.h>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.