Possibly damaged two Nano 33 BLE's trying to connect to app

Unless the App does something obvious, such as causing over-voltage or over-heating, the Nano cannot be damaged by it. I suspect your boards may have arrived with a manufacturing fault, or were perhaps damaged during packaging or during transport.

Maybe I should try to submit a warranty claim. The cost is starting to add up.

Would that mean the Nano 33 BLE can also use serial communication. It does appear a lot easier.

I think it has two on board serial ports? In any case, there is always Software Serial

I certainly would.

@ChrisWard
Wow. I submitted a warranty claim before I went to CT. Came back about a week later and all three boards now connect as well as they did when new. I have no idea what is going on. It appears the boards needed a good long rest?

In any case back to the app. The challenge now is to get the data from my Nano 33 BLE to the app.

I don't know how to do this. I have several issues.

  1. Just getting the data into a variable, I can't seem to figure out how to do this. This section of the code is what I tried:
    image

That gave me this runtime error:

  1. My Arduino code sends all the data in signed integers and the only way to display it appears to be by labels. Therefore I need some way of converting the integers to strings.

.... and watering twice daily :joy:

No you don't - Labels will display numbers too, no conversion required.

Where did you get those UUIDs from? If you created them, they have to be assigned in the Arduino's Sketch.

How to register for and then receive integers for example:

My UUIDs were generated using an online UUID generator. They are put into the code: I believe I have them assigned in the top part of the sketch.

[code]
const int RadPin = A0;      // Radiator Input Thermister
const int CndPin = A1;      // Condenser Input Thermister
const int AuxPin = A2;      // Auxilary Input Not used at this time
const int FanPin = 9;       // Set Fan pin
const long Period = 10000;  // Recheck period

long previousMillis = 0;    // last time the temperature levels were checked, in ms

                    /*
                      Temperatur Monitor

                      This example creates a Bluetooth® Low Energy peripheral with the standard Temperature service and
                      level characteristic. Pins A0, A1 and A2 are used to calculate the temperatures of 3 sensors.
                      The data is calculated by the time set in the constant Period.

                      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>

// Define the Temperature Service
BLEService TempService("53436b3f-5f91-474b-963e-8b09b170c670");        //*** BLEService Class Any Hex Name 128-bit UUID in String format *********************************************************

// Define Temperature Level Characteristics as BLEUnsignedIntCharacteristic, BLEUnsignedCharCharacteristic will not work.

// Note define Characteristics and  
BLEUnsignedIntCharacteristic RadLevelChar("694d181e-4421-47f3-9653-c4d6bb295a07",  // standard 128-bit characteristic UUID *******************************
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedIntCharacteristic CndLevelChar("0407dd37-ae29-4ec7-ab40-a83898d610df",  // standard 128-bit characteristic UUID *******************************
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedIntCharacteristic AuxLevelChar("ad43db8f-e3e6-4025-b745-43f2100f27e1",  // standard 128-bit characteristic UUID *******************************
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes

void setup() {
  Serial.begin(9600);    // initialize serial communication
  //while (!Serial);

  pinMode(LED_BUILTIN, OUTPUT); // initialize the built-in LED pin to indicate when a central is connected

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1);
  }

  /* Set a local name for the Bluetooth® Low Energy device
     This name will appear in advertising packets
     and can be used by remote devices to identify this Bluetooth® Low Energy device
     The name can be changed but maybe be truncated based on space left in advertisement packet
  */

  BLE.setLocalName("Testing 123"); //******************************************************************************

    BLE.setAdvertisedService(TempService); // add the service UUID
    TempService.addCharacteristic(RadLevelChar); // add the radiator level characteristic
    TempService.addCharacteristic(CndLevelChar); // add the condenser level characteristic
    TempService.addCharacteristic(AuxLevelChar); // add the aux level characteristic
    BLE.addService(TempService);  // Add the Temperature service
    RadLevelChar.writeValue(0);   // set initial value for this characteristic
    CndLevelChar.writeValue(0);   // set initial value for this characteristic
    AuxLevelChar.writeValue(0);   // set initial value for this characteristic

  // Start advertising Bluetooth® Low Energy.  It will start continuously transmitting Bluetooth® Low Energy
  // advertising packets and will be visible to remote Bluetooth® Low Energy central devices
  // until it receives a new connection

  BLE.advertise();  // start advertising

  // Serial.println("Bluetooth® device active, waiting for connections...");
}


  void loop() {
  // wait for a Bluetooth® Low Energy central
  BLEDevice central = BLE.central();

  // if a central is connected to the peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's BT address:
    Serial.println(central.address());
    // turn on the LED to indicate the connection:
    digitalWrite(LED_BUILTIN, HIGH);

    // check the temperature levels every Period (ms)
    // while the central is connected:
    while (central.connected()) {
      long currentMillis = millis();
      // if Period ms have passed, check the temperature levels:
      if (currentMillis - previousMillis >= Period) {
        previousMillis = currentMillis;
        updateTemperatures();
      }
    }
    // when the central disconnects, turn off the LED:
    digitalWrite(LED_BUILTIN, LOW);
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
  }

  void updateTemperatures() {
  // Read the current voltage level on each analog input pin.
  //   This is used here to simulate the charge level of temperaturs.

  int Rad = analogRead(RadPin);
  int Cnd = analogRead(CndPin);
  int Aux = analogRead(AuxPin);
/*
  int RadLevel = map(Rad, 0, 1023, 0, 100);
  int CndLevel = map(Cnd, 0, 1023, 0, 100);
  int AuxLevel = map(Aux, 0, 1023, 0, 100);
 */  
  
  int RadLevel = Rad;
  int CndLevel = Cnd;
  int AuxLevel = Aux;
  
  
  Serial.print("Rad Level % is now: "); Serial.println(RadLevel);
  Serial.print("Cnd Level % is now: "); Serial.println(CndLevel);
  Serial.print("Aux Level % is now: "); Serial.println(AuxLevel);

  RadLevelChar.writeValue(RadLevel);            // update the Radiator level characteristics
  CndLevelChar.writeValue(CndLevel);            // update the Condenser level characteristics
  AuxLevelChar.writeValue(AuxLevel);            // update the Aux level characteristics
  }
[/code]

Thanks

I was working on something similar. I was going to try to get 1 variable to start out with. Hears what I was working on, based on your last example. But I think I may have to modify my Ardunio sketch to only send one characteristic. I will have to look into that tomorrow.

The values have already been received, so testing for connectivity here is redundant:

Only use one characteristic UUID for all integer values. Make sure signed/unsigned matches in Sketch and App code.

Sketch (no idea if it will work but it does at least compile)
Nano33VehicleData.txt (5.8 KB)

//09/06/2022 07:00:41
//Arduino Nano 33 BLE vehicle data to Android App
const int RadPin = A0;      // Radiator Input Thermister
const int CndPin = A1;      // Condenser Input Thermister
const int AuxPin = A2;      // Auxilary Input Not used at this time
const int FanPin = 9;       // Set Fan pin
const long Period = 10000;  // Recheck period

long previousMillis = 0;    // last time the temperature levels were checked, in ms

                    /*
                      Temperatur Monitor

                      This example creates a Bluetooth® Low Energy peripheral with the standard Temperature service and
                      level characteristic. Pins A0, A1 and A2 are used to calculate the temperatures of 3 sensors.
                      The data is calculated by the time set in the constant Period.

                      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>

// Define the Temperature Service
BLEService TempService("53436b3f-5f91-474b-963e-8b09b170c670");        //*** BLEService Class Any Hex Name 128-bit UUID in String format *********************************************************

// Note define Characteristics and
BLEUnsignedIntCharacteristic IntCharacteristic("694d181e-4421-47f3-9653-c4d6bb295a07", BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes

void setup()
{
               Serial.begin(9600);    // initialize serial communication with PC Arduino Serial Monitor


               pinMode(LED_BUILTIN, OUTPUT); // initialize the built-in LED pin to indicate when a central is connected

               // begin initialization
               if (!BLE.begin())
               {
                 Serial.println("starting BLE failed!");

                 while (1);
               }

               /* Set a local name for the Bluetooth® Low Energy device
                  This name will appear in advertising packets
                  and can be used by remote devices to identify this Bluetooth® Low Energy device
                  The name can be changed but maybe be truncated based on space left in advertisement packet
               */

               BLE.setLocalName("Testing123"); //No spaces in name

               BLE.setAdvertisedService(TempService); // add the service UUID
               TempService.addCharacteristic(IntCharacteristic); // All integer values
               BLE.addService(TempService);  // Add the Temperature service

               // Start advertising Bluetooth® Low Energy.  It will start continuously transmitting Bluetooth® Low Energy
               // advertising packets and will be visible to remote Bluetooth® Low Energy central devices
               // until it receives a new connection

               BLE.advertise();  // start advertising

               // Serial.println("Bluetooth® device active, waiting for connections...");
}


void loop()
{
               // wait for a Bluetooth® Low Energy central
               BLEDevice central = BLE.central();

               // if a central is connected to the peripheral:
               if (central)
               {
                         Serial.print("Connected to central: ");
                         // print the central's BT address:
                         Serial.println(central.address());
                         // turn on the LED to indicate the connection:
                         digitalWrite(LED_BUILTIN, HIGH);

                         // check the temperature levels every Period (ms)
                         // while the central is connected:

                         while (central.connected())
                         {
                                   // if Period ms have passed, check the temperature levels:
                                   if (millis() - previousMillis >= Period)
                                   {
                                     previousMillis = millis();

                                     updateTemperatures();
                                   }
                         }

                         // when the central disconnects, turn off the LED:
                         digitalWrite(LED_BUILTIN, LOW);
                         Serial.print("Disconnected from central: ");
                         Serial.println(central.address());
               }
}

void updateTemperatures()
{
// Read the current voltage level on each analog input pin.
// This is used here to simulate the charge level of temperaturs.

int Rad = analogRead(RadPin);
int Cnd = analogRead(CndPin);
int Aux = analogRead(AuxPin);
/*
int RadLevel = map(Rad, 0, 1023, 0, 100);
int CndLevel = map(Cnd, 0, 1023, 0, 100);
int AuxLevel = map(Aux, 0, 1023, 0, 100);
*/

int RadLevel = Rad;
int CndLevel = Cnd;
int AuxLevel = Aux;

               Serial.print("Rad Level % is now: "); Serial.println(RadLevel);
               Serial.print("Cnd Level % is now: "); Serial.println(CndLevel);
               Serial.print("Aux Level % is now: "); Serial.println(AuxLevel);

               IntCharacteristic.writeValue(RadLevel);   // update the Radiator level characteristics
               IntCharacteristic.writeValue(CndLevel);   // update the Condenser level characteristics
               IntCharacteristic.writeValue(AuxLevel);   // update the Aux level characteristics
}

Thanks for the code and example.

Using that code and this app as shown below, I get this message:

When I use the code with the LightBlue app it only reports 1 value, which I believe is the Rad Temp. ?

Note I am not using fan speed for the moment because the sample code does not report it.

Hmm :thinking: Are the UUIDs identical in both App Project and Arduino Sketch?

Right, not sure how the LightBlue App got a value because the write attribute hadn't been included in the Characteristic UUID :upside_down_face:

Not sure why the UUIDs are not published, unless they are not identical in App and Arduino, or the device you selected in the App was actually not the Nano. Problem with BLE is that there are so many libs and so many ways to do the same thing.

Try the attached Sketch update - I have used different values for the UUIDs because they worked on another Project. Copy-paste them into App Inventor.

Nano33VehicleData.txt (5.9 KB)

They appear to be. They were copied and pasted.

// Define the Temperature Service
BLEService TempService("53436b3f-5f91-474b-963e-8b09b170c670");        //*** BLEService Class Any Hex Name 128-bit UUID in String format *********************************************************

// Note define Characteristics and
BLEUnsignedIntCharacteristic IntCharacteristic("694d181e-4421-47f3-9653-c4d6bb295a07", BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes

image

Tried the new code. Got exactly the same results. with both the MIT app and the LightBlue app.

Same runtime error with MIT app:

Same behavior with LightBlue. I was able to determine the LightBlue app was displaying the third value of the three. I guess it uses the last value it gets.

That doesn't make sense though - values should only be received if the UUIDs are accepted.