Problem with serial communication from Tiny84 to Arduino

Hello,

I'm quite new to Arduino and co. Now I wanted to test SoftwareSerial for the communication of ATtiny84 and Arduino Uno.

On tiny84 I did (with 8MHz clock):

#include <SoftwareSerial.h>

int rxPin    = 10;
int txPin    =  0; 

SoftwareSerial mySerial(rxPin,txPin);

void setup() 
{                
  pinMode(txPin,  OUTPUT);     
  pinMode(rxPin,  INPUT);       
  
  mySerial.begin(9600);
}

void loop() 
{
  mySerial.println("Hello, world?");
}

and on Arduino the code is:

#include <SoftwareSerial.h>
int rxPin    =  10;
int txPin    =  8;

SoftwareSerial mySerial(rxPin,txPin);

void setup()
{
  Serial.begin(9600);

  pinMode(txPin, OUTPUT);     
  pinMode(rxPin, INPUT);    
  
  mySerial.begin(9600);
}

void loop()
{
  char c;
  int cnt = 0;
  
  if(mySerial.available())
  {
    while(mySerial.available() && cnt < 80)
    {
      cnt += 1;
      c = mySerial.read();       
      Serial.write(c);
    }
    Serial.println();
    Serial.println("=================================================");
  }
}

i.e. the code is quite simple. Nevertheless on Serial Monitor I only get garbage.
Both processors are connected via a wire.

Whats wrong?

Sorry if the question is stupid. On web I found a lot on SoftwareSerial but nothing on my problem.

Do you have the wiring correct? Are the grounds connected together?

No, the powersupply is separated for both ICs since I originally planned to connect the ICs by an RF module.

Because this did only work partially, I tried to connect the TX of the Tiny (at Pin 0) with the RX of the Arduino (at pin 10).

There is a reason I used the words "correct" and "grounds connected" in the same post.

:blush: hmmmm .... I will try it. Does this mean, that I cannot use SoftwareSerial for wireless communication?

Meanwhile I tried it and it works (wired).

But what about wireless communication?

But what about wireless communication?

I think that depends on yor wireless hardware.

I have a couple of these cheap 433 MHZ tranceiver/receiver

http://www.ebay.com/itm/5-sets-433Mhz-RF-Wireless-Transmitter-Receiver-Link-Kit-Module-for-Arduino-/170959638368?pt=LH_DefaultDomain_0&hash=item27cdfd0f60

I tried using them with SoftwareWerial, with no luck.

But with the manchester library they works fine:

Ok, meanwhile I also found the Manchester library.

Unfortunately I'm working with Tiny84 but Manchester seems only to support Tiny85.

I tried the examples an they compile with Tiny85 8MHz selected. With Tiny84 I get the partially in the web reported errors:

D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp: In function 'void MANRX_SetupReceive()':
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:196: error: 'TCCR2A' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:196: error: 'WGM21' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:197: error: 'TCCR2B' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:197: error: 'CS22' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:197: error: 'CS21' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:198: error: 'OCR2A' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:199: error: 'TIMSK2' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:199: error: 'OCIE2A' was not declared in this scope
D:\Arduino\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp:200: error: 'TCNT2' was not declared in this scope

This means the installation is correct but doesn't compile with Tiny84. =(

Maybe this will help:

I didn't read the whole topic that Erni posted, but it looks like that they had a couple of problems with that library.. Anyway, I've made an update of my own.. I don't have the Attiny84 only 85 so I didn't try the library directly. I've updated the Timers and interrupts and also changed the prescaler because the 128 prescaler isn't supported. It compiles fine under Arduino 1.0.1 with the Attiny core.. Please try it and report any problems..

Edit: I've made a few changes to the updated library. You can find the latest patched version on github: GitHub - baselsw/arduino-libs-manchester at patch-1

MANCHESTER - Update - Baselsw.zip (6.38 KB)

Well, I installed the tiny.zip https://github.com/downloads/mchr3k/arduino-libs-manchester/tiny.zip suggested for MANCHESTER library in the hardware subdirectory of my Arduino workspace and used it instead of the "standard" library from Google Code Archive - Long-term storage for Google Code Project Hosting..

The MANCHESTER example code now compiles without error. Unfortunately the code does not run on my tiny84, even if I just try a led blink code nothing happens, i.e. the tiny.zip seems to have a bug!? I used the ATtiny84 @ 8 MHz  (internal oscillator; BOD disabled) configuration instead of ATtiny84 (internal 8 MHz clock) The latter one works without problems but doesn't compile with MANCHESTER library.

So, what to do now? I'm totally lost :~

Milou:
Well, I installed the tiny.zip https://github.com/downloads/mchr3k/arduino-libs-manchester/tiny.zip suggested for MANCHESTER library in the hardware subdirectory of my Arduino workspace and used it instead of the "standard" library from Google Code Archive - Long-term storage for Google Code Project Hosting..

The MANCHESTER example code now compiles without error. Unfortunately the code does not run on my tiny84, even if I just try a led blink code nothing happens, i.e. the tiny.zip seems to have a bug!? I used the ATtiny84 @ 8 MHz  (internal oscillator; BOD disabled) configuration instead of ATtiny84 (internal 8 MHz clock) The latter one works without problems but doesn't compile with MANCHESTER library.

So, what to do now? I'm totally lost :~

I've always used this core: Google Code Archive - Long-term storage for Google Code Project Hosting... Without any problem! Which version of the Arduino IDE are you using???

Use the standard core together with the library that I've posted above.. And use the option Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled).. Compile, upload and post your results here..

Edit: Here is a sketch I believe will work.. Connect the Data pin of the transmitter to D4 (Physical pin 7). Connect a switch between GND and D2 (physical pin 5). Everytime you press the switch the tiny will transmitt 12345 to the reciever.

#include <MANCHESTER.h>

unsigned int Data = 12345;
void setup()
{
  MANCHESTER.SetTxPin(4);
  pinMode(2,INPUT);
  digitalWrite(2,HIGH);
  attachInterrupt(0,sendData, FALLING);
}

void loop()
{
}

void sendData(){
  MANCHESTER.Transmit(Data); 
}

baselsw

I got curious and tried your modified manchester library on an Attiny84.
It worked right out of the box :smiley:

Thanks for sharing.

BTW I am using this core:

https://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0015.zip

Attiny84 as tx and Arduino UNO as rx

and this test sketch

#include <MANCHESTER.h>
unsigned int data = 1000;

void setup() 
{  

MANCHESTER.SetTxPin(4);
//  MANCHESTER.SetTimeOut(1000);
}

void loop(){
data++;

MANCHESTER.Transmit(data);

delay(500);
}

If I understand right, the arduino-tiny-0100-0015.zip has no "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" - this is a part of the tiny.zip. The arduino-tiny-0100-0015.zip comes with "ATtiny84 (internal 8 MHz clock)" and does definitely not compile with original MANCHESTER or your update, neither on Arduino 1.0.1 nor on 1.0.4.

What I did was:

  1. Downloading and installing the Arduino 1.0.4 IDE (after it didn't work with 1.0.1)
  2. Downloading and installing the arduino-tiny-0100-0015.zip Google Code Archive - Long-term storage for Google Code Project Hosting.
  3. Downloading and installing all proposed MANCHESTER libraries starting with this one GitHub - mchr3k/arduino-libs-manchester and updating with this one Arduino Forum
  4. Downloading and installing the tiny.zip https://github.com/downloads/mchr3k/arduino-libs-manchester/tiny.zip

Selecting "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" compiles with MANCHESTER but does nothing with my Tiny 84V 10 PU, the "ATtiny84 (internal 8 MHz clock)" doesn't compile with MANCHESTER.

By the way: I did nothing with the core subdirectory of MANCHESTER, since the tiny.zip should be sufficient.

So, where is the error in my chain of actions?

I forgot to mention, I use version 1.01

So your step 1 and 2 are OK

In yoyr librarries folder you should have a folder called MANCHESTER

In that folder you copy the two files MANCHESTER.cpp and MANCHESTER.h from baselsw's link.

And thats it.

If yoy enable * vebose output you will be able to see if you use the right library files.

  • In file -> preferences

Milou:
If I understand right, the arduino-tiny-0100-0015.zip has no "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" - this is a part of the tiny.zip. The arduino-tiny-0100-0015.zip comes with "ATtiny84 (internal 8 MHz clock)" and does definitely not compile with original MANCHESTER or your update, neither on Arduino 1.0.1 nor on 1.0.4.

What I did was:

  1. Donwnloading and installing the Arduino 1.0.4 IDE (after it didn't work with 1.0.1)
  2. Downloading and installing the arduino-tiny-0100-0015.zip Google Code Archive - Long-term storage for Google Code Project Hosting.
  3. Downloading and installing all proposed MANCHESTER libraries starting with this one GitHub - mchr3k/arduino-libs-manchester and updating with this one Arduino Forum
  4. Downloading and installing the tiny.zip https://github.com/downloads/mchr3k/arduino-libs-manchester/tiny.zip

Selecting "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" compiles with MANCHESTER but does nothing with my Tiny 84V 10 PU, the "ATtiny84 (internal 8 MHz clock)" doesn't compile with MANCHESTER.

By the way: I did nothing with the core subdirectory of MANCHESTER, since the tiny.zip should be sufficient.

So, where is the error in my chain of actions?

You're obviously doing something wrong because I just REdownloaded the core and opened up the boards.txt and there you have it: attiny84at8.name=ATtiny84 @ 8 MHz (internal oscillator; BOD disabled)

So if you're not seeing this in the IDE then I believe your putting the files in the wrong directories..

Follow these steps and report again:

  1. Download the core: Google Code Archive - Long-term storage for Google Code Project Hosting.

  2. Extract the directory "tiny" to "C:\arduino-1.0.1\hardware" (change to your path to the hardware folder of the arduino IDE). You will get the following tree under the hardware folder:
    C:\arduino-1.0.1\hardware\tiny\boards.txt
    C:\arduino-1.0.1\hardware\tiny\cores
    C:\arduino-1.0.1\hardware\tiny\bootloaders
    and so on......

  3. Download the updated manchester library and extract the files to "C:\arduino-1.0.1\libraries".. You will get the following tree under the libraries folder:
    C:\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.cpp
    C:\arduino-1.0.1\libraries\MANCHESTER\MANCHESTER.h

  4. Try the sketch that I posted in the previous post.

@Erni: Thank you for trying out the library! =)

So next I did was to delete all object files to get a clean compilation.

The code I use is:

#include "MANCHESTER.h"

int rxPin    = 10; 
int txPin    =  0; 
int ledPin   =  1;

void setup() 
{                
  pinMode(ledPin, OUTPUT);    
  MANCHESTER.SetTxPin(txPin); 
}

void loop() 
{
  digitalWrite(ledPin,HIGH);
  delay(200);
  digitalWrite(ledPin,LOW);
  
  MANCHESTER.Transmit((unsigned int)12345);
  delay(100);
  
  digitalWrite(ledPin,HIGH);
  delay(200);
  digitalWrite(ledPin,LOW);
  delay(500);  
}

This compiles well with "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" from tiny.zip. Switch on the power, nothing happens at the led.

Damn (sorry) ... I mixed the available libraries.

So, here is (again) what I did:

  1. Downloading and installing the Arduino 1.0.4 IDE (after it didn't work with 1.0.1)
  2. Downloading and installing arduino-tiny-0100-0015.zip Google Code Archive - Long-term storage for Google Code Project Hosting. (contains "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)")
  3. Downloading and installing master.zip https://github.com/damellis/attiny/archive/master.zip proposed from http://hlt.media.mit.edu/?p=1695 (contains "ATtiny84 (internal 8 MHz clock)")
  4. Downloading and installing all proposed MANCHESTER libraries starting with this one GitHub - mchr3k/arduino-libs-manchester and updating with this one Arduino Forum
  5. Downloading and installing the tiny.zip not done anymore github.com/downloads/mchr3k/arduino-libs-manchester/tiny.zip (also contains "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)")

Did not do anything with the cores subdirectory of MANCHESTER library.

Behaviour is as before, i.e. "ATtiny84 (internal 8 MHz clock)" works perfectly for the Tiny84 but doesn't compile with MANCHESTER, "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" compiles with MANCHESTER but doesn't do anything with my Tiny84. Does anyone use the same Tiny: Tiny 84V-10PU. Maybe this is the reason, why it doesn't work?

Milou:
Behaviour is as before, i.e. "ATtiny84 (internal 8 MHz clock)" works perfectly for the Tiny84 but doesn't compile with MANCHESTER, "Attiny84 @ 8MHz (Internal Oscillator; BOD Disabled)" compiles with MANCHESTER but doesn't do anything with my Tiny84. Does anyone use the same Tiny: Tiny 84V-10PU. Maybe this is the reason, why it doesn't work?

After selecting the "board" did you use Tools / Burn Bootloader to ensure the fuses were correct?

Yes, everytime I change the board I first burn the bootloader.

What about the ATtiny 84V-10PU question? I program this by using the Arduino as ISP. The aim for me is also (as mentioned above) to have Attiny84 as TX and Arduino UNO as RX (later also an Attiny84).

By the way: the MANCHESTER version with cores subdirectories I got from here Arduino Forum or as direct link from here: Google Code Archive - Long-term storage for Google Code Project Hosting. but I think its overwritten by the other versions. In the new and clean installation I did not take this one.

Did you try baselsw's library from reply #8, as I said it worked for me on a Attiny84.