Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Bluefruit LE - which product?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Bluefruit LE - which product?

by paulosophy on Tue Aug 11, 2015 10:25 am

Hi all,

I am trying to decide between the UART and SPI version of the BLE modules.
From what I've read, SPI needs 7 pins (MOSI, MISO, SCK, CS/SSEL, GPIO, VIN, GND) [1], while UART only needs 4 (TX, RX, VIN and GND)[2].

Questions:
1. If UART only needs 4, why do all of the wiring instructions say to use 7 (TX, RX, MOD, RTS, CTS, VIN, and GND)?
2. Why would someone want to use SPI instead of UART, generally? On the SPI page, it says "If you like Serial communication more than SPI, we also have a version that can talk UART." Could someone expand on what that means?
3. Does the UART with only 4 pins use any interrupts to function?

[1] https://learn.adafruit.com/introducing- ... troduction
[2] https://learn.adafruit.com/introducing- ... troduction

paulosophy
 
Posts: 90
Joined: Fri Apr 17, 2015 5:40 pm

Re: Bluefruit LE - which product?

by adafruit_support_rick on Wed Aug 12, 2015 9:58 am

The 'extra' three lines on the BLE UART are control signals. Ready to Send, Clear To Send (these are data flow control signals) and Mode, which switches the module between Command and Data modes.

SPI is a bus - you can have more than one device attached to SCK, MISO, and MOSI. If you're running out of pins, SPI may be helpful over UART.

Software Serial uses pin-change interrupts on RX..

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Bluefruit LE - which product?

by paulosophy on Wed Aug 12, 2015 10:12 am

Just following up on this. My most pressing question is why I can't seem to use the BLE UART module with only 4 pins.

I read this:
"For most people, they'll be very happy to use the standard Nordic UART RX/TX connection profile. In this profile, the Bluefruit acts as a data pipe, that can 'transparently' transmit back and forth from your iOS or Android device." from here: https://learn.adafruit.com/introducing- ... troduction

Then I read this:
"Don't forget to also connect the CTS pin on the Bluefruit to ground if you are not using it!"

My original pin layout is the default one:
Code: Select all | TOGGLE FULL SIZE
MOD to Pin 12
CTS to Pin 11
TXO to Pin 10
RXI to Pin 9
VIN to 5V
RTS to Pin 8
GND to GND


Here are the pin combos I've tried. With notes on the behavior:
************** COMBO 1 ****************************
Code: Select all | TOGGLE FULL SIZE
MOD  **REMOVED**
CTS to Pin 11
TXO to Pin 10
RXI to Pin 9
VIN to 5V
RTS to Pin 8
GND to GND

Notes: If I move the physical switch to CMD mode, this works, but shouldn't it be in UART mode, since I'm connecting in UART mode on the app?


************** COMBO 2 ****************************
Physical switch: CMD
Code: Select all | TOGGLE FULL SIZE
MOD  to Pin 12
CTS **GROUNDED**
TXO to Pin 10
RXI to Pin 9
VIN to 5V
RTS to Pin 8
GND to GND

Notes: In this case, with CTS grounded, I get this errror message:
"Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"


************** COMBO 3 ****************************
Physical switch: CMD
Code: Select all | TOGGLE FULL SIZE
MOD **REMOVED**
CTS **GROUNDED**
TXO to Pin 10
RXI to Pin 9
VIN to 5V
RTS to Pin 8
GND to GND

Notes: Same error message as above:
"Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"

************** COMBO 4 ****************************
Physical switch: CMD
Code: Select all | TOGGLE FULL SIZE
MOD  to Pin 12
CTS to Pin 11
TXO to Pin 10
RXI to Pin 9
VIN to 5V
RTS  **REMOVED**
GND to GND

I see "Initialising the Bluefruit LE module" but nothing else print out. I am able to connect to the module from the app, but nothing happens, presumably because the sketch is frozen at that point.

************** COMBO 5 ****************************
Physical switch: CMD
Code: Select all | TOGGLE FULL SIZE
MOD **REMOVED**
CTS to Pin 11
TXO to Pin 10
RXI to Pin 9
VIN to 5V
RTS  **REMOVED**
GND to GND

I see "Initialising the Bluefruit LE module" but nothing else prints out. I am able to connect to the module from the app, but nothing happens, presumably because the sketch is frozen at that point.

How can I use the Bluefruit as a data pipe with only 4 pins?

BTW, here's the setup for the code I'm using. Note that I've removed the factory reset:
Code: Select all | TOGGLE FULL SIZE
// Initialise the bt module //
  Serial.print(F("Initialising the Bluefruit LE module: "));
  if ( !ble.begin(false) ) {
    error(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
  }
  Serial.println( F("OK!") );

  // Disable command echo from Bluefruit //
  ble.echo(false);
  ble.verbose(false);  // debug info is a little annoying after this point!

  // Wait for connection //
  while (! ble.isConnected()) {
      delay(500);
  }
  Serial.println(F("*****************"));

paulosophy
 
Posts: 90
Joined: Fri Apr 17, 2015 5:40 pm

Re: Bluefruit LE - which product?

by adafruit_support_rick on Fri Aug 14, 2015 9:33 am

If you connect the BLE as hardware serial, then you don't need RTS and CTS. That's only required for Software Serial.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Bluefruit LE - which product?

by ktownsend on Sat Sep 19, 2015 6:25 pm

This post has been inactive for a while, but I'm replying for people who end up here as a search result.

The need for CTS and RTS is related to a HW issue with the nRF51822 chips. The HW UART block inside the ICs isn't very 'robust', and has a very small FIFO, meaning that it is easily overwhelmed when too much data is sent back and forth on the two UART lines. Using CTS and RTS isn't always necessary, especially if you aren't transmitting much data, but it is highly recommended if you send moderate amounts of data or just don't want to have to 'wonder' if you're crossing the data threshold. CTS and RTS basically tell the device on the other end when they need to wait a bit before sending more data.

The SPI modules don't have the same issue, and can handle data more elegantly, though the SW involved in SPI transactions is a bit more complicated.

If you don't need to connect to an MCU using UART, I would generally recommend the SPI parts, though we provide two models since they are both useful in different situations.
Last edited by ktownsend on Wed Sep 23, 2015 3:20 pm, edited 1 time in total.

ktownsend
 
Posts: 1447
Joined: Thu Nov 05, 2009 2:18 am

Re: Bluefruit LE - which product?

by paulosophy on Wed Sep 23, 2015 9:52 am

Wow thank you this was incredibly helpful!
(Dumb question: what is an MCU?)

Do you have an idea of what is a 'moderate' amount of data? One 20-char String every 5 minutes? Is that a lot or not very much?

For what it's worth, I ended up using Hardware Serial anyway (we ran into some issues with the Software Serial library that went away with HW Serial). I'm still waiting to get approval from my work to post the open-source code, but I certainly will post what I've done as soon as that goes through!

paulosophy
 
Posts: 90
Joined: Fri Apr 17, 2015 5:40 pm

Re: Bluefruit LE - which product?

by ktownsend on Wed Sep 23, 2015 3:20 pm

Sorry, MCU = Microcontroller (AVR chip, ARM chip, etc.).

To me moderate amount of data = maybe one or two 20 byte packets per second or more. But if you can design CTS and RTS in, that should solve any problems you'll have with UART.

ktownsend
 
Posts: 1447
Joined: Thu Nov 05, 2009 2:18 am

Please be positive and constructive with your questions and comments.