Bluetooth Low Energy (BLE) Connectivity for Teensy 3.X Boards

Status
Not open for further replies.

gregtomasch

New member
Hello Everyone!

I am a newcomer to the PJRC Forum but have been using Teensy 3.X products for a number of years now... The Teensy 3.2 was transformative; excellent form factor, lots of I/O, plenty of numerical processing power and all at a economical price. And perhaps most important, Teensy 3.X products are fully supported (through Teensyduino) by the Arduino IDE. So spend your time writing application code, not figuring out how to configure the IDE.:)

One problem area for small, powerful MCU development boards is the lack of wireless connectivity. The Nordic nRF52 is in principle combines BLE connectivity with a Cortex M4 MCU... However, I find using the Nordic SDK about as much fun as a trip to the dentist's office:eek: Having said that, the nRF52 does have very good capability as a Bluetooth enabled device... In either Peripheral or Central role. So why not let the Teensy and the nRF52 both do what they are good at?

So now there is an nRF52 add-on board for Teensy 3.X products. Here's a GitHub repository for the project: https://github.com/gregtomasch/Tlera_nRF52_MCU_Add_On_Board

The concept is simple. The nRF52 is programmed as a BLE/UART bridge in either Central or Peripheral role and is connected to a UART port (Serial1) on the Teensy. Data transfer between the two BLE devices is done using the Nordic UART Service (NUS). Data coming in from the paired BLE device is written to the Teeny's UART port. Data generated by the Teensy can be streamed to the paired device by writing it to the UART port connected to the add-on board.

If you have a smart phone/tablet with a BLE/NUS capable terminal application (such as the Bluefruit LE Connect App) The Teensy can stream data directly to your smart device. You can also use a second Teensy with a Central role add-on board to act as a gateway to a PC. Again, data transfer with the add-on is done over a Serial1. In the gateway MCU's programming, you can read data coming in over the BLE/NUS link and immediately write it to the Teensy's USB serial port... So simply open up a serial monitor on the gateway Teensy's USB port and you can see data streaming in from your remote Teensy board!

The nRF52 add-on board has been successfully tested on Teensy 3.2 and 3.6 in both Central and Peripheral roles. I hope others will find this capability useful... If I can help anyone make use of it, that would be my pleasure.

Best Wishes,
Greg Tomasch

36044991-2dbfa902-0d89-11e8-9547-ddb436c5b8a5.png
 
Flashing the nRF52 add-on board

Hi mjs513,

The boards can be purchased pre-flashed as either a Central or Peripheral role device. Programming is done using the Nordic nRF52 DK board and "nRFgoStudio":

https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52-DK

If you look at the "Downloads" tab of the link above, you will see a link to download "nRFgoStudio". The wiki ".pdf" file in the GitHub repository for this project gives detailed instructions for flashing the nRF52 add-on board:

https://github.com/gregtomasch/Tler...ob/master/STM32L4_BLE_Bridge_and_OTA_Wiki.pdf

Best,
Greg
 
Thanks Greg, didn't notice that I could order them pre-flashed. Will have to add this to my list.

Mike
 
Hi There

I am trying develop Bluetooth communication with a Teensy 3.5 and a RN-42 HC-05 module.View attachment 13313
View attachment 13314

If I bridge the RX and TX the communication does respond clearly
If I hock it up to the RX TX at the teensy is does react but the Char or String is not transferred properly.. like this: View attachment 13315

Question:
The level is 3.3V at the teensy, right?
Do I need to invert the signal?

Here the datasheet for the RN42 BT:
http://ww1.microchip.com/downloads/en/DeviceDoc/rn-42-ds-v2.32r.pdf

Any idea?






Code:
int led8 = 8;           
int led13 = 13;

void setup() {
  Serial.begin(9600);
  pinMode(led8, OUTPUT);
  digitalWrite(led8, HIGH); 
  
  pinMode(led13, OUTPUT); 
  digitalWrite(led13, HIGH);
 
  Serial4.begin(115200);
  Serial4.println('a');
  
}

// the loop routine runs over and over again forever:
void loop() {
  String t;
  while(Serial4.available()){
    t +=((char)Serial4.read());
  }

  if(t.length()) {
      Serial.println("h...");
      Serial.println(t);
      if(t =="A\r\n") {
          digitalWrite(led13, HIGH);   
          delay(500);
      } 
      if(t !="A\r\n") {
          digitalWrite(led13, LOW); 
          delay(500);
      }
      
  }
  Serial.println("idle");
  delay(500);
}
 
Attachments invalid...

Hi,

Can't see the attachments... Difficult to comment on what's going on Logic levels should be 3.3V...
 
Status
Not open for further replies.
Back
Top