Go Down

Topic: SOLVED: ATtiny85 w/IR remote: This should be working but...???  (Read 280 times) previous topic - next topic

open817

Howdy Folks,

Brand-newby here. Seems like maybe I bit off more that I can handle, but I'm not one to give up. Yet.

I have an art project that requires 3 separate circuits of LEDs to be individually controlled by one remote. One circuit is a rgb addressable strip LED kit with IR remote. Another is a mini LED 'fairy light' string (on/off switch). Lastly, I have a harness of 8 individual 2.5mm 'twinkling' LEDs. I want to re-purpose two buttons on the the strip kit remote to simply toggle on/off and provide power to each of the other 2 circuits.

Here's some initial particulars:

LED strip kit runs on 12v with a power adapter (output rated at 5amps).
Fairy lights and twinklers both run on 3.3v .

Purchased several 12v,5v,3v3 power modules (12v input). [Good thing I bought multiples as I burned out the first 2 with excessive amps! Found another power adapter with proper mAh.]

I felt like the most practical method was to pass 12v straight through the power module to the strip light's board and use the 3v3 power-out pins for the other 2 circuits. I glued the strip board and power module to a solderable breadboard and installed header pins for permanent connections. Once I got past the over-current issues the lights work/look great! At this point however only the rgb strip was controlled by its remote.

Over the past several weeks I've been learning to write sketches for Arduino Uno but I don't have room to simply install the Uno on the project and let it do the work. I do have room on the breadboard for an ATtiny85 so I've learned to program ATtiny with Arduino as ISP. Truthfully, I haven't learned much C++ yet so I've taken most of my info and examples from Arduino community and other online resources.

My current sketch compiles and uploads to ATtiny without issue. It all looks great - it just doesn't respond to the IR codes received.

My wiring hookups correspond to the standard schematics for programming Attiny85. As follows:

               ATtiny Pin:                Arduino Uno Pin:                       Prototyping Breadboard:


            Reset PB5 (1)      to      10
          Analog PB3 (2)       "       unused
          Analog PB4 (3)       "       signal pin on IR (vs1838)          ("RECV_PIN" in my sketch)       
                    GND (4)       "       breadboard gnd
            MOSI PB0 (5)       "       11                                            (output "LED1" in sketch)
            MISO PB1 (6)       "       12                                            (output "LED2")
              SCK PB2 (7)       "       13
                    VCC (8)      "        breadboard voltage

Also:                                         5V to breadboard
                                               GND     "      "
                                               GND to RESET w/ 10µf cap
                                                                                              33µf cap across +/- columns

                    PB0 (5) -----------------------------------------------  jumper to an LED
                                                                                               (to observe LED1 output)

                    PB1 (6) -----------------------------------------------  jumper to an LED
                                                                                                (to observe LED2 output)


After many corrections my sketch compiles and uploads without issue. NOTE: The Tx/Rx LEDs on
Uno are of course an easy way to watch as the sketch uploads to ATtiny85, but I can also see the same activity on the observance LEDs I installed on the breadboard.

So, my problem is that it just doesn't work. The DIY4 and DIY5 remote buttons do not produce any effect at all. I've retested to verify IR function and correct codes (NEC format). I've tried each of the 3 different numbers describing ATtiny85 pinouts (e.g., PB0, 0, and 5). 
Checked and triple-checked everything... I feel like I'm so close and yet, I'm lost.

Please help.
Sketch is attached.

Thank You Very Much.
Paul
 





open817

"So, my problem is that it just doesn't work. The DIY4 and DIY5 remote buttons do not produce any effect at all. I've retested to verify IR function and correct codes (NEC format). I've tried each of the 3 different numbers describing ATtiny85 pinouts (e.g., PB0, 0, and 5).
Checked and triple-checked everything... I feel like I'm so close and yet, I'm lost."

******************************************************************************************


Folks,

I solemnly promise that after I get through this particular nightmare I will work diligently to learn the proper etiquette for posting. For those hardy souls who waded my verbose initial post I thank you!

I have at this point created a new sketch and I have a pic of my breadboard (both attached). The sketch functions perfectly when uploaded to Uno. Remote key codes are detected and energize each channel just as expected.

When uploaded to ATtiny85 I get the same nothing as before. It appears to me that the RECV_PIN (2)
is getting the remote signals but the chip isn't activating output channels.

Please look at my attachments and let me know what you think.

Thanks!


open817

Adding the wiring photo here. Previous was too large.

DrAzzy

Post from OP:

Code: [Select]
/*
 * ATtiny85 programming
 * Arduino as ISP
 * Remote control button reprogramming
 * Controls two led circuits independently
 */

 // Include IR Remote Library by Ken Shirriff
 #include <IRremote.h>
 
 // Define sensor pin
 const int RECV_PIN = 2;

 // Define LED pin constants
 const int blupin = 0;
 const int grnpin = 1;

 // Define integer to remember toggle state
 int togglestate = 0;

  // Define IR Receiver and Results Objects
  IRrecv irrecv(RECV_PIN);
  decode_results results;
 
void setup() {
  // Enable the IR Receiver
  irrecv.enableIRIn();
  // Set LED pins as Outputs
  pinMode(blupin, OUTPUT);
  pinMode(grnpin, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)){

     switch(results.value){
       case 0xFF10EF: //DIY4 Keypad Button
      // Toggle Blue LED On or Off
      if(togglestate==0){
      digitalWrite(blupin, HIGH);
      togglestate=1;                       
      }
      else {
      digitalWrite(blupin, LOW);
      togglestate=0;
      }
     break;

        case 0xFF906F: //DIY5 Keypad Button
      // Toggle LED On or Off
      if(togglestate==0){
      digitalWrite(grnpin, HIGH);
      togglestate=1;                       
      }
      else {
      digitalWrite(grnpin, LOW);
      togglestate=0;
      }
      break;
    }
    irrecv.resume();
  }
}


use code tags (</> button) to post code if possible, instead of attaching the file. Most of us, particularly the knowledgable people you want answering you, do much of their answering from a mobile device (ie, when they are not at a desktop computer, because if they were, they would be working on their own projects). Even on a desktop, downloading and opening the file is a bunch of additional steps that someone helping another person on the internet has little motivation to do - there are always other questions that don't require those steps to answer, so why bother with one that makes it harder. You also did not clearly spec original problem statement - you said that two buttons did not work, but that implied that the other buttons did when there are no such buttons, and we needed to download a file to see that.

In any event, I think the most likely issue is that the part is getting the input signal, but not able to correctly interpret it for some reason, resulting in the codes it sees not getting interpreted. A way to verify this would be to blink an LED when it receives a code, maybe a blink code to further communicate that the code received was the expected length.

In no particular order (please respond to all of these - it is incredibly frustrating when someone gives a list of things to check, and the person we are trying to help will only try one of them)
Did you do "burn bootloader" on the receiver? this step is needed, even if not using a bootloader, because that's the only thing that sets the fuses to select the clock speed. If the clock speed isn't matched with the speed that you told the IDE, all timing will be off, including calculation of lengths of pulses for IR remote, will be way wrong. (you know the transmitter is right, because the uno could receive from it).

What board package and version of that board package are you using? It should be my ATTinyCore; some of the others do weird stuff with timer1, and other cores others are not actively maintained, and have limited features and selection of supported chips.

Where did the library come from? Have you verified that it does not make any undue assumptions about the chip configuration?

You are missing the 0.1uF cap between Vcc and Gnd right next to the attiny, this is required for reliable operation. Put it across the top of the chip.

Where is that yellow wire supposed to go?
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

open817

"... you said that two buttons did not work, but that implied that the other buttons did when there are no such buttons, and we needed to download a file to see that."

Sorry. I was trying to say that the two remote control buttons whose NEC codes are specified in the sketch did not produce the desired effect. All buttons on the remote are functional and codes verified multiple times.

To your questions:


1.) "What board package and version of that board package are you using?"

2.) "Where did the library come from?"


    The board, ATtiny25/45/85, and the library were from ATtiny:
 
githubusercontent.com/damellis/attiny/ide-1.6.x-boards manager/package_damellis_attiny_index.json
ver. 1.1.3

    I am not experienced enough to know how to verify undue assumptions.


3.) "Where is that yellow wire supposed to go?"

    From the signal pin on VS1838 IR sensor to PB2 on ATtiny85. [I also tried using PB4.
     Results were the same.]

4.) "Did you do "burn bootloader" on the receiver?"

    After having read that doing so uses up a chunk of ATtiny85's limited memory I elected not to.


Current Status:

After installing the .1µf cap as instructed. I installed your ATtinyCore. Unexpectedly, ATtinyCore itself was greyed out (?) but there were many more options available. I selected ATtiny85 (Optiboot) plus the following settings:

Chip:                      "ATtiny85"
Clock:                    "8mHz internal"
B.O.D.:                   "Disabled"      (default)
EEPROM                  "Retained"          (")
Timer 1 clock:         "CPU"                 (")
LTO:                       "Enabled"           (")
millis()/micros():     "Enabled"           (")

Programmer:           "Arduino as ISP"

I then ran burn bootloader and uploaded the sketch. Results were the same. Tx/Rx leds on Uno showed proper activity. IDE message: "Upload successful."  Functionality: Negative

Went back and selected ATtiny25/45/85 as board (same settings). Same results.

Stopped and came here to post a reply only to discover that the site was down. Saturday night maintenance?

Thank you DrAzzy.

DrAzzy

Do burn bootloader, reupload your sketch, and it should work. I suspect you are compiling for 8MHz, but the chip is actually running at 1MHz, so it thinks all the pulses are 1/8th as long as they actually are, and hence doesnt recognize the IR message (the encoding is timing dependent, think more code)

Burn bootloader does two things - it sets the fuses to use the selected clock source, and uploads the bootloader (if any). ALWAYS burn bootloader on a part before you start uploading your sketches (and if you change the clock source), otherwise all sorts of things dont work.

That board definition doesnt have a bootloader - sketches are loaded via ISP (what you're doing now). So it does not cost you any flash.

The damellis attiny core is not well updated, and by now is quite feature poor compared to mine (mine, by the way, does have a separate board definition for the t85 that has an actual bootloader (optiboot), in addition to a board def for uploading via ISP - I recommend the latter, like you noted, the bootloader js a waste of flash). Board manager url is in sig.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

open817

Good morning.

This is absolutely maddening... my sketch has now decided it will no longer compile!!!

On my word, the only adjustment whatsoever was to change the clock speed from 8mHz to 1mHz and disable B.O.D. (really wasn't terribly worried about a brown-out). Not a single character in the sketch was altered. I even double-checked against the copy posted by DrAzzy in a previous reply (who was kind intention was to show me how to post the code directly into the reply instead of an attachment).

Tried to get it to compile with the DrAzzy ATtinyCore for both ATtiny45_85 (Optiboot) board and ATtiny25/45/85.
No luck with either.

Also mentioned in a previous message was that IDE 1.8.10 could be buggy with certain parameters. I uninstalled 1.8.10 and installed the 1.8.9 version of Arduino and tried again. No apparent success or difference.

Setting preferences for verbose output produced a lengthy (and cryptic) error message. Despite advice to the contrary I am again going to attach the file instead of copying it here. It is just too large.

Kindly inspect same and advise.

Thank you for your help.

DrAzzy

Use the non-optiboot board def - as you said, you want to program via ISP, no need for the bootloader itself.

You probably want to select 8MHz internal for the clock source, and then choose burn bootloader with the ISP programmer connected (this will not install a bootloader - there isnt one for the non-optiboot board def - but it will set the fuses, which is critical).

Don't get hung up on the term "burn bootloader" - it is a poor choice of terms, as in this case no bootloader is involved, but that step is still necessary to set the fuses.

Does it compile with clock source set to 8MHz internal? I vaguely remember something about IRremote requiring 8MHz minimum, but I may be getting it confused with something else.

I wonder if the cause of the problem is this:

 Used: C:\Users\pnoe5\Documents\Arduino\libraries\IRremote
 Not used: C:\Users\pnoe5\Documents\Arduino\libraries\Arduino-IRremote-master

try exiting the IDE, moving C:\Users\pnoe5\Documents\Arduino\libraries\IRremote to another location not inside libraries folder (eg, C:\Users\pnoe5\Documents\Arduino\libraries_not_used\IRremote) then starting ide again - that will force it to pick the other version. (if this doesn't fix it, you can undo this step - you should probably only have one version of that library installed, though - the one you want to use)

Wonder if you may have "updated" the library via board manager, when you were previously using a different version of that library with different behavior.

If above steps do not resolve it, switch back to damellis core, make the settings available there match what just failed in my core, and see if it fails there.

If it compiles with damellis, but not mine, that is a compatibility issue in my core that I need to investigate and resolve, so please let me know.

If it doesn't compile with either, that means the problem is not related to your switching to my core, probably a library version issue.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

open817

I am ecstatic to tell you.   IT WORKS!!!

As a guy who prides himself on being able to think through problems and find a solution, this has been a real booger. The solution in this case was to find a mentor, and that is YOU DrAzzy. I can't thank you enough.

Apparently mine was a library problem, as you suggested. After having created the Libraries_Not_Used folder and moving IRremote.h into it I then set up the following parameters:

Board:            ATtiny25/45/85

Chip:              ATtiny85

Clock:            8mHz (internal)

Programmer:  Arduino as ISP


Ran the burn bootloader. The sketch compiled and uploaded without issue. So then I disconnected the jumpers for programming ATtiny85 and reinstalled to the breadboard the IR sensor and my leads for PB2 (INPUT), PB0 (OUTPUT(circuit1)), and PB1 (OUTPUT(circuit2)).

And IT WORKS!!
There was no need to remove your ATtinyCore.

One oddity: I am having to press the remote buttons multiple times to get each circuit to toggle on/off.
I consider this a minor issue and wonder if it might be corrected once my circuits are hard soldered to a board. Sometimes a single press of the remote button will energize a circuit and other times it might take a half dozen presses to toggle on/off. Any ideas about that? Didn't seem to be a problem with the other test exercises and tutorials I completed.

A last forum etiquette question:
Seems like I should be able to edit the subject header to add "Solved" How do I do that?

Once again, thank you very much DrAzzy for your patience and diligence. I've learned so much from you in this short period of time.

Warm Regards.




DrAzzy

I think you edit the first post?

Glad it's working. Don't have any immediate guesses - but does your code transmit each message several times? I would recommend that - my understanding is that in typical commercial IR remotes, the remote sends the signal continually as long as the button is held down. Especially if the receiver and transmitter aren't pointed directly at eachother or something.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up