VirtualWire and SoftwareSerial

Hi,
I'm currently trying to control some Neopixels with a 433Mhz transmitter and the Virtualwire-Library. Both libraries are not working together due to the usage of the timers by both libraries.

My plan is to use a Attiny85 as receiver for the 433 Mhz signal. The received message should be sent with the SoftwareSerial library to an Arduino Uno that is connected to the Neopixels.

But it looks like the Software Serial-library and the Virtual Wire-library are not working together as well.
My first attempt is to send the message 1:1 to the Arduino Uno everytime it is received. The Arduino Uno does not receive anything. Here is my Attiny85-Code:

#include <VirtualWire.h>

#include <SoftwareSerial.h>
SoftwareSerial mySerial(99,4);

bool message_received = false;

unsigned long T1 = 0;

#define rxPin 3
//#define receive_pin 1


void setup() {
  vw_setup(2000);   // Bits per sec
  vw_set_rx_pin(rxPin);
  vw_rx_start();       // Start the receiver PLL running
  
  mySerial.begin(9600);
}

void loop() 
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t bufleng = sizeof(buf);

  if (vw_get_message(buf, &bufleng)) // Non-blocking
  {
    int i;
    char Str[bufleng];
    for (i=0;i<bufleng;i++)
    {
      char letter = char(buf[i]);
      Str[i] = letter;          
    }
    message_received = true;
    mySerial.println(Str);
  }
}

Does anybody find an error in the code or is there a alternative solution?

Thanks for your help!
Ben

Same problem. Software serial wants to use the timer that VirtualWire is using.

VirtualWire can be configured to use a different timer.

...or you could use NeoSWSerial, since it doesn't require an additional timer. It just uses the pre-existing millis() timer (i.e., Timer0). That limits it to 9600, 19200 or 38400 baud. Your sketch uses 9600, so NeoSWSerial is an option. It's much more efficient, and it can send and receive at the same time. SoftwareSerial blocks interrupts for so long that it can prevent other devices from working.

Cheers,
/dev

The NeoSWSerial-Library sounds very good but unfortunately it seems not to work on an Attiny85.
(Failure message:

C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp: In member function 'void NeoSWSerial::listen()':
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:124:5: error: 'TCCR2A' was not declared in this scope
TCCR2A = 0x00;
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:125:5: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0x03; // divide by 32
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp: In static member function 'static void NeoSWSerial::rxISR(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:31:17: error: 'TCNT2' was not declared in this scope
#define TCNTX TCNT2
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:268:16: note: in expansion of macro 'TCNTX'
uint8_t t0 = TCNTX; // time of data transition (plus ISR latency)
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp: In member function 'bool NeoSWSerial::checkRxTime()':
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:31:17: error: 'TCNT2' was not declared in this scope
#define TCNTX TCNT2
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:343:28: note: in expansion of macro 'TCNTX'
uint8_t t0 = TCNTX; // now
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp: In member function 'virtual size_t NeoSWSerial::write(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:31:17: error: 'TCNT2' was not declared in this scope
#define TCNTX TCNT2
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:480:18: note: in expansion of macro 'TCNTX'
uint8_t t0 = TCNTX; // start time
^
C:\Program Files (x86)\Arduino\libraries\NeoSWSerial-master\NeoSWSerial.cpp:505:13: error: 'PCIFR' was not declared in this scope
if (PCIFR & PCIbit) {
^
Fehler beim Kompilieren.

Oops, I've tried lots of AVRs but not the ATtiny85. I'll take a look...

NeoSWSerial uses Timer2 if FCPU is 8MHz - it would have to use Timer1 on the ATtiny85. What is your CPU speed?

Thanks,
/dev

I'm using 8Mhz internal.
Which AVR did you try?