Nano Bluetooth and PC

Can a Nano Bluetooth have 2 way coms with a PC or should I use a Nano with a normal external Bluetooth module.

Hi @olly. Yes, it can.

There is an overview of the BLE communication protocol, which is used by the Nano 33 BLE boards, here:

https://docs.arduino.cc/libraries/arduinoble/#a-quick-introduction-to-ble

From the first two paragraphs you might get the impression that the "peripheral" can only be a transmitter of data, and that the "central" can only be a receiver of data. From this impression, the obvious approach would be to implement a peripheral and a central device on the Nano 33 and on the PC.

You can certainly do that, and perhaps for some applications it might make sense. However, you should be aware that a peripheral can receive and transmit data. Communication via a single peripheral will simplify the implementation significantly. In the case where you are communicating between an Arduino board and a PC, it would be most typical for the Arduino board to be the peripheral and the PC the central:

The "ArduinoBLE" library's "ButtonLED" example demonstrates bidirectional communication using the Arduino board as a peripheral device. The example can be accessed via the File > Examples > ArduinoBLE > Peripheral > ButtonLED menu in Arduino IDE.

In case it will be helpful, I'll provide a more minimal demonstration sketch:

#include <ArduinoBLE.h>

BLEService testService("19B10010-E8F2-537E-4F6C-D104768A1214");

BLEByteCharacteristic receiverCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214", BLEWrite);
BLEByteCharacteristic transmitterCharacteristic("19B10012-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify);

byte transmitData;
unsigned long timestamp;

void setup() {
  Serial.begin(9600);
  while (!Serial) {}  // Wait for port to be opened in Serial Monitor.

  if (!BLE.begin()) {
    Serial.println("BLE.begin() failed!");
    while (true) {}  // No point in continuing with the rest of the program.
  }

  // Set the local name the peripheral advertises.
  BLE.setLocalName("Test Peripheral");

  // Set up the service
  BLE.setAdvertisedService(testService);
  // Add the characteristics to the service.
  testService.addCharacteristic(receiverCharacteristic);
  testService.addCharacteristic(transmitterCharacteristic);
  // Add the service.
  BLE.addService(testService);

  // Start advertising.
  BLE.advertise();

  Serial.println("BLE device was successfully initialized.");
}

void loop() {
  // Poll for BLE events.
  BLE.poll();

  // Simulate some periodically changing data (e.g., a sensor reading).
  if (millis() - timestamp >= 1000) {
    timestamp = millis();
    // For the sake of simplicity, this demo just generates a random number as "dummy" data.
    transmitData = random(100);
  }

  if (transmitData != transmitterCharacteristic.value()) {
    // The data changed, so update the value of the characteristic.
    transmitterCharacteristic.writeValue(transmitData);
  }

  if (receiverCharacteristic.written()) {
    Serial.print("Received data: ");
    Serial.println(receiverCharacteristic.value());
  }
}

Hi ptillisch, thank you Very much for your excellent detailed reply!

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per

Your bidirectional example is excellent.

I had read about the single direction function and I thought about using AT+ROLE=0 and =1 to change direction for the reply because the Nano always spoke first.

Messy , amateurish, probably wouldn't work.

Thanks again.