Pages: [1]   Go Down
Author Topic: attiny85 with rf link  (Read 1382 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried to connect an arduino uno with an attiny85 with a rf link at 433 mhz.
The code I write wirk with two atmega328 but if I try a connection with an atmega328 at 16 mhz an attiny85 with internal oscillator 8 mhz nothing work.
Maybe the Oscillator should be the same frequency? Maybe if I will use two attiny85 the connection will work?
I use virtualwire fir atmega328 e virtualwirenewtiny for attiny.
Any suggestion?

« Last Edit: March 03, 2012, 03:36:42 pm by gozilla » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Any suggestion?
Post the code on each end.
Post a wiring diagram on each end.
Post some sample out on each end (if there is any. If there isn't, then add some!).

Without more details, all we can offer is condolences.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code I use for the atmega328 as a receiver is:

Code:
#include <VirtualWire.h>

void setup()
{
   
    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(4800); // Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       // Start the receiver PLL running

pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{
 
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
 
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
int i;

        digitalWrite(13, true); // Flash a light to show received good message
for (i = 0; i < buflen; i++)
{
   
            if(buf[i] == '1'){digitalWrite(8, HIGH);}
       
   
}

        digitalWrite(13, false);

   }
}

And the code for the Attiny85 setted ad Transmitter  is :

Code:
#include <VirtualWireNewTiny.h>

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(4800); // Bits per sec
        vw_set_tx_pin(4);
        
        pinMode(2, INPUT);
      

digitalWrite(2, HIGH);

}

void loop()
{
  char *msg;
  digitalWrite(3, HIGH);
  if(digitalRead(2) == LOW){
    digitalWrite(3, LOW);
    delay(250);
    char *msg = "1";
     vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
}
  }
  

The Schematic connection it's ok, with two atmega320 the code work fine, for the schematic of the attiny85 i use it's internal oscillator setted at 8 mhz.

If you need further information let me know.
I just want to light a led connected on the atmega328 when I press I button on the attiny85, and if work the use two attiny85 and not more atmega328 and attiny85.
Thanks and sorry for my english.
« Last Edit: March 04, 2012, 04:32:24 am by gozilla » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your sender is sending data. Your receiver is sending data. Neither one is reading incoming data. That looks like a problem to me.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your sender is sending data. Your receiver is sending data. Neither one is reading incoming data. That looks like a problem to me.

Sorry, very sorry I edit the post with the right code.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Somebody who is familiar with the ATTiny85, which is NOT an Arduino-supported chip, will have to help you, I think.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Finally work...
I read this post:
http://arduino.cc/forum/index.php/topic,63755.0.html
http://mchr3k-arduino.blogspot.com/2012/01/wireless-sensor-node-part-2.html
And with the Manchester librarie the connection attiny85 TX e atmega328 RX work, the only problem (that isn't really a problem) is that I only be able to send e receive integer values , it's possible to further modify the Manchester librarie to let sending character byte?
Thanks.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the only problem (that isn't really a problem) is that I only be able to send e receive integer values , it's possible to further modify the Manchester librarie to let sending character byte?
A character is just a byte that holds an index into the ASCII table. If you can send ints, you can send characters.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I can send int and then character, but I also have to write code to endcode and decode the character and also have to use send method  many time because int max dimension
Logged

Pages: [1]   Go Up
Jump to: