Hello,
I am trying to interface ATtiny85 with the cheap 433 MHz radio receiver & transmitter pair:
The ATtiny is connected to receiver, Arduino UNO is connected to transmitter.
The problem is:
Arduino transmits the data, but ATtiny isn’t responding to it (the led doesn’t light up). I tried to use the newest version of VirtualWire library, but ATtiny doesn’t have Timer1. The older version of VirtualWire compiles fine. The newest version of Manchester library too. But any of them doesn’t work for my ATtiny receiver. Can anybody help me with the problem?
The code I use for VirtualWire:
Transmitter:
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
Serial.begin(9600); // Debugging only
pinMode(13, OUTPUT);
pinMode(3, OUTPUT);
// Initialise the IO and ISR
vw_set_tx_pin(3);
vw_setup(2000); // Bits per sec
}
void loop()
{
char msg[2];
msg[0] = 0x00;
msg[1] = 0xFF;
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);
}
Receiver:
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
// Initialise the IO and ISR
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, INPUT);
vw_set_tx_pin(4);
vw_set_rx_pin(2);
vw_set_ptt_pin(3);
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
digitalWrite(3, true); // Flash a light to show received good message
if (buf[0] == 0x00) {analogWrite(0, buf[1]);}
if (buf[0] == 0x01) {analogWrite(1, buf[1]);}
digitalWrite(3, false);
}
}
Manchester Transmitter:
#include <Manchester.h>
#define TX_PIN 3 //pin where your transmitter is connected
uint16_t transmit_data = 2761;
void setup() {
man.setupTransmit(TX_PIN, MAN_1200);
}
void loop() {
man.transmit(transmit_data);
delay(200);
}
Receiver:
#include <Manchester.h>
#define RX_PIN 4 //= pin 6
void setup()
{
pinMode(0, OUTPUT);
pinMode(RX_PIN, INPUT);
man.setupReceive(RX_PIN, MAN_1200);
man.beginReceive();
}
void loop() {
if (man.receiveComplete()) {
uint16_t m = man.getMessage();
digitalWrite(0, HIGH);
delay(100);
digitalWrite(0, LOW);
man.beginReceive(); //start listening for next message right
}
}
Can you help me ASAP (I must have that done this Monday)??? Thanks in advance!
kuba2k2
libraries.zip (29.6 KB)