Closed Raynman77 closed 8 years ago
Well the ATtiny pin config is super confusing, so my first assumption is that.
See here for an example of my confusion: https://github.com/TMRh20/RF24/pull/155
Please double check, because you have verified the radio is working, and ATTiny is usually straight forward once connected properly.
I totally agree with you. It is very confusing, especially when trying to follow some of the examples. So swapping MISO and MOSI according to the way the diagram in the rf24ping85.ino is listed still doesn't help. My first impression was how does the tiny84 communicate with slave if MISO on the tiny84 (PA5) is considered DO but there is no DI pin listed for the tiny84 on the MOSI pin (PA6). I mean isn't MISO and MOSI bus only available for programming the tiny84, and if this is true, then how would the tiny84 ever be able to communicate with an NRF24L01? It's very confusing.
So reading confusion: #155 , does this mean that in order to keep the MCU from switching between master and slave I need to use the SPI library within my sketch?
My first impression was how does the tiny84 communicate with slave if MISO on the tiny84 (PA5) is considered DO but there is no DI pin listed for the tiny84 on the MOSI pin (PA6).
Both official datasheets [1] and [2] list PA6 as DI for USI.
So reading confusion: #155 , does this mean that in order to keep the MCU from switching between master and slave I need to use the SPI library within my sketch?
No, SPI support code is implemented inside RF24 library, so it should work out of the box.
What software are you using? I assume Arduino IDE with some kind of attiny support library? Last time I checked Arduino IDE versions higher than 1.6.5 didn't work well with google-code attiny core.
Right, and initially thats what I assumed. That SPI is included in the library. Which to me doesn't help, because I have tried the rf24ping85.ino example on the tiny85 chip and the getting started.ino example on a arduino pro mini and it worked with no problems. However if I use the same setup but with the given wiring for a tiny84 (with the rf24ping85.ino on a tiny84), it doesn't transmit. The arduino IDE i'm using is 1.6.5. The only attiny support i'm using is the rf24 libraries provided from the TMRh20 fork.
The only attiny support i'm using is the rf24 libraries provided from the TMRh20 fork.
And what device do you select in Tools->Board
menu?
Anyway, I looked again at your first post.
ATtiny24/44/84 Pin map with CE_PIN 8 and CSN_PIN 7
This says that provided wiring diagram needs CE_PIN
set to 8 and CSN_PIN
set to 7, but you left default values - 3 and 4. Please edit this part of your sketch and check again.
// CE and CSN are configurable, specified values for ATtiny85 as connected above
#define CE_PIN 3
#define CSN_PIN 4
Edit Pin map from google-code core:
// ATMEL ATTINY84 / ARDUINO
//
// +-\/-+
// VCC 1| |14 GND
// (D 0) PB0 2| |13 AREF (D 10)
// (D 1) PB1 3| |12 PA1 (D 9)
// PB3 4| |11 PA2 (D 8)
// PWM INT0 (D 2) PB2 5| |10 PA3 (D 7)
// PWM (D 3) PA7 6| |9 PA4 (D 6)
// PWM (D 4) PA6 7| |8 PA5 (D 5) PWM
// +----+
Tried that too and it did not work either.
// CE and CSN are configurable, specified values for ATtiny85 as connected above
//#define CSN_PIN 3 // uncomment for ATtiny85 3 pins solution
RF24 radio(CE_PIN, CSN_PIN);
Ill try again when im not at work. But i did try ce>8 & ce>7 and still didnt work, although i might have made a simple wiring mistake as it was very late at night. Ill post back as soon as get it wired up and tested.
My first impression was how does the tiny84 communicate with slave if MISO on the tiny84 (PA5) is considered DO but there is no DI pin listed for the tiny84 on the MOSI pin (PA6). I mean isn't MISO and MOSI bus only available for programming the tiny84, and if this is true, then how would the tiny84 ever be able to communicate with an NRF24L01? It's very confusing.
Both ATtiny84 and ATtiny85 doesn't have a hardware SPI interface. They have an USI (Universal Serial Interface) that has a different registers map inside these chips. Standard SPI software library will not work - more over it will not compile at all. However - it is possible to configure the USI interface to act as an SPI interface - this little piece of code is included in RF24 attiny85 example/implementation (it is a SPI over USI implementation).
I do not know why your code doesn't work on ATtiny84. What device (board) have you selected in Arduino IDE? There is a chance that software compiled for ATTiny85 will not work when you upload it to ATtiny84. May it be because of chips internal hardware differences?
There is a chance that software compiled for ATTiny85 will not work when you upload it to ATtiny84. May it be because of chips internal hardware differences?
Normally programmer (avrdude) won't let you upload if MCU signature doesn't match selected target MCU.
There is a chance that software compiled for ATTiny85 will not work when you upload it to ATtiny84. May it be because of chips internal hardware differences?
It definitely won't work due to different register and port addresses.
What device (board) have you selected in Arduino IDE?
And what speed and fuse settings?
I use nRF24L01 with attiny84 since 1-2 years ago and they work fine together. Thanks to TMRh20 libraries.
Try to call RF24 lib as:
RF24 radio(CSN pin, CE pin);
where your "CSN pin" = "PA3" and "CE pin" = "PA2"; so:
RF24 radio(PA3, PA2);
Here my project (I'm sorry, it is in Italian), and it work. I use an old version of TMRh20 libs, so I don't know if the code works with the last release; but you can take a look.
Wmarkow, im using the board selection for the tiny84. Burnt the boot for 8mhz. And using the USBtiny programmer.
Slartitorto, defining the actual port "A" for ce and csn works?
Raynman77, I believe you are wrong when you assign CE and CSN pin numbers:
...
PB3 4| |11 PA2 --- nRF24L01 CE, pin3
PB2 5| |10 PA3 --- nRF24L01 CSN, pin4
...
#define CE_PIN 3
#define CSN_PIN 4
...
RF24 radio(CE_PIN, CSN_PIN);
...
In this way, you call RF24 lib with "3" and "4", but they are the pins on nRF24L01 module, they are not the pins on the microcontroller attiny84; I believe you need to pass the correct pin numbers that are attiny84's pins (PA3 and PA2); so I'd try:
...
PB3 4| |11 PA2 --- nRF24L01 CE, pin3
PB2 5| |10 PA3 --- nRF24L01 CSN, pin4
...
#define CE_PIN PA2
#define CSN_PIN PA3
...
RF24 radio(CSN_PIN, CE_PIN);
...
I will try defining ce and csn with PA2 & PA3 instead of using just 2 & 3 when i get off work. It will be one of the things I do in my testing.
Be sure to connect:
attiny84 pin 11 (PA2) ---> nRF24L01 pin 3 (CE)
attiny84 pin 10 (PA3) ---> nRF24L01 pin 4 (CSN)
Also, try both:
RF24 radio(CSN_PIN, CE_PIN);
and
RF24 radio(CE_PIN, CSN_PIN);
@Raynman77 Thanks for your input. In Arduino IDE if you go to Tools > Boards > Boards Manager, do you find 'ATTiny Core by Spence Konde' ?
The 'Arduino' pin numbers are defined in a file called pins_arduino.h as per https://github.com/SpenceKonde/ATTinyCore/blob/master/avr/variants/tinyX4/pins_arduino.h#L114
I think the problem lies in the fact that the ATTiny support was built and documented for the old google ATtiny core, which doesn't even exist any more. I think the Arduino pin numbers are different in this core, so the PA2, PA3 thing should work, but in theory it should also work with the corresponding pin numbers.
Thanks to all the comments, I think the problem is related to the change in ATTiny core, which can be fixed easy enough. I think this came up before, but the issue got closed or something.
@TMRh20 pin map you linked matches google-code pin map for tiny84 (this)
@zador-blood-stained Thanks, the darn project page was removed so I couldn't find it! Long thread for such a small chip.
Yup:
- That's an error. The project arduino-tiny was not found.
This link works fine for me (sorry for big screenshot)
No...my board manager shows "attiny by David A. Mellis ver. 1.0.1
I will add the core by Spence Konde when i get off work. I had a feeling this could be an issue..will post back with results later this evening.
What a trip with so many bugs lately... is this all somehow related to the leftpad thing lol?
The google page doesn't work for me in chrome at all. I tried using a VPN also and it doesn't matter where I connect from. It fails in Firefox, but if I refresh it comes up... LOL... I don't even know...
@Raynman77 https://github.com/damellis/attiny/blob/master/variants/tiny14/pins_arduino.h would be Arduino D2 and D3 ??
Gotcha, thanks. Will try D2 and D3 for ce & csn pin defintitions first.
Ok, so quick question. When I go to define the pin for D2 & D3 as PA2 and PA3, it compiles just fine. However I'm having trouble declaring the correct pin value for my int switchPin, in which my switchPin is the reed switch IO device. I've tried PA1 and 12 but this pin never go HIGH. Bear in mind i'm still testing this using the David Mellis tiny core.
sorry, i set it correctly now. Using switchPin PA1 as int switchPin = 1;
This does not work using David A. Mellis tiny core and I even swapped the MISO and MOSI pins on the breadboard: `// CE and CSN are configurable, specified values for ATtiny85 as connected above
//#define CSN_PIN 3 // uncomment for ATtiny85 3 pins solution int switchPin = 1;
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = { "1Node","2Node"};
void setup() { pinMode(switchPin, INPUT); // Setup and configure rf radio radio.begin(); // Start up the radio radio.setAutoAck(1); // Ensure autoACK is enabled radio.setRetries(15,15); // Max delay between retries & number of retries radio.openWritingPipe(addresses[1]); // Write to device address '2Node' radio.openReadingPipe(1,addresses[0]); // Read on pipe 1 for device address '1Node' radio.startListening(); // Start listening }
void loop(void){
digitalRead(switchPin); digitalWrite(switchPin, HIGH); const char payload[] = "Garage Opened"; if (switchPin == HIGH) { radio.stopListening(); // First, stop listening so we can talk. radio.write( &payload, sizeof(payload) ); radio.startListening(); // Now, continue listening } unsigned long started_waiting_at = micros(); // Set up a timeout period, get the current microseconds boolean timeout = false; // Set up a variable to indicate if a response was received or not
while ( !radio.available() ){ // While nothing is received if (micros() - started_waiting_at > 200000 ){ // If waited longer than 200ms, indicate timeout and exit while loop timeout = true; break; }
}
if ( !timeout ){ // Describe the results unsigned long got_time; // Grab the response, compare, and send to debugging spew radio.read( &got_time, sizeof(unsigned long) ); }
// Try again 1s later delay(1000); }`
Sorry for the big post, just wanted it up and case anyone spots any issues in the code. However, there shouldn't be considering it runs just fine with the ATtiny85 chip. So I guess my next attempt will be to use a different core for the tiny. The core by Spence Konde mentioned by TMRh20 and zador-blood-stained.Will post back the results. Gonna go eat first..lol
Does anyone have any tips or suggestions for installing the alternate ATtiny core for the arduino IDE? I'm not sure if it is wise to remove the David A. Mellis attiny core before installing the Spence Konde attiny core, but it seems like the logical thing to do.
I installed the Spence Konde attiny core to the Arduino IDE 1.6.5 and wired everything up, uploaded the code in past posts above with the exception of these changes and is still not working.
`#include "RF24.h"
int switchPin = 1;
RF24 radio(PA2, PA3); ` evened swapped 'ce & csn' for physical pins on the tiny84 '11 & 10'
A funny thing, when I use the tiny85 chip and program it with the exact same program as above, except I define the reed switch as int switchPin = 1; , in which is the reset pin of the tiny85. When I do this everything works fine with the exception when the NC reed switch is closed the tiny85 is constantly resetting itself due to using the reset pin as an IO without fusing it to act as an IO pin. (Only for testing purposes). Also with the David Mellis core and using a tiny84 chip, I can set the int switchPin = 1; , which is PA1 physical pin location 12 and the internal resistors are set to the pin I commanded pin PA1. However, I am not getting any data transmitted out from the rf24. This is beginning to be very upsetting. I'm almost out of hair to pull out.
I would recommend this:
Delete/remove everything ATtiny using Arduino Board Manager, then verify/delete manually:
(On Windows)
Check Documents/Arduino/hardware -- delete all tiny stuff
Check C:\Users
Get the google ATtiny core that is tested and the examples were built with: (you may have to use firefox or a browser that works there??) https://code.google.com/archive/p/arduino-tiny/ Download It should work with the others, but lets go with the known working one.
Run the known working example rf24ping85 using RF24 radio(8,7); or RF24 radio(PA2,PA3);
Laugh or cry...
I removed everything tiny from my hardware folder within my sketch book folder and removed all the tiny stuff from my C:\Users
`#include "RF24.h"
int switchPin = 1;
RF24 radio(PA2, PA3);` Would int switchPin = 1; be the same as selected PA1 as my input, btw it is called to fuse HIGH in my sketch? Or do I have the wrong pin?
Nevermind, it would be 9.
`#include "RF24.h"
int switchPin = 9;
RF24 radio(8,7);`
This doesn't work either. When testing the chip with my meter. I probed pin PA6 in which according to the pinout is MOSI. However it never shows any voltage on it. PA5 MISO does though. It's voltage is varying as I suspect it should.
I'm not familiar at all with the switchPin/fuse thing, but the comment https://github.com/TMRh20/RF24/issues/236#issuecomment-203324723 shows the pinmap.
If you specify a number like 9, it uses the D9 arduino pin, else using the PA/PB numbers is pretty straight forward I think. Maybe @zador-blood-stained would be more knowledgeable than I?
I tested PA1 before setting switchPin = 9 and it was LOW, afterwards I set my variable switchPin = 9 and tested it again and my meter read 3.3 volts concluding that using the straight numeral value works.
I only bought 2 of these 84 chips to play around with. So far it looks like the only thing they are good for at the moment is for running basic scripts. For me anyway.lol. The only other option I have is to just use the 85 and disabling the reset function so that I can use a INPUT/OUTPUT on that chip.
Yeah, I would probably resort to looking at hardware or coding a loopback test with MISO connected directly to MOSI to see if SPI is working or what. Change #include <SPI.h> to <RF24.h>
should allow it to compile and work on ATTiny
@TMRh20 Funny you mention that, when I swapped MISO on the radio to PA6 on the 84, and MOSI to PA5, the voltage meter showed a varying voltage indicating that communication was taking place. But I swapped the cables around voltage only showed on PA5.
This is what I get if I try to #include
"rf24ping84_sw.ino:57:17: fatal error: SPI.h: No such file or directory compilation terminated. Error compiling."
GitHub formatting blocked out your #include
but if you are getting that error with #include <RF24.h>
, maybe you need to do the same thing with RF24 library and delete everything RF24 manually before reinstalling with library manager preferably.
If ATtiny is selected, RF24 will include SPI functions automatically for all supported devices.
@TMRh20 Im getting this error when I attempt to include SPI.h in my sketch
Standard spi lib does not support attiny. Rf24.h has spi code for attiny.
Sent from my iPod
On 2016-03-31, at 11:50 PM, Ray notifications@github.com wrote:
@TMRh20 https://github.com/TMRh20 Im getting this error when I attempt to include SPI.h in my sketch
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/TMRh20/RF24/issues/236#issuecomment-204257066
@TMRh20 With the David Mellis RF24 library?
@TMRh20 Just want to be clear on which library to install. I have removed the RF24 libraries from David A. Mellis
This https://github.com/TMRh20/RF24 is the RF24 library.
For the record, the problems at https://code.google.com/archive/p/arduino-tiny/ with chrome were user error (a plugin blocking it).
Thanks for all the input everybody.
Would int switchPin = 1; be the same as selected PA1 as my input
Yes if your attiny support core was installed and configured correctly. But there are many things that could go wrong (especially since you had to edit/copy-paste board definitions manually).
Without an oscilloscope or logic analyzer I would recommend starting from scratch with simple blinking LED sketch to verify pin mappings, after that test input with pull-up (switchPin
), and after that start to play with RF24 library and hardware.
@zador-blood-stained I will do that, again. However, I have tested the pins with a meter for simple HIGH and LOW state changes according to the pins that I have selected as IO functions and they are correct as far as IO pin mapping is concerned.
This is a picture of the blink LED working correctly as "int switchPin = 9;" the LED is attached to pin PA1. You can't see that it is blinking because its a picture, but it is. Confirming that it is not my pin selection for IO
Hi, I'm having a problem with the transmission using the RF24 library. On the tiny84, i'm using the example diagram that you have provided for my wiring scheme in the example "rf24ping85" for the ATtiny84 and it's not transmitting anything. On the receiver i'm using the example "getting started". When I use the 5 wire hookup on an ATtiny85, it works just fine. However, when I wire up a tiny84 and load the same sketch, I get nothing. Here's the sketch:
ATtiny24/44/84 Pin map with CE_PIN 8 and CSN_PIN 7 Schematic provided and successfully tested by Carmine Pastore (https://github.com/Carminepz) +-\/-+ nRF24L01 VCC, pin2 --- VCC 1|o |14 GND --- nRF24L01 GND, pin1 PB0 2| |13 AREF PB1 3| |12 PA1 PB3 4| |11 PA2 --- nRF24L01 CE, pin3 PB2 5| |10 PA3 --- nRF24L01 CSN, pin4 PA7 6| |9 PA4 --- nRF24L01 SCK, pin5 nRF24L01 MOSI, pin7 --- PA6 7| |8 PA5 --- nRF24L01 MISO, pin6 +----+ */