ATtiny45 Ir codes not sending correct

Hey,

I’m trying to program the ATTiny45 to send IR codes but it only sends FFFFFFFF codes.
Does anyone know why this happens?

This is exactly what I do:

I got the ATTinyTX library installed and the correct ATTiny boards for the arduino IDE.

  1. I setup my arduino to program my attiny45 and then upload the ArduinoISP to my arduino uno. ( I did change delay(40) to delay(20) )
  2. I choose from boards: ATTiny45 (Internal 8MhZ) and click burn bootloader.
  3. I write my sketch and include the ATTinyTX library to it.
  4. I upload the sketch to the ATTiny45.
  5. I test my sketch.

Problem:
My ATTiny45 does send IR Signals but not the right one, It sends five signals with this as data: 4294967295 with length: 100.

This is my sketch:

#include <IRTinyTX.h>

#define F_CPU 8000000 //<--I also tested it without this.
IRsend irs;
int btn_pin = 0;
boolean lastState;
long hexs[] = { 0xE1A2E817, -234209089, -509417449, -1045820938, 16730295 };
long hexlen[] = { 68, 68, 68, 68, 68 };

void setup(){
  pinMode(btn_pin, INPUT);
}

void loop(){
  if(digitalRead(btn_pin) == HIGH && lastState != HIGH)
  {
    for(int i=0;i<5;i = i + 1)
    {
      irs.sendNEC(hexs[i], hexlen[i]);
    }
  }

  lastState = digitalRead(btn_pin);
  delay(250);
}

Snippet from boards.txt:

attiny45-8.name=ATtiny45 (internal 8 MHz clock)
attiny45-8.bootloader.low_fuses=0xe2
attiny45-8.bootloader.high_fuses=0xdf
attiny45-8.bootloader.extended_fuses=0xff
attiny45-8.upload.maximum_size=4096
attiny45-8.build.mcu=attiny45
attiny45-8.build.f_cpu=8000000L
attiny45-8.build.core=arduino:arduino
attiny45-8.build.variant=tiny8

Thanks, -Tim

Hi,
That is a nice library to use with the Tiny’s

I think your problem is in the array you are trying to send, and the corresponding length.

Anyway i tried this, and I received the correct codes:
I am using a Attiny85 running @8Mhz

#include <IRTinyTX.h>

IRsend irs;
int btn_pin = 0;
boolean lastState;
long hexs[] = { 0xE1A2E817, 0x23420908, 0x50941744, 0x10458209, 0x16730295 };
long hexlen[] = { 32, 32, 32, 32, 32 };

void setup(){
}

void loop(){

    for(int i=0;i<5;i++)
    {
      irs.sendNEC(hexs[i], hexlen[i]);
    }
 
  delay(500);
}

Received code

E1A2E817
23420908
50941744
10458209
16730295
E1A2E817
23420908
50941744
10458209
16730295
E1A2E817
23420908
50941744
10458209
16730295
E1A2E817
23420908

Erni:
Hi,
That is a nice library to use with the Tiny’s

I think your problem is in the array you are trying to send, and the corresponding length.

Anyway i tried this, and I received the correct codes:
I am using a Attiny85 running @8Mhz

#include <IRTinyTX.h>

IRsend irs;
int btn_pin = 0;
boolean lastState;
long hexs = { 0xE1A2E817, 0x23420908, 0x50941744, 0x10458209, 0x16730295 };
long hexlen = { 32, 32, 32, 32, 32 };

void setup(){
}

void loop(){

for(int i=0;i<5;i++)
    {
      irs.sendNEC(hexs[i], hexlen[i]);
    }

delay(500);
}




Received code



E1A2E817
23420908
50941744
10458209
16730295
E1A2E817
23420908
50941744
10458209
16730295
E1A2E817
23420908
50941744
10458209
16730295
E1A2E817
23420908

Thanks for responding!
But I’m still receiving FFFFFFFF codes :confused:

-Tim

Even this code doesnt work:

BTW: I use decode_results_var.rawlen to get the IR signal length is that right?

#include <IRTinyTX.h>

IRsend ir = IRsend();

void setup(){
  
}

void loop(){
  ir.sendNEC(0xFF48B7, 68);
  delay(1000);
}

BTW: I use decode_results_var.rawlen to get the IR signal length is that right?

I am not sure what you mean.
I just just used Ken Shirriff’s demo sketch on my Arduino. Actually I’m no expert in IR coding, let’s hope you hear from somebody who are.

And by the way your last example worked fine in my setup

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

Still nothing works. I've tried replacing the IRLEDs different ATTINY45s. I've also noticed that the delay isnt correct. I've put a 2 second delay between the IRSignals but the delay is lower then one second. I think there is something wrong with the Timer or MHz??

Thanks in advance..

-Tim.

Seems to me you maybe have a timing problem.

It is strange that it works on my setup.

I am using this core: https://code.google.com/p/arduino-tiny/

Which core are you using?

Erni:
Seems to me you maybe have a timing problem.

It is strange that it works on my setup.

I am using this core:
https://code.google.com/p/arduino-tiny/

Which core are you using?

Wow! That doesn’t even come close to my ‘core’. (which only got fuses)
This is what I’m using:

I’m gonna give yours a try hope it works.

-Tim.

YESSS!!! Erni! Thanks for answering! It send the right codes now and does apply the right delay! And really thank you for your fast responses!

-Tim

(Really thanks now I can finally continue with my project after 1 1/2 week of trying to fix it!)

Glad you got it working.

I will forward the Thanks to Coding Badly for his excellent core

BTW I have tried the receiver code from the library. It works when used with the tx part of the library. With one of my remote controllers there are problems, but that might be because it use another protocol.