Pages: [1] 2 3   Go Down
Author Topic: Virtual wire help  (Read 9728 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27114
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used Virtualwire before, am trying to get it working again in 1.0.1.

I've copied the Virtualwire library into the c:\Arduino-1.0.1\libraries folder,
and checked Sketch:Import Library:VirtualWire was showing up

When I compile the sample Tx sketch I get these errors.
Code:
// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);   // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000); // Bits per sec
}

void loop()
{
    const char *msg = "hello";

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(200);
}
Compiling yields this
Code:
C:\Arduino-1.0.1\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -IC:\Arduino-1.0.1\hardware\arduino\cores\arduino -IC:\Arduino-1.0.1\hardware\arduino\variants\standard -IC:\Arduino-1.0.1\libraries\VirtualWire C:\Users\Owner\AppData\Local\Temp\build2811771902139116391.tmp\sketch_aug18a.cpp -o C:\Users\Owner\AppData\Local\Temp\build2811771902139116391.tmp\sketch_aug18a.cpp.o
In file included from sketch_aug18a.cpp:11:
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:14:20: warning: wiring.h: No such file or directory
In file included from sketch_aug18a.cpp:11:
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:59: warning: 'vw_set_tx_pin' initialized and declared 'extern'
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:59: error: variable or field 'vw_set_tx_pin' declared void
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:59: error: 'uint8_t' was not declared in this scope
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:63: warning: 'vw_set_rx_pin' initialized and declared 'extern'
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:63: error: variable or field 'vw_set_rx_pin' declared void
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:63: error: 'uint8_t' was not declared in this scope
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:67: warning: 'vw_set_ptt_pin' initialized and declared 'extern'
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:67: error: variable or field 'vw_set_ptt_pin' declared void
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:67: error: 'uint8_t' was not declared in this scope
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:71: warning: 'vw_set_ptt_inverted' initialized and declared 'extern'
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:71: error: variable or field 'vw_set_ptt_inverted' declared void
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:71: error: 'uint8_t' was not declared in this scope
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:76: warning: 'vw_setup' initialized and declared 'extern'
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:76: error: variable or field 'vw_setup' declared void
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:76: error: 'uint16_t' was not declared in this scope
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:90: error: 'uint8_t' does not name a type
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:98: error: 'uint8_t' does not name a type
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:104: error: 'uint8_t' does not name a type
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:107: error: 'uint8_t' does not name a type
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:112: error: 'uint8_t' does not name a type
sketch_aug18a.cpp: In function 'void setup()':
sketch_aug18a:18: error: 'vw_set_ptt_inverted' was not declared in this scope
sketch_aug18a:19: error: 'vw_setup' was not declared in this scope
sketch_aug18a.cpp: In function 'void loop()':
sketch_aug18a:27: error: 'vw_send' was not declared in this scope

This line seems to be the start of the problem:
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:14:20: warning: wiring.h: No such file or directory

however,
C:\Arduino-1.0.1\libraries\VirtualWire\VirtualWire.h is definitely there.

I closed the IDE down, restarted, no help. What am I doing wrong?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 187
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

if you look closely it's not about the virtualwire lib, but about the wiring lib (wiring.h) that is not present somewhere

Quote
C:\Arduino-1.0.1\libraries\VirtualWire/VirtualWire.h:14:20: warning: wiring.h: No such file or directory
Logged


UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In version 1 of the IDE, the standard include files were renamed. This means you will either need to change the #include statements, or provide your own .h that includes the new ones.

(Yeah, it strikes me as a monumentally daft thing to do too, but I imagine there must have been some reason for it.)
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27114
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried this change from the release notes.  Same errors, don't think I have quite the right approach yet...
Code:
//#include <Wire.h>

#include <VirtualWire.h>   // Wireless transmitter/receiver library

  #if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
  #else
  #include "WProgram.h"
  #endif


// RF Link Transmitter - Sparkfun MO-SAWR-A, 434MHz, WRL-08946

// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with RF module.

// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

// uses default pin 12 for transmit data
// uses default pin 11 for receive data

// end of notes
// ***********************************************************************

byte ledPin = 13;
// create an array to store data to be sent out
char msg[10]; // extra char added for address

byte analogvalue1;
byte analogvalue2;
byte analogvalue3;
byte analogvalue4;

// ***********************************************************************
// set up the pins as Inputs, Outputs, etc.
void setup()
{
  /* Setup the pin directions, write inputs High to turn on internal pullups */
  pinMode (ledPin, OUTPUT);

  // Initialise the IO and ISR for VirtualWire
  vw_setup(2000);                       // Bits per sec

}                                            // end of void Setup()

// ***********************************************************************
// Main loop for reading the keypad and sending the button pushed out
// (with a unique address to be added eventually by reading 0-F from currently unused pins)

void loop()
{
  // add your code here to read in the 4 analog values
  //
  //

  // now put the data into an array with a couple of sync bytes

  msg[0] = 'b';
  msg[1] = 4;
  msg[2] = highByte (analogvalue1);
  msg[3] = lowByte (analogvalue1);
  msg[4] = highByte (analogvalue2);
  msg[5] = lowByte (analogvalue2);
  msg[6] = highByte (analogvalue3);
  msg[7] = lowByte (analogvalue3);
  msg[8] = highByte (analogvalue4);
  msg[9] = lowByte (analogvalue4);

  digitalWrite(ledPin, true);               // Flash a light to show transmitting

  vw_send((uint8_t *)msg, strlen(msg));     // send the character out

  vw_wait_tx();                             // Wait until the whole message is gone

  digitalWrite(ledPin, false);              // turn off the flash of LED

}                                             // end of void loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27114
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bump
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can't look myself; I'm still at 0022, but it appears to me that in VirtualWire.h, there's a #include wiring.h.
Logged

... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi CrossRoads,
I just downloaded the latest Virtualwire library from here http://www.open.com.au/mikem/arduino/ and it compiled without problem in 1.0.1
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27114
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, just downloaded rev 1.9.

I see this was added:
Code:
#if (ARDUINO < 100)
#include "WProgram.h"
#endif
#include "VirtualWire.h"
#include <util/crc16.h>

so I'll go back to my experiment again.

Edit:
Confirmed, that solved it. Oddly, I couldn't just rename the existing virtualwire to virtualwire_old, and have the new virtualwire in the same arduino/libraries folder. 1.0.1 kept pulling files from \virtualwire-old!  Must be a benefit of only compiling the unchanged code.
Deleting the old folder took care of it.
« Last Edit: August 20, 2012, 11:16:17 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1925
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I couldn't just renanem the existing virtualwire to virtualwire_old, and have the new virtualwire in the same arduino/libraries folder. 1.0.1 kept pulling files from \virtualwire-old!

Hi Robert... I got burned with that same old/new library thing; wasted hours..

It's SUPPOSED to be possible to delete the compiled library code, but what/where???
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It's SUPPOSED to be possible to delete the compiled library code, but what/where???
That's a question I would also like to know the answer for. I have also had problems with updating libraries and finding they still show the same errors.
Logged


CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I couldn't just renanem the existing virtualwire to virtualwire_old, and have the new virtualwire in the same arduino/libraries folder. 1.0.1 kept pulling files from \virtualwire-old!

Hi Robert... I got burned with that same old/new library thing; wasted hours..

It's SUPPOSED to be possible to delete the compiled library code, but what/where???

Interesting. I haven't dug into the depths of the IDE, but yeah, you'd think there's some sort of make-like functionality someplace.

You back from Italy now?
Logged

... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You back from Italy now?
Who me?
Logged


Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1925
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You back from Italy now?
Who me?

OH: Me... 

Yes I am 'permanently' back home in rural Vermont USA after 8 great years in which my wife designed/ran libraries in International schools in Africa, China, Saudi Arabia and Italy and I did electronics/Arduino and online Educational stuff (http://arduinoinfo.info)

We had a great experience, met many wonderful people who were very much (As they say in Vermont) "Not From Around Here".  A shepherd grazing goats in the ruins of a Roman era city in North Africa, Berber kids running barefoot through the Sahara, 86 year old Chinese farmer working in the fields every day, Chinese kid with a mohawk in a downtown disco, Saudi Electrical Engineering professor with 3 wives, Italian woman teaching kids Arduino Sumo robots on the second floor of an old palace in Italy. Wow.  Couple Photos:
http://goo.gl/Fxi5q     http://goo.gl/YWnkQ    http://goo.gl/ybg2o   http://goo.gl/Bpfx5

I loved China, especially the rural villages. The Shenzhen Electronics Marketplace is awesome: 900 shops in one building and 1000 more within 5 km. My Chinese friend Jun Peng and I started Yourduino.com to sell parts that we could give great prices on. The secret to getting the best price in the world: Be friendly, speak Chinese, walk into the shop or factory with RMB Cash in your hand. Negotiate.  Big companies with purchase orders can never get that price  smiley 

Now.. where the heck is the pre-compiled part of a library??? I HEARD about this. I'll keep looking...

And I really appreciate this Community and you people who have been with me online, from everywhere!

Regards, Terry King  ...In The Woods in Vermont, USA
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Geez Terry

What an experience, I want to do that, but where do you find such a wife ?

No,   back to the topic that Bob raised,  I was tempted to look at upgrading to v1.whatever,  I put it off because of the initial hassles with libraries , that I felt were out of my depth.

I have been busy 24/7 for the last few months, but nearly caught up , so I was going to check through the forum to see if the migration ( from 23 to 0.1 ) had been sweetened, but now I am even more wary if you experienced guys are getting hassles .

Why can't they leave well alone, if it ain't broke dont fix it !   ...................

Or perhaps its a case of teaching an old dog new tricks  :-(
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27114
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Virtualwire was solved easily enough - I just removed the old folder.

The new one addresses this stuff from the 1.0 release notes.

http://arduino.cc/en/Main/ReleaseNotes

I imagine other popular 'user' libraries have been updated also.

Code:
* The WProgram.h file, which provides declarations for the Arduino API,
  has been renamed to Arduino.h. To create a library that will work in
  both Arduino 0022 and Arduino 1.0, you can use an #ifdef that checks
  for the ARDUINO constant, which was 22 and is now 100.  For example:

  #if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
  #else
  #include "WProgram.h"
  #endif
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1] 2 3   Go Up
Jump to: