Virtual Wire: Array length limitation?

Hello!
I've been working a little with virtual wire lately, and the other day occurred to me that the vw_send() function won't work if I try to transmit arrays with more than 27 elements on my Mega 2560 or Leonardo. If I for example use this code, using pin 13 as transmission pin (meaning it will blink rapidly when sending something), it will just work fine - but as soon as I exceed an element amount of 27 it just won't transmit. Is this some kind of built in limitation or am I possibly messing something up?

Thanks for any help :slight_smile:

#include <VirtualWire.h>

int transmitpin = 13;
int switchpin = 2;
int switchpinvalue = 0;
boolean Display_Array[27];

void setup () {
  

  pinMode(switchpin,INPUT);
  pinMode(transmitpin,OUTPUT);
  vw_set_tx_pin(transmitpin);
  vw_setup(2000); 
  Serial.begin(9600);
}

void loop () {
  switchpinvalue = digitalRead(switchpin);

 if(switchpinvalue) { //pressing button starts transmission 
    vw_send((boolean *)Display_Array,27); //works fine with an array size of 27
    vw_wait_tx();
}
}

Is this some kind of built in limitation

Have you looked at the source code for the library. I seem to recall that yes there is a limit and that the limit is 32 characters. I could be mistaking that for something else, though, so look at the source code.

This is the website for VirtualWire : http://www.airspayce.com/mikem/arduino/
At the bottom is a pdf file for explanation. There is only 1 pdf file.
In that pdf file it says: "Messages of up to VW_MAX_PAYLOAD (27) bytes can be sent"

It is better to sent compressed short data than raw larger data. The chance for noise distortion is less with shorter messages.

Do you want to transmit display data, like 2 * 16 characters ?
You could change the library, or send 17 bytes per transmission (16 + 1, since an extra byte is needed to indicate the row).

Erdin:
This is the website for VirtualWire : http://www.airspayce.com/mikem/arduino/
At the bottom is a pdf file for explanation. There is only 1 pdf file.
In that pdf file it says: "Messages of up to VW_MAX_PAYLOAD (27) bytes can be sent"

It is better to sent compressed short data than raw larger data. The chance for noise distortion is less with shorter messages.

Do you want to transmit display data, like 2 * 16 characters ?
You could change the library, or send 17 bytes per transmission (16 + 1, since an extra byte is needed to indicate the row).

I checked the source code but I really couldn't figure it out, thanks for finding this!
I actually don't want to send characters at all, but rather a larger number of boolean values to control some LEDs. This is the stupid part of virtualwire - you can only send whole bytes. I guess I could write my own transmition/receiving program since it is only boolean values... I will however have a go at dividing the transmission up into smaller parts first, VW is so easy to use!

cheers

VirtualWire sends bytes, but those bytes can be anything: floating point, characters, integers, booleans, everything.
Using bytes is very common to be able to send any type of data.
The most simple way is to use an array of bytes, but also a structure or union can be used.

There are many ways to convert booleans into bytes.

How is your sketch ? How are the booleans declared ? and how are they used ?

Yes I know they can be anything, but using a whole byte to store a boolean seems like a waste, especially when I have this data limitation on the transmitions!
I've had no problems converting the booleans into bytes and the other way, it's just that I now want to send larger amounts of data. It is a POV display I am working with, 16 LEDs. Earlier I just sent characters from one stationary arduino to a rotating one, where the rotating (and receiving one) would have the code ready for each letter. Now I have made a Windows interface in Java where you're supposed to be able to control every individual pixel on the display which means I need to handle quite a lot more data - say about 16 x 100 boolean values! This information gets uploaded to the stationary board and is then supposed to be sent to the rotating one. It worked just fine until I realized VW was limited like that, he he. But, like I said I think I'll try doing several separate transmissions instead. Thanks for helping :slight_smile:

/Oskar

16 * 100 bit = 200 byte.
I don't know if the VirtualWire transmission is okay with 200 bytes at once. Using 10 seperate transmissions of 20 bytes should do it.

An array of 200 bytes is okay for the Arduino Uno, using an array of 1600 byte is not okay.

Take a look at these:

http://arduino.cc/en/Reference/BitWrite

There are many ways to convert booleans into bytes.

booleans ARE bytes. No conversion necessary.

Okay, a variable 'boolean' is actually a byte as defined by the compiler.
I ment this: There are many ways to convert eight bits (eight logical states, or eight 0/1 or eight false/true) into bytes.