Can't connect to nrf8001

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
wookie1
 
Posts: 14
Joined: Wed Mar 26, 2014 2:00 pm

Can't connect to nrf8001

Post by wookie1 »

I'm trying to use my iPhone 5s to talk to a Trinket Pro 5V through the nrf8001. I've got the SPI pins hooked up CLK to pin 13, MISO to pin 12, MOSI to pin 11, RDY to pin 3, REQ to pin 6, and RST to pin 8 and set up the #define lines to match. I don't see any BT devices on my iPhone, and scanning in the nRF UART app doesn't find anything.

Other considerations: I'm using this with the 8 LED NeoPixel stick. I also have the nrf8001 stacked on the Trinket Pro using double-sided tape. Is that likely to mess up communication? I stacked it on the back behind the components area, the antenna area of the nrf board is uncovered by anything.

Here's my program, I have a simple lighting effect and wanted to change the color of the Neopixels if a character came in over BLE.

Code: Select all

#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include "Adafruit_BLE_UART.h"

// Connect CLK/MISO/MOSI to hardware SPI
// e.g. On UNO & compatible: CLK = 13, MISO = 12, MOSI = 11
#define ADAFRUITBLE_REQ 6
#define ADAFRUITBLE_RDY 3     // This should be an interrupt pin, on Uno thats #2 or #3
#define ADAFRUITBLE_RST 8
#define PIN 9

Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);

const uint8_t maxBrightness = 100;
uint32_t color;

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  BTLEserial.begin();
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  color = strip.Color(100, 30, 255);
  
}

aci_evt_opcode_t laststatus = ACI_EVT_DISCONNECTED;

void loop() {
  aci_evt_opcode_t status = BTLEserial.getState();
  if (status == ACI_EVT_CONNECTED) {
    // Lets see if there's any data for us!
     while (BTLEserial.available()) {
      char c = BTLEserial.read();
      switch (c) {
        case 'r':
        color = strip.Color(255, 0, 0);
        break;
        case 'g':
        color = strip.Color(0, 255, 0);
        break;
        case 'b':
        color = strip.Color(0, 0, 255);
        break;
        case 'o':
        color = strip.Color(0, 0, 0);
        break;
     }
 
    }
  }
  strip.setBrightness(maxBrightness);
  centerOut(color);
  delay(200);
  centerOutOff();
  delay(200);
}
  
  void centerOut(uint32_t c) {
   strip.setPixelColor(3, c);
   strip.setPixelColor(4, c);
   strip.show();
   delay(200);
   strip.setPixelColor(2, c);
   strip.setPixelColor(5, c);
   strip.show();
   delay(200);
   strip.setPixelColor(1, c);
   strip.setPixelColor(6, c);
   strip.show();
   delay(200);
   strip.setPixelColor(0, c);
   strip.setPixelColor(7, c);
   strip.show();
  }

  void centerOutOff() {
    strip.setPixelColor(3, strip.Color(0,0,0));
   strip.setPixelColor(4, strip.Color(0,0,0));
   strip.show();
   delay(200);
   strip.setPixelColor(2, strip.Color(0,0,0));
   strip.setPixelColor(5, strip.Color(0,0,0));
   strip.show();
   delay(200);
   strip.setPixelColor(1, strip.Color(0,0,0));
   strip.setPixelColor(6, strip.Color(0,0,0));
   strip.show();
   delay(200);
   strip.setPixelColor(0, strip.Color(0,0,0));
   strip.setPixelColor(7, strip.Color(0,0,0));
   strip.show();
  }
Last edited by Franklin97355 on Sun Oct 12, 2014 3:22 pm, edited 1 time in total.
Reason: Added missing [code] tags.

wookie1
 
Posts: 14
Joined: Wed Mar 26, 2014 2:00 pm

Re: Can't connect to nrf8001

Post by wookie1 »

Also I just noticed that if I set pin 10 as an INPUT, the program seems to get stuck after the first few lines below (the middle 2 LED's come on and then nothing else happens):
void centerOut(uint32_t c) {
strip.setPixelColor(3, c);
strip.setPixelColor(4, c);
strip.show();

This only seems to happen if I also set up the BLE lines in the program, it will work fine if I comment them out. I was planning to react to pin 10 with different light effects. Is there some conflict on pin 10 with the BLE? I guess I can just try to move that wire to a different pin, but wanted to know why it isn't working.

wookie1
 
Posts: 14
Joined: Wed Mar 26, 2014 2:00 pm

Re: Can't connect to nrf8001

Post by wookie1 »

I got the BT connection working, so I'm just left with the pin 10 issue. I noticed after posting this topic that there's a category for wireless comm, sorry I didn't see it before.

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

Re: Can't connect to nrf8001

Post by adafruit_support_mike »

There is a conflict with pin 10, but it's a side-effect of the Arduino SPI library rather than the nRF8001 specifically.

The SPI library is hardcoded with the assumption that pin 10 will be used for a CS signal. You can use other lines for CS, but you can't use pin 10 for anything *but* a CS.

wookie1
 
Posts: 14
Joined: Wed Mar 26, 2014 2:00 pm

Re: Can't connect to nrf8001

Post by wookie1 »

Ok, I figured it was something like that. Thank you!

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

Return to “Other Products from Adafruit”