Attiny85 Virtual wire problem

Hi! I copied this sketch somewhere it works on atmega328 but not on Attiny85. Im using this just to test if my rf433 is working.
I uploaded this to Attiny85 without any problems but it's not working. all the wirings are correct(checked it 1000x lol). virtualwire version is updated. Do I need other libraries to work on Attiny85? I already googled but no luck. Thanks!

when I press a button on tx the led on rx should light. works on atmega328 not on attiny :frowning:

#include <VirtualWire.h>

int button = 0 ; //
//int button2 = 1;
int buttonValue;
//int button2Value;

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

    // Initialise the IO and ISR
 //   vw_set_ptt_inverted(true);
    vw_setup(2000);	 // Bits per sec
    vw_set_tx_pin(1); 
        
    pinMode(button, INPUT);
//    pinMode(button2, INPUT);
   digitalWrite(button, HIGH);
//   digitalWrite(button2, HIGH);


}

void loop()
{
  buttonValue = digitalRead(button);
//  button2Value = digitalRead(button2);
  char *msg;
//First Button  
  if(buttonValue == LOW){ //Button Pressed = LOW
    char *msg = "1"; //Button pressed
    vw_send((uint8_t *)msg, strlen(msg)); // send "1" to receiver.
    vw_wait_tx(); // Wait until the whole message is gone
  }
  if(buttonValue == HIGH){ //Button Released
  char *msg = "A"; //button released
  vw_send((uint8_t *)msg, strlen(msg));
   vw_wait_tx(); // Wait until the whole message is gone
 //Second Button 
  }
}
/*  if(button2Value == LOW) { //Button Pressed
    char *msg = "2";// button2 pressed
    vw_send((uint8_t *)msg, strlen(msg)); // send "2" to receiver.
    vw_wait_tx(); // Wait until the whole message is gone
  }
  if(button2Value == HIGH) { //Button Released
    char *msg = "B";// button2 Released
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
}
} 
*/
 #include <VirtualWire.h>

int led = 2;

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
    vw_set_rx_pin(1);
    vw_rx_start();       // Start the receiver PLL running

   pinMode(led, OUTPUT);
 //  pinMode(led2, OUTPUT);
}

void loop() {
  

    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;
	
     for (i = 0; i < buflen; i++) {
	
   if(buf[i] == '1') {
     digitalWrite(led, HIGH);
}
   if(buf[i] == 'A') {
     digitalWrite(led, LOW);
}      
   if(buf[i] == '2') {
//      digitalWrite(led2, LOW);
}
   if(buf[i] == 'B') {
 //     digitalWrite(led2, HIGH);
}
}
}
}

Always use the original newest library.
http://www.airspayce.com/mikem/arduino/

How about the number of bits per second ?
Are you sure the receiver and transmitter are set to the actual cpu speed and the same bits per second for the Virtual Wire library ?

Caltoa:
Always use the original newest library.
http://www.airspayce.com/mikem/arduino/

How about the number of bits per second ?
Are you sure the receiver and transmitter are set to the actual cpu speed and the same bits per second for the Virtual Wire library ?

Thanks for the reply! I'm newb at this, what do you mean by actual cpu speed?

At what speed is the ATtiny85 running ?
How do you upload sketches to it ?

If for example the sketche assumes that the ATtiny is running at 16 MHz, but actually it is running at 8 MHz, the bit rate for the Virtual Wire would be wrong.
I wrote 'cpu speed', perhaps I should have written 'the clock speed of the microcontroller'.

The internal RC oscillator for the ATtiny85 is not very accurate, perhaps you have to lower the bit rate to 1000 bits per second.

I chose attiny85 1MHz board to upload the sketch. I'm gonna change virtualwire to 1000, see if it'll work. Thanks!

Caltoa:
At what speed is the ATtiny85 running ?
How do you upload sketches to it ?

If for example the sketche assumes that the ATtiny is running at 16 MHz, but actually it is running at 8 MHz, the bit rate for the Virtual Wire would be wrong.
I wrote 'cpu speed', perhaps I should have written 'the clock speed of the microcontroller'.

The internal RC oscillator for the ATtiny85 is not very accurate, perhaps you have to lower the bit rate to 1000 bits per second.

I lowered virtualwire to 1000 bits per sec and uploaded with attiny85 1 Mhz but still not working. Also tried uploading attiny85 8Mhz, and virtualwire to 2000 , not working :frowning:

I don't know what to do.
There are still a few things you can try.

Capture the receiving or transmitting signal with a storage scope. You can also use the audio_in with attenuator of a computer with Audacity.

Capture the RF signal with SDR.
You need a dongle of about 15 to 20 dollars, and you can tune to the 433MHz

If you have a receiver and transmitter that works, you should be able to determine where the differences with the ATtiny85 are.
Can you make the ATtiny85 flash a led every seconds ? and check if that is a second and not faster or slower ?

Caltoa:
I don't know what to do.
There are still a few things you can try.

Capture the receiving or transmitting signal with a storage scope. You can also use the audio_in with attenuator of a computer with Audacity.
http://audacity.sourceforge.net/

Capture the RF signal with SDR.
You need a dongle of about 15 to 20 dollars, and you can tune to the 433MHz
Getting Started With Software Defined Radio | Hackaday

If you have a receiver and transmitter that works, you should be able to determine where the differences with the ATtiny85 are.
Can you make the ATtiny85 flash a led every seconds ? and check if that is a second and not faster or slower ?

Thanks for your time. You are sure that attiny85 works with virtualwire without any other libraries or mods?

Yes, if you use the newest VirtualWire.

Here is another thread over 2 pages, you can scroll through that:
http://forum.arduino.cc/index.php?topic=186143.0

P.S.: You can click 'Reply', there is no need to 'Quote' my message, since it is already there.