RF Transmitter and Receiver using attiny85

Hi,

I'm using these cheap rf transmitter/receiver pair:

with attiny85 for my project and wanting to get serial output from it.

I was able to read and display the transmitted values in serial monitor fine with the atmega328 using the RCswitch library, but with the attiny using the Manchester library, I'm getting gibberish.

RCswitch library: GitHub - r10r/rcswitch-pi: RCSwitch implementation for the Raspberry Pi
Manchester library: GitHub - mchr3k/arduino-libs-manchester

The receiver has 4 pins, the center two are data pins. I don't know whether they are data in or out, so if anyone know, please help with that. But basically, on the atmega328, I hooked one of those pins to pin #2 and the other to pin #0 (Rx pin) and was able to get output. It seems you need both pins hooked up like that to get output. If either pins are taken out, serial displays nothing.

On the attiny, I hooked one of the pin to the designated receiving pin #2 and the other pin to a UART usb Rx pin and am getting blinking lights which means it's receiving, but serial output is gibberish while the transmitter transmit every 2 seconds. Every 2 seconds, the receiving LED on the UART stays solid for a second and then goes back to blinking.

I just want to know if anyone successfully got serial output using these rf modules with the attiny85. Thanks.

Maybe this will help

http://forum.arduino.cc/index.php?topic=149928.0

Nice! I love these cheap radios, but working with them I've found that with ASK some of the cheap chinese manufacturers don't always stick to the protocol, so it almost always involves a little discovery. 3 pin chips on 433mhz usually have a Data, +5v (or however many volts via spec sheet), and GND. Some of the 4 pin ones are organized such that you have VCC, VT, GND, 10 (being your data line),(4 total pins). I find this layout to be the most common; same as previous, with the addition of 11, 12, 13, making a total of 4 channel radio (and 6 total pins). SOME radios support a type of encryption, which requires power on both VCC (obviously) and VT. As to your specific radio I would see if that fourth pin is an antenna output, (I've seen them do this a lot recently, cheaper than giving you an antenna onboard and smaller pcb as well). :astonished:

Just some stuff to think about during your troubleshooting, sorry I can't be of more help!

@Erni - Thanks for the link, but I've already read over it before making this post and the answer I'm looking for wasn't in there.

@RobertMcCabe784 - There's actually an antenna hole in addition to the 4 pins shown. So I'm guessing one is data in and the other is data out. I don't know what VT stands for.

bradley:
Hi,

I'm using these cheap rf transmitter/receiver pair:

with attiny85 for my project and wanting to get serial output from it.

I was able to read and display the transmitted values in serial monitor fine with the atmega328 using the RCswitch library, but with the attiny using the Manchester library, I'm getting gibberish.

RCswitch library: GitHub - r10r/rcswitch-pi: RCSwitch implementation for the Raspberry Pi
Manchester library: GitHub - mchr3k/arduino-libs-manchester

The receiver has 4 pins, the center two are data pins. I don't know whether they are data in or out, so if anyone know, please help with that. But basically, on the atmega328, I hooked one of those pins to pin #2 and the other to pin #0 (Rx pin) and was able to get output. It seems you need both pins hooked up like that to get output. If either pins are taken out, serial displays nothing.

On the attiny, I hooked one of the pin to the designated receiving pin #2 and the other pin to a UART usb Rx pin and am getting blinking lights which means it's receiving, but serial output is gibberish while the transmitter transmit every 2 seconds. Every 2 seconds, the receiving LED on the UART stays solid for a second and then goes back to blinking.

I just want to know if anyone successfully got serial output using these rf modules with the attiny85. Thanks.

Hey Bradley, did you ever get this to work? I'm using exactly the same hardware and trying to get the Attiny85 to transmit to a UNO.

I'm seeing some pretty weird behaviour out of the tiny. I've cut my ATtiny code back to simply modulating pin 0 LOW, HIGH, LOW, HIGH, LOW, HIGH etc 48 times, holding each state for 500 microseconds and looking at what I get back in the UNO. So far I can't match the ATtiny output with the input I see on the UNO.

Did you get it to work?....

I'm seeing some pretty weird behaviour out of the tiny. I've cut my ATtiny code back to simply modulating pin 0 LOW, HIGH, LOW, HIGH, LOW, HIGH etc 48 times, holding each state for 500 microseconds and looking at what I get back in the UNO. So far I can't match the ATtiny output with the input I see on the UNO.

I recently did something similar to what you are doing but I did do it successfully. Hopefully i can explain it well enough now.

What I did was create a High check on the Attiny85, where the microcontroller would look for the receiving pin to stay high for an x amount of microseconds and if it does an LED will blink to show it was successful. Since the arduino UNO is easier to program I would then create a program to move the transmitter pin high for as short of a period as I can.

I then did a low check on the attiny using the same process as i did with the high check. First program the attiny and then change the delay times on the arduino uno. You can have as many outcomes as you want with this. The code i used is posted below.
It may take some thinking and time to build the program for whatever your using it for.Hope my process somewhat helped

// attiny code built to carry out 2 commands based on signal recieved
int g=0;
int t;
// 2 rf module
// 1 light 1
// 0 piezo buzzer
// 3 led 2

void setup(){
  pinMode(2,INPUT);
  pinMode(1,OUTPUT);
  pinMode(0,OUTPUT);
  
  for (int i=0;i<5;i++){
    digitalWrite(1,HIGH);
    delay(20);
    digitalWrite(1,LOW);
    delay(10);
  }
}

void loop(){
  if (digitalRead(2)==HIGH){// high check
    g=1;
    for (int i=0;i<8;i++){
    delayMicroseconds(58);
    if (digitalRead(2)==LOW){
      g=0; i=8;}// if it drops low stop
    }
    
    if (g==1){
     delayMicroseconds(250);
     if (digitalRead(2)==LOW){// low check
       g=1;}
     else{g=0;} // did not pass check
    }
    
    t=0;
    
     if (g==1){
       for (int i=0;i<2;i++){//last high check to choose option
         delayMicroseconds(450);
         if(digitalRead(2)==HIGH){
           t=t+1;}
       }
    if(t==1){ // command 1
   for(int i=0;i<7;i++){
    for (int p=0;p<5000;p++){
      digitalWrite(0,HIGH);
      delayMicroseconds(5);
      digitalWrite(0,LOW);
      delayMicroseconds(5);
    }
    digitalWrite(1,HIGH);
    delay(40);
    digitalWrite(1,LOW);
  }
}else if(t==2){// command 2
  for (int i=0;i<20;i++){
    digitalWrite(1,HIGH);
    delay(20);
    digitalWrite(1,LOW);
    delay(10);
  }
   }
    }
}
}

I think this is the program that matches up with the receiving program... my computer isn't to organized, Sorry

// arduino uno program
char input;

void setup(){
  pinMode(2,OUTPUT);
  pinMode(13,OUTPUT);
  Serial.begin(9600);
}
void loop(){
 if (Serial.available() > 0){
   char input = (char) Serial.read();
   if ((char)input == '1'){
  digitalWrite(13,HIGH);// light on 
  digitalWrite(2,HIGH);//high check
  delayMicroseconds(5000);
  digitalWrite(2,LOW);//low check
  delayMicroseconds(1250);
  digitalWrite(2,HIGH); //high check
  delayMicroseconds(5000);
  digitalWrite(2,LOW);
  digitalWrite(13,LOW);// light off
  delay(500);
  Serial.println("Option 1");
}else if ((char)input == '2'){
  digitalWrite(13,HIGH);
  digitalWrite(2,HIGH);
  delayMicroseconds(5000);
  digitalWrite(2,LOW);
  delayMicroseconds(1250);
  digitalWrite(2,HIGH);
  delayMicroseconds(10000);
  digitalWrite(2,LOW);
  digitalWrite(13,LOW);
  delay(500);
  Serial.println("Option 2");
}else if ((char)input == '3'){
  digitalWrite(13,HIGH);
  digitalWrite(2,HIGH);
  delayMicroseconds(5000);
  digitalWrite(2,LOW);
  delayMicroseconds(1250);
  digitalWrite(2,HIGH);
  delayMicroseconds(15000);
  digitalWrite(2,LOW);
  digitalWrite(13,LOW);
  delay(500);
  Serial.println("Option 3");
}else    if ((char)input == '4'){
  digitalWrite(13,HIGH);
  digitalWrite(2,HIGH);
  delayMicroseconds(5000);
  digitalWrite(2,LOW);
  delayMicroseconds(1250);
  digitalWrite(2,HIGH);
  delayMicroseconds(20000);
  digitalWrite(2,LOW);
  digitalWrite(13,LOW);
  delay(500);
  Serial.println("Option 4");
}else    if ((char)input == '5'){
  digitalWrite(13,HIGH);
  digitalWrite(2,HIGH);
  delayMicroseconds(5000);
  digitalWrite(2,LOW);
  delayMicroseconds(1250);
  digitalWrite(2,HIGH);
  delayMicroseconds(25000);
  digitalWrite(2,LOW);
  digitalWrite(13,LOW);
  delay(500);
  Serial.println("Option 5");
}else    if ((char)input == '6'){
  digitalWrite(13,HIGH);
  digitalWrite(2,HIGH);
  delayMicroseconds(5000);
  digitalWrite(2,LOW);
  delayMicroseconds(1250);
  digitalWrite(2,HIGH);
  delayMicroseconds(30000);
  digitalWrite(2,LOW);
  digitalWrite(13,LOW);
  delay(500);
  Serial.println("Option 6");
}
 }
}