Open danjohn opened 7 years ago
Which pin on Attiny85 you use for receiving? Though code does compile with https://github.com/damellis/attiny LED is not blinking while I'm transmitting from Arduino.
According to his comment
// Receiver on interrupt 0 => that is pin #2
And to the pin definition
The pin to use is 2, the one under VCC.
I'll check that tonight as I would like to use attiny as receivers also. Will give a feedback
Ok, I've just did a test like this and led is blinking on attiny85 as receiver:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
pinMode(4, OUTPUT);
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 5393) {
digitalWrite(4, HIGH);
}
else if (value == 5396) {
digitalWrite(4, LOW);
}
mySwitch.resetAvailable();
}
}
I can confirm that there seems to be no problem to simply comment out the "#define RCSwitchDisableReceiving" in RCSwitch.h (line 56). Using interrupt 0 (pin 2) is working on Digispark with ATTiny85 just like on an Arduino Nano or Leonardo.
I will continue testing while working on a project that sends and receives (not to itself) over RF433 and so far that is working fine on this platform (I have not encountered any issues yet) so suggest to take out this #define at least for the __AVR_ATtinyX5__ platform.
I confirm that commenting the above said line also works with bare attiny85. But not with every library. Didn't work with Spence Konde "ATTinyCore" Library but did work when using "attiny" Library by David A. Mellis
I'm using very old attiny45's and 85's from their release 16 years ago and using David A. Mellis's cores the 45's work, but the 85's do not. Neither work with Spence Konde's cores. These old 45's just work straight out of the tube without burning a bootloader or anything, but these 85's won't work no matter what I try.
Did yout try to change the speed, 1Mhz, 8Mhz? Do they fail while uploading or when running?
Yes, and I was WRONG. Both the old 45's and old 85's work at both 1 and 8 using Mellis's cores. So Mellis's seems choice.
I just received new/latest 85's but I don't know what I changed in the last few days because now when I try to burn a bootloader on the new or old 85's it states: "free(): invalid next size (normal)". Again though, Mellis's works just fine.
I confirm receiving is working on the ATTiny85 with the following setup:
atmelavr
and board digispark-tiny
RCSwitchDisableReceiving
So as a conclusion Mellis core is definitely not the only one option
@sui77 assuming that multiple people confirm ATTiny85 receive is working pls consider removing RCSwitchDisableReceiving
at least for ATTinyX5, I can create PR for that if you'd like or otherwise users of your awesome lib will have to use custom fixed forks all over the place 😢
UPD: tested with non-default CPU frequencies 1, 8 and 16MHz. Default 16.5MHz feels to be the most stable due to being calibrated precisely by the micronucleus, while 1MHz has the most unstable receiving
Hello, I too late here... I just restarted now hehe... I need same, I use digistump Attiny85. Blue with the micro USB. When I used the Arduino Uno it is fine I have no issue, but my focus is on ATtiny85 because that is more than enough hardware for my project and I love it.
First issue that I encountered is compiling with the RCSwitch Library and saw online regarding the solution same above that I commented the line #define RCSwitchDisableReceiving... I used the Digistump | DigiSpak board in Arduino IDE compiling and uploading Successful but when I pressed the remote key (433 MHZ) there is no response of the built-in LED which I call for the high and low of the LED to know if there is a signal detected. It means its not working. The INT0 in my board is PB2 pin# 7 in the actual IC. PB1 has the built-in LED.
So... I follow here... excitedly...
@vi7 and @bodtx can you help?
and same as yours @vi7
Never use this board but if as I understand you use Arduino IDE and you want to upload with a programmer, you have to choose it here
Hello @bodtx, I really appreciated your response... thank you soo much...
Yes... I'm using Arduino... So I will use the ATtiny85 without the board which I attached the link? I will use the ATtiny85 microcontroller IC only not with the board and upload the sketch using other Arduino board and upload it using Arduino as ISP?
because the ATtiny85 with the board as same as I attach the link I don't need Arduino Board it can be directly upload the sketch with the programmer Micronucleus same as mentioned by @vi7.
Thank you very much @bodtx I will try it... If I will use the ATtiny85 microcontroller only, I will burn first the bootloader and upload the sketch.
I just copy and paste your code. You connect the data pin of the RF to the pin 7 (INT0/PB2) right?
I am using this RF below and it's perfectly working with Arduino with the example sketch of the RCSwitch library on receiving sketch...
Never use this board but if as I understand you use Arduino IDE and you want to upload with a programmer, you have to choose it here
@bodtx I found out that the error message "A programmer is required to upload." is when I used the Upload button and the uploading successful when I'm using the Sketch | Upload Using Programmer.
so again I uploaded your code and nothing happened. I put the data pin of the RF receiver to the PB2 (pin 7 physical pin of the ATtiny85 next/under the VCC pin where the INT0 pin) and the LED on the PB1 (pin 6 physical pin on the ATtiny85).
Any help please? can you share your's how did you do it?
Ok, I've just did a test like this and led is blinking on attiny85 as receiver:
#include <RCSwitch.h> RCSwitch mySwitch = RCSwitch(); void setup() { mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 pinMode(4, OUTPUT); } void loop() { if (mySwitch.available()) { int value = mySwitch.getReceivedValue(); if (value == 5393) { digitalWrite(4, HIGH); } else if (value == 5396) { digitalWrite(4, LOW); } mySwitch.resetAvailable(); } }
This is the code I uploaded, I want to see only if there is a reaction when pressing any RF remote or detects any signal. just to test if it is working the code and library.
#include <Arduino.h>
#include <RCSwitch.h>
#define RF_PIN PB2
#define LED PB1
RCSwitch mySwitch = RCSwitch();
void setup()
{
mySwitch.enableReceive(RF_PIN); // Receiver on interrupt 0 => that is pin #2
pinMode(LED,OUTPUT);
}
void loop() {
if (mySwitch.available())
{
digitalWrite(LED, HIGH);
mySwitch.resetAvailable();
delay(100);
} else
{
digitalWrite(LED, LOW);
}
} ```
Did it work on a real Arduino, uno for exemple ?
Did it work on a real Arduino, uno for exemple ?
No... I try in Arduino Uno but still not working.... So... what I did is uncommented the #if defined( AVR_ATtinyX5 ) or defined ( AVR_ATtinyX4 ) and #endif and live the //#define RCSwitchDisableReceiving commented and try again with Arduino Uno and it works...
In my ATtiny85, I change the #define RF_PIN PB2 to RF_PIN 0 and upload the sketch and yehhheyyy it's working...
So... I found out that mySwitch.enableReceive(0) must always be zero parameter but you will connect the RF data pin to where is the INT0 or External Interrupt pin in your board and I uncomment also the #if defined( AVR_ATtinyX5 ) or defined ( AVR_ATtinyX4 ) and #endif and live the //#define RCSwitchDisableReceiving commented.
Now, it's perfectly working... and my project was done!
Thank you soo much @bodtx I can't solve it with out you... I really appreciated your help...
Sharing to you my project is... An RF remote receiver with a relay that will turn-on my air-condition. The remote receiver has a learning capability so that I can use whatever RF remote available. those learn code are saved on the EEPROM so that if the device will turn off and turn back on for what ever the reason, the remote code will still there... now my aircon can be controlled by Alexa and Google Home and I can control it wherever I am in the world.
once again... I really appreciated your help @bodtx and this topic... thank you soo much... cheers...
Very good, so you were missing some defined parameters. Happy it helped, but as always you did most of the job 🤯🤩😎
Very good, so you were missing some defined parameters. Happy it helped, but as always you did most of the job 🤯🤩😎
yes... and as always... thank you soo much...
hey @jilvir , as I see I'm a bit late for the party. JFYI feel free to check my sample project for RX testing on different boards including our subj - Digispark ATTiny85 USB. Couple of notes about the project:
Worth to mention that my ATTiny85 USB clone has INT0
interrupt on PB2
pin, that is the one used by default when you do receiver.enableReceive(0)
. On the other hand project above allows you to use any ATTiny85 pin with some additional interrupt messing code (included in the example)
ing code (included in the example)
Thank you soo much... yes I will... thanks...
For anyone checking, this also works with an ATtiny84 (just make sure to use the ONLY external interrupt pin for your DATA pin. It is physical pin 5, aka "INT0" aka "PB2"), and you need to comment out #define RCSwitchDisableReceiving
on line 56 of RCSwitch.h, as mentioned.
The implementation disables receive features on ATtiny's due to "missing libm depencies (udivmodhi4)".
I don't know, maybe that requirement has changed in the last few months (new libs? adapted code?), but I can definitely compile and (obviousely successful) run that receive code on a DigiSpark-like target.
Hopefully this could be verified by a more experienced user!? (Also, I can't see where "divmod" would be used in the sources (pls give a noob a hint!:))
All I did for testing, was to comment out "#define RCSwitchDisableReceiving" in RCSwitch.h (line 56). Sketch:
Blinks when I press a button on my RC key.
IDE: arduino-1.8.2-linux32 RC-switch: version of Feb 27, 2017 Target: http://www.electrodragon.com/product/attiny85-usb-mini-dev-board-digispark-compatible/