Is it possible to increase the baud rate on the BLEUart service on the nrf52840?
I found:
https://infocenter.nordicsemi.com/index ... _958674283
Which to me says the hardware should be able to handle up to 1mbps
Then I found:
https://learn.adafruit.com/introducing- ... d/hardware
Admittedly this is for the 51822 but I would think it should be doable on a later generation 52840 (assuming those numbers are increasing with release).
What I dont understand is how I actually do: "AT+BAUDRATE=115200" to set the baud rate in code.
UART Baud Rate on an nRF52840
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: UART Baud Rate on an nRF52840
@sminogue,
Are you using an Adafruit Feather nRF52840?
Are you running Arduino or CircuitPython?
Are you using an Adafruit Feather nRF52840?
Are you running Arduino or CircuitPython?
- sminogue
- Posts: 46
- Joined: Sun Oct 04, 2020 9:35 am
Re: UART Baud Rate on an nRF52840
Yes I am using an nRF52840 and I am writing my code in C++ in the Arduino IDE.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: UART Baud Rate on an nRF52840
It scanned the Adafruit nRF52 Arduino library and it looks like you specify the desired baudrate with the begin() statement. I believe 921,600 is the max value supported.
https://github.com/adafruit/Adafruit_nRF52_Arduino
https://github.com/adafruit/Adafruit_nR ... leuart.ino
Code: Select all
// Configure and Start BLE Uart Service
bleuart.begin(921600);
https://github.com/adafruit/Adafruit_nR ... leuart.ino
Code: Select all
/*********************************************************************
This is an example for our nRF52 based Bluefruit LE modules
Pick one up today in the adafruit shop!
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
All text above, and the splash screen below must be included in
any redistribution
*********************************************************************/
#include <bluefruit.h>
#include <Adafruit_LittleFS.h>
#include <InternalFileSystem.h>
// BLE Service
BLEDfu bledfu; // OTA DFU service
BLEDis bledis; // device information
BLEUart bleuart; // uart over ble
BLEBas blebas; // battery
void setup()
{
Serial.begin(115200);
#if CFG_DEBUG
// Blocking wait for connection when debug mode is enabled via IDE
while ( !Serial ) yield();
#endif
Serial.println("Bluefruit52 BLEUART Example");
Serial.println("---------------------------\n");
// Setup the BLE LED to be enabled on CONNECT
// Note: This is actually the default behavior, but provided
// here in case you want to control this LED manually via PIN 19
Bluefruit.autoConnLed(true);
// Config the peripheral connection with maximum bandwidth
// more SRAM required by SoftDevice
// Note: All config***() function must be called before begin()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
//Bluefruit.setName(getMcuUniqueID()); // useful testing with multiple central connections
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Configure and Start Device Information Service
bledis.setManufacturer("Adafruit Industries");
bledis.setModel("Bluefruit Feather52");
bledis.begin();
// Configure and Start BLE Uart Service
bleuart.begin();
// Start BLE Battery Service
blebas.begin();
blebas.write(100);
// Set up and start advertising
startAdv();
Serial.println("Please use Adafruit's Bluefruit LE app to connect in UART mode");
Serial.println("Once connected, enter character(s) that you wish to send");
}
void startAdv(void)
{
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
// Include bleuart 128-bit uuid
Bluefruit.Advertising.addService(bleuart);
// Secondary Scan Response packet (optional)
// Since there is no room for 'Name' in Advertising packet
Bluefruit.ScanResponse.addName();
/* Start Advertising
* - Enable auto advertising if disconnected
* - Interval: fast mode = 20 ms, slow mode = 152.5 ms
* - Timeout for fast mode is 30 seconds
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
*
* For recommended advertising interval
* https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
}
void loop()
{
// Forward data from HW Serial to BLEUART
while (Serial.available())
{
// Delay to wait for enough input, since we have a limited transmission buffer
delay(2);
uint8_t buf[64];
int count = Serial.readBytes(buf, sizeof(buf));
bleuart.write( buf, count );
}
// Forward from BLEUART to HW Serial
while ( bleuart.available() )
{
uint8_t ch;
ch = (uint8_t) bleuart.read();
Serial.write(ch);
}
}
// callback invoked when central connects
void connect_callback(uint16_t conn_handle)
{
// Get the reference to current connection
BLEConnection* connection = Bluefruit.Connection(conn_handle);
char central_name[32] = { 0 };
connection->getPeerName(central_name, sizeof(central_name));
Serial.print("Connected to ");
Serial.println(central_name);
}
/**
* Callback invoked when a connection is dropped
* @param conn_handle connection where this event happens
* @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h
*/
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
(void) conn_handle;
(void) reason;
Serial.println();
Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
}
- sminogue
- Posts: 46
- Joined: Sun Oct 04, 2020 9:35 am
Re: UART Baud Rate on an nRF52840
Results in a compile error:
error: no matching function for call to 'BLEUart::begin(int)'
I'm looking through the code in
https://github.com/adafruit/Adafruit_nR ... LEUart.cpp
https://github.com/adafruit/Adafruit_nR ... /BLEUart.h
And dont see a begin with a parameter.
error: no matching function for call to 'BLEUart::begin(int)'
I'm looking through the code in
https://github.com/adafruit/Adafruit_nR ... LEUart.cpp
https://github.com/adafruit/Adafruit_nR ... /BLEUart.h
And dont see a begin with a parameter.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: UART Baud Rate on an nRF52840
@sminogue,
Good point.
I don't see a way to set the BLE UART baudrate. I think the following only works for the nRF52 hardware UARTs (non-BLE).
https://github.com/adafruit/Adafruit_nR ... q=baudrate
I would suggest opening an issue and requesting a setable BLE UART. If there is a way that will come out of the issue.
https://github.com/adafruit/Adafruit_nR ... ino/issues
Good point.
I don't see a way to set the BLE UART baudrate. I think the following only works for the nRF52 hardware UARTs (non-BLE).
https://github.com/adafruit/Adafruit_nR ... q=baudrate
I would suggest opening an issue and requesting a setable BLE UART. If there is a way that will come out of the issue.
https://github.com/adafruit/Adafruit_nR ... ino/issues
Please be positive and constructive with your questions and comments.