compiling error with attiny45

Hello,
I want to test my attiny45 with softserial but it won't work. Could somebody see what i have done wrong? Thanks.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 1);
int sensorValue = 0;
int sensor = 3;
float var = 0.0;
float temp = 0.0;
void setup()
{
mySerial.begin(4800);
mySerial.println("Hello, world?");
pinMode(sensor, INPUT);
}
void loop()
{
sensorValue = analogRead(sensor);
var = (sensorValue * 5.00) / 1024.00;
temp = var * 52.0833 - 20.833;
mySerial.print(temp);
delay(5000);
}

Why not use hardware serial?

... compiling error ...

What error?

Read this before posting a programming question

Point 6: "If you get an error, post the error (copy and paste). Not just "I got an error"."

Nope, no error here. (IDE 1.0)

Edit: oops missed the "tiny" bit.

the error:

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn45.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25/libgcc.a(_exit.o)

there is no hardware serial at an attiny45, isn't it?
Maybe the file is too big?

What version of the IDE are you using? I'm getting different errors to you, so we need to work out your environment.

Maybe the file is too big?

The source file? All 21 lines of it?

All 21 lines of it?

Yes, at least three lines too many

when i delete mySerial.print(temp);
the sketch work! What would be the problem?

Just as a hypothesis ...

The Attiny45 has 4 Kb of program memory. Asking it to print a float is probably loading in more libraries than will fit.

Maybe the file is too big?

Yes, maybe you asked too much of a processor with 4096 bytes of program space.

This doesn't totally prove it, but if you set the board to Uno, the space needed is:

Binary sketch size: 5528 bytes (of a 32256 byte maximum)

That's more than 4 Kb.

i use now serial.write instead of serial.print. But i retrieve '??øfxfx??'. Could i translate that into the right data ?

mySerial.print(sensorValue);

Amazing how tiny the attiny is !

It's not called the "tiny" for nothing!

But really, floating point numbers are traditionally pretty code and computation expensive.

i use now serial.write instead of serial.print. But i retrieve '??øfxfx??'. Could i translate that into the right data ?

I think you use the wrong baudrate.

If you are using TinyDebugSerial you can only use 9600, 38400 or 115000

The outputpin used by TinyDebugSerial is PB3, so if you move the sensorpin to PB4, you have a working sketch.

http://arduino.cc/forum/index.php/topic,91125.0.html

int sensorValue = 0;
int sensor = 4;
float var = 0.0;
float temp = 0.0;
void setup()  
{
    Serial.begin(9600);
  Serial.println("Hello, world?");
  pinMode(sensor, INPUT);
}
void loop()
{
sensorValue = analogRead(sensor); 
var = (sensorValue * 5.00) / 1024.00;
temp = var * 52.0833 - 20.833;                     
Serial.print("Temp ");
Serial.println(temp);
delay(1000);
}