Can't get CC3000 and nrf24l01 to work together

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
snapDan
 
Posts: 6
Joined: Mon Oct 07, 2013 8:28 pm

Can't get CC3000 and nrf24l01 to work together

Post by snapDan »

Starting with the buildtest.ino example from the Adafruit_CC3000 library - works fine. Add in some simple listening code for an nrf24l01 module with the RF24 library:

added to setup:

Code: Select all

	radio.begin();
	radio.setRetries(15,15);
	radio.setPayloadSize(16);
	radio.setPALevel(RF24_PA_HIGH);
	radio.setDataRate(RF24_250KBPS);
	radio.setCRCLength(RF24_CRC_16);
	radio.setChannel(0x77);
	radio.openReadingPipe(1,remoteAddress);
	radio.startListening();
then in loop:

Code: Select all

	if ( radio.available() ) {
		char data[16];
		bool done = false;
		while (!done) {
			done = radio.read( &data, sizeof(data) );
			delay(20);
		}
		for (int i=0; i<16; i++){
			Serial.print(data[i]);
		}
		Serial.println(".");
	}
And the RF device spits out an endless stream of this character "ÿ". If I comment out the CC3000 initialization the RF code works exactly as expected. I've tried on a Teensy 3.0, then a Teensy 2.0, and now an Uno (even wired it exactly as this poster did) and the behavior is consistent between all 3. I've tried initializing the RF24 in different spots before and after the CC3000 initialization and nothing changes the behavior. Any ideas what's happening?

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by Franklin97355 »

What happens if you use the nrf code by itself?

snapDan
 
Posts: 6
Joined: Mon Oct 07, 2013 8:28 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by snapDan »

franklin97355 wrote:What happens if you use the nrf code by itself?
Works fine and I get the expected response. Since the two modules work independently I'm guessing that eliminates a hardware/wiring issue as the cause.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by adafruit_support_mike »

You may be hitting memory limits. The static code can compile to a size that fits, but when it starts allocating buffers dynamically, you get trouble.

Take a look at this tutorial for inforamtion about tracking and controlling memory usage: http://learn.adafruit.com/memories-of-a ... ot-dot-dot

snapDan
 
Posts: 6
Joined: Mon Oct 07, 2013 8:28 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by snapDan »

adafruit_support_mike wrote:You may be hitting memory limits. The static code can compile to a size that fits, but when it starts allocating buffers dynamically, you get trouble.

Take a look at this tutorial for inforamtion about tracking and controlling memory usage: http://learn.adafruit.com/memories-of-a ... ot-dot-dot
If I were hitting memory limits wouldn't my program just stop working? The program itself works fine - it just reads endless garbage from the RF module. Also I got the same problem using this on a Teensy 3.0 which is pretty powerful.

Still I went in and output the getFreeRam() function at various spots and when using both the CC3000 and nrf24l01 on the Uno it output 1172 free before the loop, then 1160 constantly during. Let me know if there's something else I should check to see about memory issues.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by adafruit_support_mike »

Memory limits cause all sorts of strange problems. Sometimes you'll run out of room in the stack frame, sometimes you'll get data corruption in the heap.

Communication devices use buffers that consume memory, and wierd output characters -- especially those with ASCII values above 127 -- tend to be a sign of memory corruption. The character you were getting is ASCII value 216, so again, that looks like data corruption.

Are you sure there are no pin conflicts between the two devices? That's another potential source of trouble.

snapDan
 
Posts: 6
Joined: Mon Oct 07, 2013 8:28 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by snapDan »

Thanks Mike. I've re-wired it 8 times now and re-checked many more so highly doubtful there are any pin conflicts: cc3000 has CS 8, VBAT 5, IRQ 3. nrf24l01 has CE 6, CS 7. They share CLK 13, MISO 12, MOSI 11.

At this point I really think there's something in cc3000.begin() that's messing with the nrf24l01. The following code

Code: Select all

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <RF24.h>

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    8
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIV2); // you can change this clock speed but DI

uint64_t remoteAddress = 0x00000000F2;
RF24 radio(6,7);

void setup(void)
{
	Serial.begin(115200);
	Serial.println(F("Hello, CC3000!\n")); 
	radio.begin();
	radio.setRetries(15,15);
	radio.setPayloadSize(16);
	radio.setPALevel(RF24_PA_HIGH);
	radio.setDataRate(RF24_250KBPS);
	radio.setCRCLength(RF24_CRC_16);
	radio.setChannel(0x77);
	radio.openReadingPipe(1,remoteAddress);
	Serial.println(F("\nInitialising the CC3000 ..."));
	if (!cc3000.begin()) {
		Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
		for(;;);
	}
 }
 
void loop(void) {
	if ( radio.available() ) {
		char data[16];
		bool done = false;
		while (!done) {
			done = radio.read( &data, sizeof(data) );
			delay(20);
		}
		for (int i=0; i<16; i++){
			Serial.print(data[i]);
		}
		Serial.println("<-radio output");
	}
	delay(1000L); // Pause 5 seconds
}
Produces the following output:

Code: Select all

Hello, CC3000!


Initialising the CC3000 ...
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ<-radio output
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ<-radio output
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ<-radio output
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ<-radio output
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ<-radio output
With the problem obviously being I never even call radio.startListening() - the nrf should not be hearing anything. I can even comment out all the nrf setup except for radio.begin() and it produces the same output. Even if I add radio.stopListening() and/or digitalWrite(7, HIGH);digitalWrite(6, LOW); after the cc3000.begin I get the same output. Swap the order of cc3000.begin and radio.begin - same output. If I comment out cc3000.begin() the nrf is quiet as it should be.

I've re-installed my Arduino IDE and the maniacbug/RF24 and Adafruit_CC3000 libraries just in case there was some issue there, but no dice. If someone with these components could give this a try to confirm or refute my problem or give me any kind of direction I'd really appreciate it.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by adafruit_support_mike »

I suppose RF interference is possible.. you have two ~2.4GHz devices sitting right next to each other, and probably sharing parasitic coupling through the power connections.

Try moving the devices physically apart from each other. Put a sheet of metal (aluminum foil will work) connected to GND between them. That should provide some RF shielding.

snapDan
 
Posts: 6
Joined: Mon Oct 07, 2013 8:28 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by snapDan »

I removed power from all nrf devices save the receiver. There is absolutely no device sending a signal at all. Same result. Furthermore, as I've stated, when I comment out cc3000.begin the nrf devices work perfectly. There is no interference happening.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by adafruit_support_mike »

Well, if you've ruled out the hardware, the software, and the signals, I don't know where else to look.

snapDan
 
Posts: 6
Joined: Mon Oct 07, 2013 8:28 pm

Re: Can't get CC3000 and nrf24l01 to work together

Post by snapDan »

Apparently the nrf24l01 modules don't work with other SPI devices. Not sure if that's always the case or just with some, but anytime I just enabled the CC3000 the nrf got "corrupted" and wouldn't recover until cycling power - even with the nrf CE low and CS high so it shouldn't be listening at all. Thankfully someone forked RF24 to this library that lets you use other pins for the nrf's SPI. The only code change I had to make was the initial declaration so easy peasy.

So for anyone conisdering a CC3000 and nrf24l01 combo - make sure you have enough pins or maybe consider a different RF device.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”