CYW43 boards
Measurements on 2 CYW43 boards shown below.
Top to bottom
- Arduino Portenta H7 with external BLE antenna (CYW4343W) [there is an Ethernet/camera shield mounted on top that I didn't want to disassemble].
- Raspberry Pi 3A+ (CYW43455)
BLE libraries
The Arduino IDE supports the Portenta H7 using the ArduinoBLE library with the Mbed OS. I had some difficulty getting a working iBeacon program in this configuration even though I had used a similar setup with the nRF52840 boards. I managed to kill the Mbed OS in a couple of attempts (compiled fine, just wouldn't execute and required the "double reset" to recover). I didn't want to spend a lot of time debugging, so I used a BLE advertising program that just set up an LED service. Again, I was not able to adjust the BLE TX power. This particular chipset is supposed to default to 4 dBm for BLE, but I haven't been able to find what power levels are available for programming (spec max is 12 dBm). For the Raspberry Pi, I used BlueZ with the Linux HCI (Host Control Interface) service to set up the iBeacon - specifically the hcitool which unfortunately has been deprecated.
Arduino Portenta H7
portenta_ble_ledservice.ino (unmodified example from ArduinoBLE that advertises a service)
/*
LED
This example creates a Bluetooth® Low Energy peripheral with service that contains a
characteristic to control an LED.
The circuit:
- Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT,
Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board.
You can use a generic Bluetooth® Low Energy central app, like LightBlue (iOS and Android) or
nRF Connect (Android), to interact with the services and characteristics
created in this sketch.
This example code is in the public domain.
*/
#include <ArduinoBLE.h>
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // Bluetooth® Low Energy LED Service
// Bluetooth® Low Energy LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int ledPin = LED_BUILTIN; // pin to use for the LED
void setup() {
Serial.begin(9600);
while (!Serial);
// set LED pin to output mode
pinMode(ledPin, OUTPUT);
// begin initialization
if (!BLE.begin()) {
Serial.println("starting Bluetooth® Low Energy module failed!");
while (1);
}
// set advertised local name and service UUID:
BLE.setLocalName("LED");
BLE.setAdvertisedService(ledService);
// add the characteristic to the service
ledService.addCharacteristic(switchCharacteristic);
// add service
BLE.addService(ledService);
// set the initial value for the characeristic:
switchCharacteristic.writeValue(0);
// start advertising
BLE.advertise();
Serial.println("BLE LED Peripheral");
}
void loop() {
// listen for Bluetooth® Low Energy peripherals to connect:
BLEDevice central = BLE.central();
// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
// while the central is still connected to peripheral:
while (central.connected()) {
// if the remote device wrote to the characteristic,
// use the value to control the LED:
if (switchCharacteristic.written()) {
if (switchCharacteristic.value()) { // any value other than 0
Serial.println("LED on");
digitalWrite(ledPin, HIGH); // will turn the LED on
} else { // a 0 value
Serial.println(F("LED off"));
digitalWrite(ledPin, LOW); // will turn the LED off
}
}
}
// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}
I was surprised at the received power value (if the default power really is 4 dBm then the performance is quite a bit better than the RAK4631 [nRF52840] by > 7 dBm). It is using a different antenna (quite a bit smaller) which may make a difference. I need to try changing that.
.
Raspberry Pi 3A+
The Linux hcitool is somewhat cryptic to use. I found the commands to set up an iBeacon on the raspberry pi forum.
hcitool iBeacon
// Set up iBeacon advertising data
sudo hcitool cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00
// Start BLE advertising
sudo hcitool cmd 0x08 0x000A 01
// Query transmit power
sudo hcitool -i hci0 cmd 0x08 0x007
I remotely connected to the RPi using two puTTy terminals. The first one is used to issue the hcitool commands and the second is running btmon, so that I could see the response in a human readable format.
The TX power of -56 dB in the first response is a data field in the iBeacon data - this tells the receiver of the beacon what the expected RSSI is at 1 meter and is used for determining proximity.
The TX power of 12 dBm in response to the TX power setting query is somewhat confusing. This is the default value for Bluetooth BDR (and is the max power setting). The default for BLE should be 4 dBm. The command to set TX power using hcitool is vendor specific and it did not work. Google searches show that others have also not been able to get it to work for the Infineon (Cypress) chipsets.
Whatever the default is, the RPi has about 7 dBm less received carrier power than the Portenta - probably due to external antenna on the Portenta.
.
This concludes the testing that I had planned for this special project. A summary post will follow shortly.